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

Enable zoom plugin on treemap controller #141

Merged
merged 12 commits into from
Oct 12, 2022
Merged

Conversation

stockiNail
Copy link
Collaborator

@stockiNail stockiNail commented Oct 10, 2022

@stockiNail stockiNail added the enhancement New feature or request label Oct 10, 2022
@stockiNail stockiNail added this to the 2.1.0 milestone Oct 10, 2022
@stockiNail stockiNail marked this pull request as ready for review October 10, 2022 13:19
@stockiNail stockiNail marked this pull request as draft October 10, 2022 19:14
@stockiNail
Copy link
Collaborator Author

I set this as draft because I have forgotten to manage dataset.tree as array of numbers.

@stockiNail stockiNail marked this pull request as ready for review October 11, 2022 12:11
@stockiNail
Copy link
Collaborator Author

@kurkle do you think a sample is needed (importing zoom plugin)? And some tests (even if we didn't do for datalabels)?

@stockiNail
Copy link
Collaborator Author

zoom.drag doesn't seem working...

@stockiNail stockiNail marked this pull request as draft October 11, 2022 12:16
@kurkle
Copy link
Owner

kurkle commented Oct 12, 2022

@kurkle do you think a sample is needed (importing zoom plugin)? And some tests (even if we didn't do for datalabels)?

A sample would be ok.
I'm undecided about tests. Let's do those later in any case.

@stockiNail
Copy link
Collaborator Author

I'm still struggling with zoom.drag. I'm debugging in CHART.JS and in the controller because the scales are changing their min/max without any reason, only click on the chart. I'm going in deep... it seems something related to meta._parsed array.....

@kurkle
Copy link
Owner

kurkle commented Oct 12, 2022

I think it would make things easier to move away from the tree before doing this.

@stockiNail
Copy link
Collaborator Author

I think it would make things easier to move away from the tree before doing this.

Yes, t could be. But if you agree, I'd like to understand better how it works in CHART.JS (forgive my lack of knowledge on this internal parts of code) and probably this analysis will help me (at least me ;)) to understand better how to remove tree option in favor to data (for instance implementing parse method).

@stockiNail
Copy link
Collaborator Author

@kurkle if think I understood why I have issues with zoom.drag.
First of all, it's not related to zoom.drag itself but it's related to updateRangeFromParsed method of DatasetController.
This method is looking for scale.axis value to calculate the range of the scale and in treemap controller data, we store x and y properties (location of the element). CHART.JS is expecting x and y as property for data structure as object.

I think the final solution is to separate the data parsing and the element size calculation (planned for version 3).
Now I'm looking for a workaround.

@stockiNail
Copy link
Collaborator Author

@kurkle Overriding updateRangeFromParsed method, drag is working.
Off topic: do you know why zoom plugin draw the "drag" rectangle in the beforeDatasetsDraw hook instead of the after one?

@stockiNail stockiNail marked this pull request as ready for review October 12, 2022 15:13
@stockiNail
Copy link
Collaborator Author

Ready for review. Sorry but the updateRangeFromParsed issue was time consuming to fix.

@kurkle
Copy link
Owner

kurkle commented Oct 12, 2022

@kurkle Overriding updateRangeFromParsed method, drag is working. Off topic: do you know why zoom plugin draw the "drag" rectangle in the beforeDatasetsDraw hook instead of the after one?

I think its so that for example points/lines are drawn on top of the drag area, but am not sure.

src/controller.js Outdated Show resolved Hide resolved
src/controller.js Outdated Show resolved Hide resolved
@stockiNail
Copy link
Collaborator Author

I think its so that for example points/lines are drawn on top of the drag area, but am not sure.

Yes, I didn't add another comment but yes. Nevertheless for treemap, it's quite useless because the drag area is not visible (below the elements). I'd like to submit a PR to zoom plugin, adding drawTime option to zoom.drag (like in the annotation plugin). What do you think?

@kurkle kurkle merged commit 645a870 into kurkle:main Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to add the chartjs-plugin-zoom plugin plugin?
2 participants