methnen/m-chart

Can't seem to get theme to appear in new chart

Closed this issue · 3 comments

I've done everything as per the Wiki instructions for creating a theme when using Highcharts, but it's not appearing in the dropdown for themes. Would appreciate any advice. To be honest, I'd prefer to use Chart.js but there doesn't seem to be a way to change colours other than editing the plugin file. Unless there's a way to do it from my theme's CSS?

Thanks,
Sarah

Hey @NinjaBeaver I've got a bunch of people using the theme functionality and it's working for them. So I'd honestly need to see more specifically what you've done to know why it might not be working.

As for Chart.js the way the coloring works in that charting library is very strange and makes it functionally quite difficult to have themes in the same way I was able to do for Highcharts.

That said if you're comfortable with using filter hooks there is one that you could hook into and modify the colors of a Chart.js chart:

https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_args

The example given is for Highcharts so you'd need to modify the colors in a way Chart.js expects instead. You can find more about that here:

https://www.chartjs.org/docs/latest/general/colors.html

Keep in mind you're building an array that will get turned into a javascript object.

I'm happy to take a look at what you've done for the theme you made too and see if I can identify any problems with it.

If you want to send any info to me privately instead of on this issue feel free to email me at:

jamie AT methnen.com

Thanks for replying so quickly! I'll email you. I don't think I'd be too confident at filter hooks. I wondered if the problem might be because it's a child theme, but putting it into the parent didn't do anything either.

Thanks again
Sarah

This turned out to be a PHP syntax error in the custom theme.