Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line Graph line not smooth / Updating max tick limit #5297

Closed
cpphen opened this issue Feb 23, 2018 · 5 comments · Fixed by #5880
Closed

Line Graph line not smooth / Updating max tick limit #5297

cpphen opened this issue Feb 23, 2018 · 5 comments · Fixed by #5880

Comments

@cpphen
Copy link

cpphen commented Feb 23, 2018

Hello,

  1. I am using the line graph to display an array of data (360 in length) and my problem is that the lines appear to be rough and not smooth. I am also currently passing in an array of labels that is also 360 in length to the xAxes option (not global labels). How can I display the data and have a smooth line?

this.linegraph = new Chart(ctx, { type: 'line', data: { datasets: [ { data: this.props.info.values.buy, borderWidth: 2.5, borderColor: "#1FA7B9", fill: false, lineTension: 0, // cubicInterpolationMode: 'default', radius: 0 // backgroundColor: "#00C7B1" }, { data: this.props.info.values.rent, borderWidth: 2.5, borderColor: "#00C7B1", fill: false, lineTension: 0, // cubicInterpolationMode: 'default', radius: 0, // backgroundColor: "#1FA7B9" } ], // labels: this.props.xLabels }, options: { elements: { line: { tension: 0 }, point: { radius: 0 } }, scales: { yAxes: [ { scaleLabel: { display: true, labelString: 'Average Total Net Costs/Month' }, gridLines: { // display: false // color: 'red', drawBorder: false, // zeroLineColor: 'grey' }, ticks: { suggestedMin: 0, suggestedMax: maxSize, callback: function (value, index, labels) { return Number(value) / 1000 + 'K'; } } } ], xAxes: [ { type: 'category', scaleLabel: { display: true, labelString: 'Years at Residence' }, gridLines: { // display: false drawBorder: false, // tickMarkLength: 20 }, labels: this.state.labels, ticks: { suggestedMin: 0, suggestedMax: 360, // autoSkip: true, maxTicksLimit: 30, stepSize: 0, // stepSize: 24 callback: function (value, index, labels) { return Math.floor(index / 12) + 1; } }, } ], }, legend: { display: false }, layout: { padding: { left: 15, right: 15, top: 20, bottom: 40 } }, responsive: true, maintainAspectRatio: false, // cutoutPercentage: 83 } });

  1. I am also trying to update my maxTicksLimit with the following code:
    this.linegraph.options.scales.xAxes[0].ticks.suggestedMax = nextProps.loantype * 12; this.linegraph.options.scales.xAxes[0].ticks.maxTicksLimit = nextProps.loantype; this.linegraph.update();

When I log out these two values, it shows it has been updated, but my graph still has the same amount of ticks from the first settings and did not update.

@etimberg
Copy link
Member

@henhen87 do you have a fiddle that shows this issue?

@cpphen
Copy link
Author

cpphen commented Feb 23, 2018 via email

@cpphen
Copy link
Author

cpphen commented Feb 23, 2018 via email

@nagix
Copy link
Contributor

nagix commented Dec 2, 2018

This is a test case: https://jsfiddle.net/nagix/s2e4ahck/
issue-5297

This is a similar issue to #4704 and related to #5797.

@nagix
Copy link
Contributor

nagix commented Dec 2, 2018

Regarding the second question, ticks.suggestedMax and ticks.maxTicksLimit are not supported by the 'category' scale type which is the default for line charts. If your x axis labels are numbers at regular intervals, you can try 'linear' scale type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants