Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Cannot read property 'minBarLength' of undefined. #53

@gkane6

Description

@gkane6

Hi everyone! Could you guide me on how to use this with reactjs.

in chart.js file

import React, { useEffect } from 'react';
import { Chart as Graph } from 'chart.js';
import 'chartjs-chart-box-and-violin-plot/build/Chart.BoxPlot.js';

export default React.memo(function Chart({ data, options, type }) {
    const chartRef = React.useRef(null);

    useEffect(() => {
        const { current } = chartRef;
        const chartContext = current.getContext('2d');

        new Graph(chartContext, {
            type,
            data,
            options,
        });
    }, [chartRef, data, options, type]);

    return (
        <>
            <canvas id={`${type}-graph`} ref={chartRef} className="Chart" />
        </>
    )})

In ChartBoxPlot.js file

import React from 'react';
import Chart from  './Chart';

const ChartBoxPlot = ({ data, options }) => {
    return (
          <div>
            <div className="Bar">
                <Chart data={data} options={options} type="boxplot" />
            </div>
        </div>);
};
export default ChartBoxPlot;`

This is what I get in the console

Cannot read property 'minBarLength' of undefined
TypeError: Cannot read property 'minBarLength' of undefined
    at ChartElement.calculateBarValuePixels (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:43171:30)
    at ChartElement._updateElementGeometry (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:43066:20)
    at ChartElement._updateElementGeometry (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:55359:62)
    at ChartElement.updateElement (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:43051:6)
    at ChartElement.updateElement (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:55236:53)
    at ChartElement.update (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:43024:7)
    at ChartElement._update (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:41960:6)
    at ChartElement.reset (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:41862:8)
    at http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:47721:16
    at Object.each (http://localhost:64876/vendors~main.88ed1bbe4abec7a73360.bundle.js:40354:9)

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions