Graph.js не применяет мои настройки параметров ⇐ Jquery
-
Гость
Graph.js не применяет мои настройки параметров
I have tried using lots of suggested things but nothing is working
I am trying to start y-axis from 0 but if there is only one data (one label and one data) it gives value on axis from example image -1 to 1 Which I am trying to avoid. If there is multiple data See Image still it is not starting from 0
Below jsDelivr I am using
I have also tried below CDN it did not work https://cdnjs.cloudflare.com/ajax/libs/ ... art.min.js
My frontend is in ejs
Below is the function I am using to create and manipulate chart
function updateChart(lables, data, id, datasetLbl) { let date = moment(); date = date.format('YYYY/MM/DD'); const ctx = document.getElementById(id).getContext('2d'); new Chart(ctx, { type: 'line', data: { labels: lables.length < 1 ? [date] : lables, // Assuming each data point has a label datasets: [ { label: datasetLbl, data: !data.length ? [0] : data, // Assuming each data point has a value borderColor: 'rgb(75, 192, 192)', tension: 0.1, }, ] , }, options: { scales: { y: { beginAtZero: true, suggestedMin: 0, stepSize: 1 }, x: { display: true, }, }, }, }); } I have tried lots of things
options: { scales: { y: { beginAtZero: true, // min: 0, //suggestedMin: 0, ticks:{ //here also I have tried to define suggestedMin and min but did not work }, }, x: { display: true, }, }, }, Nothing is affecting not stepsize not min every option has no effect on my chart
I don't know how to solve it
Источник: https://stackoverflow.com/questions/780 ... ns-setting
I have tried using lots of suggested things but nothing is working
I am trying to start y-axis from 0 but if there is only one data (one label and one data) it gives value on axis from example image -1 to 1 Which I am trying to avoid. If there is multiple data See Image still it is not starting from 0
Below jsDelivr I am using
I have also tried below CDN it did not work https://cdnjs.cloudflare.com/ajax/libs/ ... art.min.js
My frontend is in ejs
Below is the function I am using to create and manipulate chart
function updateChart(lables, data, id, datasetLbl) { let date = moment(); date = date.format('YYYY/MM/DD'); const ctx = document.getElementById(id).getContext('2d'); new Chart(ctx, { type: 'line', data: { labels: lables.length < 1 ? [date] : lables, // Assuming each data point has a label datasets: [ { label: datasetLbl, data: !data.length ? [0] : data, // Assuming each data point has a value borderColor: 'rgb(75, 192, 192)', tension: 0.1, }, ] , }, options: { scales: { y: { beginAtZero: true, suggestedMin: 0, stepSize: 1 }, x: { display: true, }, }, }, }); } I have tried lots of things
options: { scales: { y: { beginAtZero: true, // min: 0, //suggestedMin: 0, ticks:{ //here also I have tried to define suggestedMin and min but did not work }, }, x: { display: true, }, }, }, Nothing is affecting not stepsize not min every option has no effect on my chart
I don't know how to solve it
Источник: https://stackoverflow.com/questions/780 ... ns-setting
Мобильная версия