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

[Chart.js] add view-value-change event #1605

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

IndraGunawan
Copy link
Contributor

@IndraGunawan IndraGunawan commented Mar 10, 2024

Q A
Bug fix? yes
New feature? yes
Issues Fix #...
License MIT

I was following this tutorial https://ux.symfony.com/demos/live-component/chartjs and everything works fine until I want to modify the y axis label.

i read about this documentation that I can extend the default behaviour https://symfony.com/bundles/ux-chartjs/current/index.html#extend-the-default-behavior

it works on the initial chart render, but when I change some values the chart gets re-render, and the scale options that I added on pre-connect event get overwritten by $chart->setOptions([...]), when I tried to remove $chart->setOptions([...]) on PHP code completely to use the options fully from pre-connect, and I got this error

Uncaught TypeError: Stimulus Value "symfony--ux-chartjs--chart.viewValue" - Cannot convert undefined or null to object

hence I propose to introduce a new event that makes it able to add additional options while we are still using $chart->setOptions([...]) everytime the chart gets re-rendered

this is also fixed on viewValueChanged method if no $chart->setOptions([...]) provided

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Mar 10, 2024
Copy link
Collaborator

@smnandre smnandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe add a test or two ?

@IndraGunawan
Copy link
Contributor Author

@smnandre test added

@IndraGunawan IndraGunawan changed the title [Chart.js] introduce on-view-value-changed event [Chart.js] introduce view-value-change event Mar 16, 2024
src/Chartjs/CHANGELOG.md Outdated Show resolved Hide resolved
@IndraGunawan IndraGunawan changed the title [Chart.js] introduce view-value-change event [Chart.js] add view-value-change event Mar 17, 2024
Copy link
Collaborator

@smnandre smnandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Mar 17, 2024
@kbond
Copy link
Member

kbond commented Mar 20, 2024

Thank you @IndraGunawan.

@kbond kbond merged commit adccf73 into symfony:2.x Mar 20, 2024
13 of 14 checks passed
@IndraGunawan IndraGunawan deleted the chartjs-introduce-event branch March 21, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants