reactjs - Set max value for Y axis in react-chart -
i have implemented react-chart using of following doc
http://www.chartjs.org/docs/latest/charts/line.html
i have implemented doc not show how set maximum value y axis. want set max y axis 100. because dataset not exceed value on 19, max y axis set @ 20.
how can set max y axis value 100 though data not exceed 19.?
my code
class linecharts extends component { constructor() { super(); } render() { var chartdata = { labels: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"], datasets: [ { color: "#4d5360", highlight: "#616774", bordercolor: "rgba(179,181,198,1)", pointbackgroundcolor: "rgba(179,181,198,1)", pointbordercolor: "#fff", pointhoverbackgroundcolor: "#fff", pointhoverbordercolor: "rgba(179,181,198,1)", label: 'current lag', fill: true, linetension: 0.1, fillcolor: "rgba(151,187,205,0.2)", strokecolor: "rgba(151,187,205,1)", pointcolor: "rgba(151,187,205,1)", pointstrokecolor: "#fff", scaleoverride: true, scalestartvalue: 0, scalestepwidth: 1, scalesteps: 5, data: [12, 19, 3, 5, 2, 3, 4, 7, 9, 3, 12, 19], }, ], } var chartoptions = { showscale: true, pointdot: true, showlines: false, title: { display: true, text: 'chart.js bar chart' }, legend: { display: true, labels: { boxwidth: 50, fontsize: 10, fontcolor: '#bbb', padding: 5, } }, } return ( <linechart data={chartdata} options={chartoptions} width="600" height="250"/> ); } } export default linecharts;
you can try this:
var chartoptions = { showscale: true, pointdot: true, showlines: false, title: { display: true, text: 'chart.js bar chart' }, legend: { display: true, labels: { boxwidth: 50, fontsize: 10, fontcolor: '#bbb', padding: 5, } }, scales: { yaxes: [{ ticks: { beginatzero:true, min: 0, max: 100 } }] } }
Comments
Post a Comment