chartjs-chart-timeline icon indicating copy to clipboard operation
chartjs-chart-timeline copied to clipboard

Different colors on datasets

Open boroneaionut opened this issue 6 years ago • 6 comments

How can I set different colors on all datasets? I tried using the default chartjs dataset options but it is not working and the with the colorFunction I can only set one color (or is it that I don't know how to use it).

Thank you.

boroneaionut avatar Apr 10 '18 06:04 boroneaionut

colorFunction returns Color() object by passing data element into it. You can log arguments in colorFunction to see arguments of the function.

fanthos avatar Apr 10 '18 07:04 fanthos

Can you please give me an example? I can't seem to figure it out.

boroneaionut avatar Apr 10 '18 07:04 boroneaionut

Nevermind, I figured it out. Thank you for your response.

boroneaionut avatar Apr 10 '18 07:04 boroneaionut

https://github.com/fanthos/chartjs-chart-timeline/blob/master/timeline.js#L245 The data object is the array: [starttime, endtime, text, extras....]. The color could passed as extra argument. The extras could be accessed by

colorFunction(text, dataobj) {
extras = dataobj[3]
...
}

fanthos avatar Apr 10 '18 07:04 fanthos

That's what I have done. Thank you for the explicit response. And very nice job with the plugin. Very useful. 👍

Have a great day!

boroneaionut avatar Apr 10 '18 07:04 boroneaionut

@fanthos need to set min and max time on x axis how i can achieve?

aftab-git avatar Dec 22 '18 14:12 aftab-git