Using the stacked area chart as seen in this example http://nvd3.com/ghpages/stackedArea.html
Trying to format the y-axis tick labels and the tooltip labels to be integers instead of floats. Tried changing the follow code from
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.2f'));
to
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.0d'));
Precision remains unchanged (still shows values to the hundredths place). I've followed the Github Wiki to no avail https://github.com/mbostock/d3/wiki/Formatting#wiki-d3_format
Any suggestions or hints will be greatly appreciated.
D3 is a JavaScript library and framework for creating visualizations. D3 creates visualizations by binding the data and graphical elements to the Document Object Model. D3 associates (binding) the data (stuff you want to visualize) with the DOM. This allows the user to manipulate, change or add to the DOM.
The JavaScript ecosystem has completely changed during this time, in terms of libraries, best practices and even language features. Nevertheless, D3 is still here. And it's more popular than ever.
Chart. js provides a selection of ready to go charts which can be styled and configured while D3 offers building blocks which are combined to create virtually any data visualisation.
D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS.
Looks like this isn't supported by nvd3 at the moment. See the offending line.
In addition, your format specification isn't quite right. As mentioned in the documentation, "d"
ignores non-integer values. So you probably want ",.0f"
instead, which means:
,
: use commas to separate thousands..0
: precision of zero (the exact meaning of this depends on which type is in use).f
: The type; in this case, Number.toFixed. This means a fixed number of digits (the precision) appear after the decimal point, and the number is rounded if necessary.this one can format label text from float to integer.
for pie chart:
chart.pie.valueFormat(d3.format(',.0d'));
for line chart:
chart.yAxisTickFormat(d3.format(',.0d'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With