• Resolved sflwa

    (@sflwa)


    I saw your earlier post / response about creating a new theme and adding $theme[‘options’]……

    I did that for the title and subtile. I couldn’t figure it out for the axis / unit measures. I guessed at $theme[‘options’][‘scales’][‘grid’][‘color’] = ‘black’;

    Also is it possible to have the “series” show in bar vs (or in addition to) the legend under the graph.

    Finally is there a way to have the custom theme without putting it into the plugin or theme folder – I’m concerned about updates removing it.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author methnen

    (@methnen)

    @sflwa

    1. https://www.chartjs.org/docs/latest/axes/#tick-configuration

    Chart.js docs are helpful usually.

    2. Can you elebarorate on what you mean exactly I’m not sure I understand.

    3. Storing them in the theme was intended to be the way you store them without having to worry about updates removing it.

    If you have a core theme that receives updates that you don’t control you should be using a child them that references the core one and put your Chart.js themes in there.

    Thread Starter sflwa

    (@sflwa)

    Thank you for the reply.

    Ok after some guessing and reviewing the chart.js site I got it
    $theme[‘options’][‘scales’][‘x’][‘ticks’][‘color’] = ‘black’;

    The axis has to get added as a level in the array

    ==========================

    This page shows what I’d like to replicate as close as possible – https://cm101.mywordpress.site/education/

    ==========================

    Right now this is the only file I would need in a child theme – I will just save it to the uploads folder and copy it over when there is a plugin update

    • This reply was modified 4 years ago by sflwa. Reason: Found part of solution - needed to clarify other information
    Thread Starter sflwa

    (@sflwa)

    One additional question for now – do you have integration for the datalabels extension in the plugin??

    https://chartjs-plugin-datalabels.netlify.app/ As I believe this would address part of my question from earlier about getting the label on top of the bar

    Plugin Author methnen

    (@methnen)

    Yes the data labels plugin is already available. It’s how the Show Labels checkbox adds the values to the chart items:

    https://methnen-dropshare.s3.amazonaws.com/pb-mbU47cUpUv.png

    You could try overriding the default behavior of that via a theme but I can’t say off the top of my head if that would work for sure.

    The other option would be adding a filter in your functions.php file of your theme and doing some more advanced filtering of the parameters before they get passed to Chart.js on the page.

    Thread Starter sflwa

    (@sflwa)

    So I was able to update class-m-chart-chartjs.php
    and change $chart_args[‘data’][‘datasets’][ $key ][‘datalabels’] = array…….

    But I couldn’t seem to override this in the theme – I’d much rather do this in the theme if I can – If you can help point me in the right direction I would appreciate it.

    Plugin Author methnen

    (@methnen)

    So that’s where I was getting with the need to probably add a filter for something like this.

    This is the one you’d want:

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

    It works real similar to how a theme works but since it doesn’t have to all be contained within an immediately returned array it’s more flexible in how you can modify the $chart_args array.

    Your theme should have a functions.php file in it somewhere. That’s usually the most straightforward place to add something like this.

    • This reply was modified 4 years ago by methnen.
    • This reply was modified 4 years ago by methnen.
    Thread Starter sflwa

    (@sflwa)

    THANK YOU!!!!! that worked great – I was able to use a code snippet tool so it isn’t directly in the functions.php – that works great

    $chart_args[‘data’][‘datasets’][1][‘datalabels’][‘color’] = “#000000”;

    I think I’m good at this point – I tried the formatter to get the $ before the label but that isn’t the end of the world

    Plugin Author methnen

    (@methnen)

    Awesome. Adding some prefix/suffix support is something I plan on adding, perhaps in the next release once I get a solid chunk of time to actually spend on it.

    My real job and life in general is currently eating up the majority of my time right now though.

    Glad you got it mostly worked out though.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘A couple quick formatting questions’ is closed to new replies.