c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.34k stars 1.39k forks source link

Gauge shows wrong threshold color if there is more than one data value for the series #2750

Closed GDFaber closed 4 years ago

GDFaber commented 4 years ago

Problem description If a gauge chart gets more than one data row/column, the values are summed up for each series, which works nicely as far as I can tell.

However there seems to be a problem finding the right level color after summing up the values: The arcs as well as the legend are colored according to the first data value instead of the sum (the tooltips show the correct color).

How to reproduce Go to https://c3js.org/samples/chart_gauge.html and change the example code like this:

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 20, 20],
            ['data2', 40, 40]
        ],
        type: 'gauge',
    },
    color: {
        pattern: ['#FF0000', '#F97600', '#F6C600', '#60B044'],
        threshold: {
            values: [30, 60, 90, 100]
        }
    }
});
GDFaber commented 4 years ago

I might have fixed it, but need to do more testing first to be sure it doesn't break anything else instead.