Chart.js the number of Y-axis labels for many decimal places

I am having problems with chart.js Y label labels. I have the following data.

var data = {
labels: ["1","2","3","4","5"],
datasets: [
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.5)",
        strokeColor: "rgba(220,220,220,0.8)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        data: [0.15000000000000088,0.15000000000000133,0.15000000000000177,0.15000000000000221,0.15000000000000308]
    },
]
};

and I get this result.

Graph Result Image

As you can see, the Y-axis marks are cut after the fifth decimal place. How to show all decimal numbers from my data in Y-Axis shortcuts?

TIA.

+4
source share
3 answers

try it

var data = {
labels: ["1","2","3","4","5"],
datasets: [
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.5)",
        strokeColor: "rgba(220,220,220,0.8)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        data: [15000000000000088,15000000000000133,15000000000000177,15000000000000221,15000000000000308]
    },
]
};

// create chart
var ctx = document.getElementById("radaranalytics").getContext('2d');
var radar = new Chart(ctx).Bar(data, {
  scaleBeginAtZero: false,
  scaleLabel: "<%=value/100000000000000000%>",
  tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value/100000000000000000 %>",
});

Fiddle - https://jsfiddle.net/2g794kxh/


Note that rounding the values ​​on the chart is above the limit. See fooobar.com/questions/1619005 / ... for more details .

, / , 88, 133, 177 .., / 0.150000.....

+1

, , , :

var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        yAxes: [{
            ticks: {
                // Include a dollar sign in the ticks
                callback: function(value, index, values) {
                    return '$' + value;
                }
            }
        }]
    }
}
});

http://www.chartjs.org/docs/latest/axes/labelling.html#creating-custom-tick-formats

0

scaleStepWidth , . , , Chart.Core.js Chart.js github.

new Chart(ctx).Bar(datasets, {scaleStepWidth : 0.00000000000000050});
-2

Source: https://habr.com/ru/post/1619004/


All Articles