usage - Angular NVD3 LineChart
I am getting milliseconds
, converting them to ('%H:%M')
format to display on x-axis.
xAxis: {
tickFormat: function(d) {
return d3.time.format('%H:%M')(new Date(d));
},
The above works fine, and shows data in format 10:30
.
i need to format it's styling, 10:
in different color and 30
in different.
I wrote below Javascript,
xAxis: {
axisLabel: '',
tickFormat: function(d) {
var xlabel = d3.time.format('%H:%M')(new Date(d));
var xlabelB = xlabel.substring(0, 3);
var xlabelA = xlabel.substring(3, 5);
var text = '<span class="lightText">'+ xlabelB + '</span><span class="boldText">' + xlabelA + '</span>';
console.log(text);
return text;
},
But the above is rendered inside <Text> tag
, so it does not render html.
How can i achieve the same. Here is the plunker
Here is the generated html after formatting,
<text dy=".71em" y="10" transform="" style="text-anchor: middle;"><span class="lightText">10:</span><span class="boldText">30</span></text>
Before Formatting
<text dy=".71em" y="10" transform="" style="text-anchor: middle;">10:30</text>