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

TypeError: Cannot read property 'plugins' of undefined #31

Closed
pzg250 opened this issue Oct 14, 2019 · 1 comment
Closed

TypeError: Cannot read property 'plugins' of undefined #31

pzg250 opened this issue Oct 14, 2019 · 1 comment

Comments

@pzg250
Copy link

pzg250 commented Oct 14, 2019

Hi,
I am trying to use this plugin in react project but got an error. It shows TypeError: Cannot read property 'plugins' of undefined
Could you help? Thx in advanced.

Some of the code:

import ChartistGraph from "react-chartist";
import { ChartistLib, Chartist } from "chartist";
...

render() {
    let  chartOptions={
        axisX: {
            showGrid: fal
        },
        axisY: {
            showGrid: false,
            showLabel: false,
            low: 0,
            high: this.state.weeklySalesStatisticsBarChartData.high,
            offset: 0,
        },
        fullWidth: true,
        offset: 0,
        chartPadding: 25,
        plugins: [
            Chartist.plugins.ctPointLabels({
                textAnchor: 'middle'
            })
        ]
    };
    return (
        <ChartistGraph
               className="height-200 lineChart lineChartShadow"
               data={this.state.weeklySalesStatisticsBarChartData}
               type="Line"
               options={chartOptions}
               listener={{
                  created: data => {
                     let circleRadius = 4;
                     if (data.type === "point") {
                        let circle = new ChartistLib.Svg("circle", {
                           cx: data.x,
                           cy: data.y,
                           r: circleRadius,
                           'class': "ct-point-circle"
                        });

                        data.element.replace(circle);
                     } else if (data.type === "label") {
                        // adjust label position for rotation
                        const dX = data.width / 2 + (30 - data.width);
                        data.element.attr({ x: data.element.attr("x") - dX });
                     }
                  }
               }}
            />
    )
@pzg250
Copy link
Author

pzg250 commented Oct 14, 2019

Got the reason. Need to import ctPointLabels. Close this ticket.

import ctPointLabels from "chartist-plugin-pointlabels";

@pzg250 pzg250 closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant