Skip to content

zoom with slider bar #344

@pigobyte

Description

@pigobyte

i have the chartjs-plugin-zoom.js file in my solution and just added two more function to the chart instance to zoom in and zoom out after the _WheelHandler function.

  chartInstance.ZoomIn = function () {
                        var rect = document.getElementById(chartInstance.canvas.id).getBoundingClientRect();

                        var center = {
                            x: rect.width / 2,
                            y: rect.height / 2
                        };

                        doZoom(chartInstance,1.1,center);
                    };


                    chartInstance.ZoomOut = function () {
                        var rect = document.getElementById(chartInstance.canvas.id).getBoundingClientRect();

                        var center = {
                            x: rect.width / 2,
                            y: rect.height / 2
                        };

                        doZoom(chartInstance,0.909,center);
                    };

and then I just call them on the button click

Woul love to see working example, cant make it work.

Originally posted by @ravau in #43 (comment)

hi .. could you explain better how to use this your solution?
thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions