question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v2 Line chart with individual point colors?

See original GitHub issue

Hi there,

I’m wondering whether it is possible to have points on a line chart with each a different color (background/border).

Not sure whether this would be something that could be done via a dataset’s metaDataset? It’s possible to grab a particular point’s color in the metaDataset via chart.data.datasets[0].metaDataset._points[0]._view.backgroundColor, but how would I be able to specify each point’s individual color? (preferrably upon instantiation of the chart already)

Thanks in advance for your feedback!

Kind regards, David

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
djooscommented, Mar 12, 2016

Hi @etimberg,

thanks for your quick reply!

I should have mentioned I gave this a go already… This looks like the perfect solution, however that doesn’t seem to work though: is this broken in Chart.js 2.0-dev?

Quick example:

var data = {
    labels: ['x1', 'x2', 'x3', 'x4'],
    datasets: [
        {
            data: [0, 1, 2, 3],
            backgroundColor: ['red', 'green', 'blue', 'yellow']
        }
    ]
};

var chart = new Chart(ctx, {
    type: 'line',
    data: data
});

…just gives me a chart with 4 gray points.

Thanks in advance for your feedback!

Kind regards, David

1reaction
djooscommented, Mar 13, 2016

No worries!

👍

…I hadn’t tried that one yet: it works perfectly, thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vary the colors of same-series data markers in a chart
Set varying colors of data markers (bars, columns, lines, pie or doughnut slices, dots, and other shapes) automatically in an Office chart.
Read more >
ChartJS - Different color per data point - Stack Overflow
Here is how you might use scriptable options on a line chart (based on the example in the docs). On this chart negative...
Read more >
Excel Multi-colored Line Charts - My Online Training Hub
The chart below contains 3 lines; red, yellow and green. They are sitting on top of one another to give the appearance of...
Read more >
How to color code individual data points in line chart
Is there a way to color code the data points in each series to indicate which part of the day the reading was...
Read more >
How to vary colors by point for chart in Excel? - ExtendOffice
If you create a single-series column, bar or line chart, all the data points in the data series are displayed the same color....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found