Can I display one sheet in a chart if I have multiple sheets in a table
-
Hi there,
I’m new to M chart. I have a table with multiple sheets. I would like to create radar charts for each table for different pages. Is it possible to produce different shortcodes for each sheet so that I can embed them to different pages? or I have to create multiple charts? Many thanks.
-
Hello!
Yes you would need multiple charts for that kind of use case.
The multiple sheets functionality is meant for multiple data sets being displayed in a single chart.
hello,
Thanks for the reply. which means there is no way to have multiple sheets, and then output in both single chart of all data sets and multiple charts for each data set?
I need charts that display single data set for the page that describes its data set, and a chart that displays multiple data sets to compare the data on the home page.
-
This reply was modified 3 years, 9 months ago by
liyuchang.
Not in the same chart object. Obviously you could maintain one chart with all data sets and then one for each page.
If you are comfortable with PHP you could conceivably use the
m_chart_chart_args
Filter hook to make what you want happen on a per page basis though by modifying the data passed to the charging library based on the page being viewed.https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_args
What you are attempting is definitely not something the plug-in currently supports by default.
Feel free to make a feature request on GitHub though and it’s conceivable it’ll be something I add at a later date via a shortcode attribute perhaps.
thx, another question is How to set the min and max value of the radar chart? Currently, the min and max values of the chart are the min and max values of the sheet. so each chart get different min and max values
You’d need to alter the chart args again by setting a min max value instead of the default Chart.js behavior of setting them based on the data being displayed.
You could do that, again via the filter hook I mentioned.
Or alternately you could try doing it via a custom theme:
hi there,
thank you for the suggestion. I have tried to follow the instruction to custom Highcharts theme without success. This is what I did1. create m-chart-highcharts-themes directory under /wp-content/themes/twentytwentyone/
2. create a PHP theme file under the new directory with the following codes
return array( 'colors' => array( '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', ), 'yAxis' ( max (10), min (0), ), );
After login again, I couldn’t see the theme I created. Did I miss something?
-
This reply was modified 3 years, 9 months ago by
liyuchang.
Did you give the theme a name comment and put it in the correct place? That example path is just if you’re using the twentytwentyone theme. You’ll need to replace that with whatever theme you are actually using.
Also themes need to have a name comment at the top as in the example.
Hi there,
Thank you for the reply. I’m using rife-free theme, so I put the file in the below directory.
/public_html/wp-content/themes/rife-free/m-chart-highcharts-themes/highChart-MinAndMax.php
This is my codes in highChart-MinAndMax.php
<?php /** * Theme Name: highChart-MinAndMax */ return array( 'colors' => array( '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', ), 'yAxis' ( max (10), min (0), ), );
However, I couldn’t find a theme call highChart-MinAndMax on the theme list when I select radar area chart. Do I miss something?
OK, so your code is goofy and that’s probably the problem.
You need to convert the Highcharts settings your messing with into a PHP array.
So your code should look like this:
<?php /** * Theme Name: highChart-MinAndMax */ return array( 'colors' => array( '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', ), 'yAxis' => array( 'min' => 0, 'max' => 10, ), );
Hi there,
Thank you for your demo. However, after adding the codes
'yAxis' => array( 'min' => 0, 'max' => 10, ),
to the file, it doesn’t really affect the chart. The type I’m using is the radar area. The min and max values are still the min and max values on my dataset, not 0 and 10. I have googled the solution, it seems that yAxis should be the one to change min and max values.
Also, I have to put the file under
/public_html/wp-content/plugins/m-chart/components/chartjs-themes/
in order to pick the highChart-MinAndMax theme, not
/public_html/wp-content/themes/rife-free/m-chart-highcharts-themes/
as suggested on your page, as nothing showed up when I put the file in the above directory. am I put the file in the right place??
many thanks
@liyuchang I think there’s been some miscommunication here.
There’s two separate charting libraries that work with M Chart.
Chart.js is the default one with completely free licensing.
Highcharts is another you can use by installing a separate add-on plugin.
Since the libraries both have different setups the theming is library specific.
If you’re just using the core M Chart plugin than everything should be setup via the Chart.js method and you’ll want to follow their docs for any stuff you want to do.
Which are you using?
Let me know and I’ll see if I can build a theme that should work for you.
hi there,
In the theme option, I pick Highcharts 4.x instead of the default chart.js, and in the type option, I pick the radar area. That’s all I did. The reason for that is the colour that Highcharts 4.x displays better fit with my page (light blue). I didn’t install a separate add-on plugin, I just pick the theme that m chart provides.
all I wish to do is to have a min =0 and max = 10 in my radar chart, as I have different datasets ranging from 0 to 10, and I need to create individual charts for each dataset. it’s better to have consistent look for all charts.
So you’re using the Highcharts theme but not the Highcharts library. That first setting is still set to Chart.js
So you want the theme to go here:
/public_html/wp-content/themes/rife-free/m-chart-chartjs-themes/
If you put it in the plugin theme folder then the next time the plugin updates you’ll lose that file.
And since Chart.js is the library being used your theme code should look like this:
<?php /** * Theme Name: MinAndMax */ return array( 'colors' => array( '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', ), 'options' => array( 'scales' => array( 'r' => array( 'min' => 0, 'max' => 10, ), ), ), );
Let me know how that works out for you.
-
This reply was modified 3 years, 9 months ago by
methnen.
Hi there,
Thank you very much for your help. The codes work for me.
Also, please consider my original request, which able to output individual charts for a table with multiple sheets/data sets. I have made a request as suggested in Github. Thank you very much again.
-
This reply was modified 3 years, 9 months ago by
- The topic ‘Can I display one sheet in a chart if I have multiple sheets in a table’ is closed to new replies.