Home Forums Chart Support CanvasJs with React Typescript

CanvasJs with React Typescript

Viewing 2 posts - 1 through 2 (of 2 total)
  • #37153

    i tried to implement canvasjs react chart with React Typescript (there is now refer page for React Typescript so i followed reactjs refer page) but getting some errors
    pl check implemented code below

    
    import CanvasJSReact from './canvasjs-commercial-3.2.16/canvasjs.react';
    const Canvas = () => {
        const CanvasJS = CanvasJSReact.CanvasJS;
        const CanvasJSChart = CanvasJSReact.CanvasJSChart;
        const options = {
            animationEnabled: true,
            theme: "dark2",
            title: {
                text: "Worpress Featured Plugins"
            },
            axisY: {
                title: "Active Installations",
                scaleBreaks: {
                    autoCalculate: true,
                    type: "wavy",
                    lineColor: "white"
                }
            },
            data: [{
                type: "column",
                indexLabel: "{y}",
                indexLabelFontColor: "white",
                dataPoints: [
                    { "label": "Akismet Anti-Spam", "y": 5000000 },
                    { "label": "Jetpack", "y": 4000000 },
                    { "label": "WP Super Cache", "y": 2000000 },
                    { "label": "bbPress", "y": 300000 },
                    { "label": "BuddyPress", "y": 200000 },
                    { "label": "Health Check", "y": 200000 }
                ]
            }]
        }
    
        return (
            <div>
                <CanvasJSChart options={options} />
            </div>
        );
    }
    
    export default Canvas;

    when i run the project getting ReferenceError: document is not defined error.

    #37161

    @rushikesh-gadekar,

    CanvasJS React charts seem to be working fine with React Typescript. Can you kindly create a sample project reproducing the issue you are facing and share it with us over Google-Drive or Onedrive so that we can look into your code, run it locally at our end to understand the scenario better, and help you out?


    Thangaraj Raman
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.