Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding colors for axes. #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlackStar1991
Copy link

Tried I can't understand why it doesn't overwrite the metropole, but takes the default ones.

…rite the metropole, but takes the default ones.
@methnen
Copy link
Owner

methnen commented Sep 19, 2024

Hey @BlackStar1991,

I'd recommend a different approach than this. This would be an example of something I would not merge into the the existing plugin.

This plugin, quite intentionally, does not go in depth with styling and managing the "look and style" of the charts themselves.

To go beyond the defaults, the filter hooks are where you want to look.

Also for testing code changes a great way to make sure what you're trying to do will even work before doing the extra work is to get a Chart.js chart up on jsfiddle or something along those lines and play with it there. Find the solution you want to use and then work on coding that into a plugin or a few functions in your theme's functions.php using the appropriate filter hooks.

Here's an example fiddle that I like to use:
https://jsfiddle.net/methnen/5dxz3wsa/23/

I've got ones for pies and bars and such if you need something more specific.

Then once you've worked out the exact behavior/change you want to make the best filter hook to use is the m_chart_chart_args filter hook:

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

This hook returns the entire array of Chart.js settings immediately before it gets written to the page and rendered as a Javascript object. At that point you have everything you might need (except in some edge cases) to conditionally alter those settings to do most anything you'd want to do.

@BlackStar1991
Copy link
Author

Understood thanks.

I also find problem in your code when try to understand how it work.
It does not check whether the table values ​​are filled with data. For example, I had a table with a large number of variables, and now there are an order of magnitude fewer of them, but your code continues to make a request to the database even with empty cells. https://monosnap.com/file/SWI4TJHMuy4i5fLxjiPQmM1a91c6BQ
I hope you understand what I wrote. There is no data, and the metafields contain hundreds of empty values.

Perhaps it is necessary to somehow visually display which elements of the pseudo table are involved in creating the charts.
https://monosnap.com/file/cQlhylPlzvHIRgfHqlB6RCmVthapr3

@methnen
Copy link
Owner

methnen commented Sep 19, 2024

Yeah, the empty null fields aren't really an issue, unless you're seeing behavior or functionality break due to them somewhere?

But yes, the code that handles that doesn't check for null or empty values at that stage in the process, it does filter them out before processing the chart code itself though, or at least it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants