Is the ColorSchema property depracated? #194
Replies: 3 comments 2 replies
-
|
Hi Andrew, Better Access Charts has evolved a lot in the last year and a half. One of my goals was to implement the current version of the chart.js library. The ColorSchema plugin only supports the version 2.x of the chart.js library. Version 3 of chart.js and higher are no longer supported. You can find more information on this topic in a blog post I published: There is an article in the wiki that lists the available versions and their most important changes: Now you have to make a choice: if you want to stay with ColorSchema you have to stay with the version 2.31.03. If you want to implement the latest version of Better Access Charts (and chart.js) you need to use the new plugin for coloring. Best Regards! P.S.: If you find a plugin for coloring in chart.js with more options or flexibility please give me a hint. ;-) |
Beta Was this translation helpful? Give feedback.
-
|
Thanks Thomas – I appreciate your reply.
That’s a shame – it was good to be able to set colour schemes.
Having had a quick look around, (and speaking as someone who knows nothing about chart.js 😊) I came across this:
https://seantheme.com/color-admin/admin/html/chart-js.html
The colours used are nice – and seem to be set with simple enough code such as this:
backgroundColor: 'rgba('+ app.color.indigoRgb + ', .3)',
I don’t know where app.color is defined, but the code would imply that a set of named colours are available at least?
Andrew
|
Beta Was this translation helpful? Give feedback.
-
|
Hi again Thomas.
Forgive me if I’m talking rubbish here (as I said before, I know nothing about using chart.js, or indeed javascript), but I made the dangerous step of asking AI tools for assistance with this.
Pi.ai told me this:
Although chartjs-plugin-colorschemes doesn't officially support Chart.js version 3, you can make it work with a small workaround. The issue is that Chart.js version 3 changed the way plugins are registered.
To make chartjs-plugin-colorschemes compatible with Chart.js version 3, you need to register the plugin using the new Chart.register() method, like so:
```
import Chart from 'chart.js';
import ColorSchemesPlugin from 'chartjs-plugin-colorschemes';
Chart.register(ColorSchemesPlugin);
```
Now, you can use chartjs-plugin-colorschemes as you normally would:
```
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
plugins: {
colorschemes: {
scheme: 'brewer.Paired12'
}
}
}
});
```
Is this complete fiction, or worth a try?
Andrew
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I used BAC in a project last year, and the client loved the results. So, I'm now doing the same again.
But this time, having used the latest version, code like this:
myChart.ColorSchema.Name = "brewer.Accent8"fails with the error "Method or data member not found". And I notice that in your sample DB, colours are fixed. Is it no longer possible to change the colours of a chart? If it is, how do I do this now? I'm talking about the data series colours, not the background colours.
Many thanks
Andrew
Beta Was this translation helpful? Give feedback.
All reactions