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

Provide chartjs object when Chart component is totally instantiated #1840

Closed
juanparati opened this issue Dec 3, 2021 · 0 comments
Closed
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add vue2-portable
Milestone

Comments

@juanparati
Copy link

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primevue/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=110

I observed that that Chart component wrapper instantiate the ChartJS dynamically, and this makes difficult to load and register ChartJS plugins.

I propose to expose the ChartJS component as soon that object is instantiated, so parents components can register plugins.

It is very easy to achieve replacing the method initChart method with something like:

protected initChart() {
        import('chart.js/auto').then((module) => {
            if (this.chart) {
                this.chart.destroy();
                this.chart = null;
            }

            if (module && module.default) {
                this.chart = new module.default(this.canvas, {
                    // @ts-ignore
                    type: this.type,
                    // @ts-ignore
                    data: this.data,
                    options: this.options
                });

                this.$emit('loaded', this.chart);
            }
        });
    }

Note that this.$emit('loaded', this.chart) was added passing the ChartJS object.

@mertsincan mertsincan self-assigned this Dec 6, 2021
@mertsincan mertsincan added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Dec 6, 2021
@mertsincan mertsincan added this to the 3.10.0 milestone Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add vue2-portable
Projects
None yet
Development

No branches or pull requests

3 participants