hansmaad / chartist-plugin-zoom

Zoom Plugin for Chartist.js
Do What The F*ck You Want To Public License
17 stars 15 forks source link

Cannot read property 'zoom' of undefined #13

Closed chelaruc closed 7 years ago

chelaruc commented 7 years ago

Hi, @hansmaad! Thanks for your great work!

Can you tell me how to use this plugin? I was trying to implement this by myself, but i get this error:

screen shot 2017-05-29 at 13 27 47

My code is like that:

   var data = {
      series: [[
        { x: 1, y: 100 },
        { x: 2, y: 50 },
        { x: 3, y: 25 },
        { x: 4, y: 66 },
        { x: 5, y: 30 },
        { x: 6, y: 22 }
      ]]
    };
    var options = {
      axisX: {
        type: Chartist.AutoScaleAxis
      },
      axisY: {
        type: Chartist.AutoScaleAxis
      },
      plugins: [
        Chartist.plugins.zoom({
          onZoom : function(chart, reset) { storeReset(reset); },
        })
      ]
    };

    var chart = new Chartist.Line('.ct-chart', data, options);
hansmaad commented 7 years ago

The UMD was messed up. I fixed this with 0.4.1 right now. Please try again. I tested with browserify:

var domready = require("domready");
var Chartist = require('chartist');
require('chartist-plugin-zoom');

function storeReset(reset) {
    console.log(reset);
}

domready(function () {
    var data = {
        series: [[
            { x: 1, y: 100 },
            { x: 2, y: 50 },
            { x: 3, y: 25 },
            { x: 4, y: 66 },
            { x: 5, y: 30 },
            { x: 6, y: 22 }
        ]]
    };
    var options = {
        axisX: {
            type: Chartist.AutoScaleAxis
        },
        axisY: {
            type: Chartist.AutoScaleAxis
        },
        plugins: [
            Chartist.plugins.zoom({
            onZoom : function(chart, reset) { storeReset(reset); },
            })
        ]
        };

    new Chartist.Line('.ct-chart', data, options);
});
chelaruc commented 7 years ago

I tried again now, but get the same error :( I'm using angular cli. Can you help me with that?

hansmaad commented 7 years ago

Have you installed npm i --save chartist-plugin-zoom? Have you required require('chartist-plugin-zoom') ?

Does npm list chartist-plugin-zoom print -- chartist-plugin-zoom@0.4.1?

chelaruc commented 7 years ago

Now i get this error:

screen shot 2017-05-30 at 15 33 14

Can you help me to fix it?

hansmaad commented 7 years ago

Try to use import 'chartist-plugin-zoom'.

chelaruc commented 7 years ago

Thanks, it's working now!

ashwinkalyanpur commented 5 years ago

I have still issue in the storereset please find the attach.

screen shot 2019-02-12 at 6 05 15 pm
ashwinkalyanpur commented 5 years ago

I am trying to implement zoom feature for my pie chart now i am facing this problem.