c3js / c3

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

Gauge chart - color threshold can't be updated dynamically #2621

Open felipevegaaraujo opened 5 years ago

felipevegaaraujo commented 5 years ago

I've been trying to update the colors.threshold value dynamically on gauge chart as follows:

chart.internal.config.color_threshold = [ Math.round(randomMaxValue/4), Math.round(randomMaxValue/3), Math.round(randomMaxValue/2), randomMaxValue ];

It doesn't seem to work. Is this a bug on c3?

Here's a codepen where you can see the issue:

https://codepen.io/felipevega/pen/WBaQKP

C3 version: v0.4.23 D3 version: N/A Browser: Chrome - Version 69.0.3497.100 (Official Build) (64-bit) OS: macOS Mojave - Version 10.14

panthony commented 5 years ago

It doesn't seem to work. Is this a bug on c3?

It is not a bug, you are modifying an internal state of the chart (chart.internal.XXX) and this is unexpected.

And it is not working because this config is read once, transformed into something else and never read again.

This feature could eventually be added through the public API.