methnen
Forum Replies Created
-
Forum: Plugins
In reply to: [M Chart] numbers higher than 100000 show as NaN@martinshoe Apologies for the delay I’ve just been utterly swamped with work and life both.
I do have a fix for this and it will go out in the next version.
I hope to get that version out sometime this week.
Forum: Plugins
In reply to: [M Chart] Need to contact you by emailjamie AT methnen.com
Forum: Plugins
In reply to: [M Chart] M-chart heightThis is a little round about and very quickly thrown together but this added to your functions.php file “should” work.
Let me know?
add_action( 'wp_footer', 'm_chart_footer_render_fix' ); function m_chart_footer_render_fix() { ?> <script> var m_chart_footer_render_fix = { charts: [] }; (function( $ ) { 'use strict'; m_chart_footer_render_fix.init = function() { let $chart_divs = $( '.m-chart-container.chartjs' ); $chart_divs.each(function() { let id = $(this).attr('id'); let chart = 'm_chart_chartjs_' + id.replace( 'm-chart-container-', '' ); m_chart_footer_render_fix.charts.push( chart.replace( '-', '_' ) ); }); $('.graph_tab').on( 'click', function() { m_chart_footer_render_fix.redraw_charts(); }); }; m_chart_footer_render_fix.redraw_charts = function() { $.each( m_chart_footer_render_fix.charts, function() { window[this].chart._doResize(); }); }; $( function() { m_chart_footer_render_fix.init(); }); })( jQuery ); </script> <?php }Forum: Plugins
In reply to: [M Chart] M-chart heightHey, I can’t seem to duplicate the issue you’re having on that page.
However, I’m noticing that the chart is not visible until. you hit the tab. I’ve seen this cause issues with the charting library in the past because the library would try to draw the chart when the tab is not visible yet which also means the boundaries haven’t been rendered by the browser yet either.
I think a likely fix is to force Chart.js to redraw the chart when the tab contents are displayed.
I believe the
_doResize()method would probably do that for you.So in the case of that specific page something like this causes the chart to redraw:
m_chart_chartjs_11912_1.chart._doResize();How you trigger that is dependent on your theme and whatever javascript is working that tab of course.
Forum: Plugins
In reply to: [M Chart] numbers higher than 100000 show as NaNI’m honestly not sure. Can you send me a CSV export of the data set and a screenshot of your chart settings to jamie AT methnen.com and I’ll take a look?
Forum: Plugins
In reply to: [M Chart] Set up to 5 decimalsIf you wanted to look at the helper function it’s here:
/components/js/m-chart-chartjs-helpers.min.js
There’s a non minimized version here:
/components/js/m-chart-chartjs-helpers.js
You could modify that to have a higher number of decimals for now but in the future as mentioned I’ll be working to improve how all of this is handled.
This was a first pass at some of this and it’s definitely not perfect.
Forum: Plugins
In reply to: [M Chart] Set up to 5 decimalsHello @legalmartin the numbers are currently being run through a helper function and I believe that’s where the rounding is happening. One of my main goals for the next version is stop u sing that helper function or at least change how that function works so it doesn’t round things like that.
I can’t say when that version will be released though as my paying gig has been extremely busy lately and I’m at the tail end of a house construction project as well so as you can imagine my free time is a bit limited at the moment. 🙂
Forum: Plugins
In reply to: [M Chart] Change background of generated imagesChanging the Chart.js background is actually a bit complicated currently.
Basically what you need to do is a draw a box in the canvas object via a custom Chart.js plugin.
You can see this illustrated in the Chart.js docs:
https://www.chartjs.org/docs/latest/configuration/canvas-background.html
I have some longer term plans to abstract it a bit so that themes can set the background color in a simple manner. I can’t say when that would happen though as my real job takes precedence of course. 🙂
I can verify that it’s doable though as I’ve had some paid customizations I worked on that set background colors and customized the visuals in even more specific ways but it currently requires a custom plugin that hooks into some of the M Chart action/filter hooks spelled out in the docs here:
https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks
Forum: Plugins
In reply to: [M Chart] Customizing Chart Axes with a ThemeHey, I’ve not actually had time and I probably won’t for awhile.
This is a Chart.js matter though and they do have a great Slack channel they provide support from. You’d just need to ask your question formatted as JS and then convert the result to a PHP array as you show above.
If you can’t get a working solution that way I can hopefully take a look soon.
Forum: Plugins
In reply to: [M Chart] Customizing Chart Axes with a ThemeInstead of this:
$theme['options']['plugins']['scales[x]']Try this:
$chart_args['options']['scales']['x']The scales stuff is in the core library and not written as a plugin. Also you put the scale key inside of a string so the library isn’t going to see it correctly.
Forum: Plugins
In reply to: [M Chart] Percentage sign not appearing in the chartYes, for now that stuff gets filtered out so the library (Chart.js/Highcharts) doesn’t choke on the numbers. But the plan is to make it so it gets put back in if possible on the display end. I haven’t worked it all out yet but that’s my goal as it is annoying.
Forum: Plugins
In reply to: [M Chart] Percentage sign not appearing in the chartThis is by design. Special symbols and characters confuse the charting library and actually cause it to fail to render.
I’m working on a way to add them back into the numbers for labels and such but that functionality isn’t in the plugin yet.
Forum: Plugins
In reply to: [M Chart] Change Bar Chart ColorsGlad you found a solution. To answer you though, colors and other things can be changed via the theme system:
https://github.com/methnen/m-chart/wiki/Themes
Or by creating a filter on the chart arguments if you have more advanced needs:
https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_args
Forum: Plugins
In reply to: [M Chart] Adjust Animation default timeHello,
Yes the gist of it is that the settings are in an array that gets converted into a Javascript object and then passed on to Chart.js at the last moment.
This allows the Templates and WordPress style filter hooks to modify things.
It’s relatively straightforward to modify. You simply translate from a javascript object to a PHP array.
So for instance the animation stuff is all in options:
options: { animations { duration: 1000 } }Adding that to the chart arguments via the filter hook stuff:
https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_args
Would look like this:
function filter_m_chart_chart_args( $chart_args, $post, $post_meta, $args ) { $chart_args['options']['animation']['duration'] = 2000; return $chart_args; } add_filter( 'm_chart_chart_args', 'filter_m_chart_chart_args', 10, 4 );Forum: Plugins
In reply to: [M Chart] A couple quick formatting questionsAwesome. 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.