Home Forums Chart Support Typescript converts CanvaJS.Chart to undefined when building

Typescript converts CanvaJS.Chart to undefined when building

Viewing 4 posts - 1 through 4 (of 4 total)
  • #26888

    I am trying to display a chart using TypeScript/Angular, using the following:

    
        var chart = new CanvasJS.Chart("chartContainer", {
          animationEnabled: true,
          zoomEnabled: true,
          title:{
            text: "Parity",
            fontFamily: "Roboto",
            fontSize: 36,
          },
          axisX: {
            title:"X Axis",
            titleFontSize: 20,
          },
          axisY:{
            title: "Y Axis",
            titleFontSize: 20,
          },
          data: [{
            type: "scatter",
            toolTipContent: "<b>X: </b>{x}<br/><b>Y: </b>{y}",
            dataPoints: [
              { x: 800, y: 350 },
              { x: 900, y: 450 },
              { x: 850, y: 450 },
              { x: 1250, y: 700 },
              { x: 1100, y: 650 }
            ]
          }]
        });

    After I build, the first line in the above code gets converted to this:

    var chart = new undefined("chartContainer", {

    How can I prevent CanvasJS.Chart from being converted to undefined? I am already importing the canvasjs.min file

    #26900

    @user12947,

    Please take a look at this sample project to integrate CanvasJS with Angular.

    In case you are still facing the issue, kindly share sample project reproducing the issue over google-drive or Onedrive so that we can run sample locally at our end, understand the scenario better and help you out.

    —-
    Manoj Mohan
    Team CanvasJS

    #35653

    I think I must be missing something: Doesn’t CanvasJS have official TypeScript type definitions anywhere? I see a seven-years-out-of-date community project on DefinitelyTyped, but nothing from CanvasJS and nothing up-to-date.

    If you really don’t have TypeScript definitions for the library yet, then frankly in 2021 you’re losing sales as a result. I was leaning toward CanvasJS vs. another charting lib but this is a big mark against CanvasJS, so please tell me I’m wrong before I make my recommendation to the client. Thanks.

    (I’ve downloaded the linked sample and don’t see any type definitions for the lib in it. Side note: You really shouldn’t include node_modules in zips like that.)

    • This reply was modified 3 years, 2 months ago by tjcrowder. Reason: Left off key info
    #35698

    @tjcrowder,

    Sorry, there is no official TypeScript type definition for CanvasJS as of now. However, this feature is there in our roadmap but no definite timeline yet as we are working on some other important features at this point in time.

    You really shouldn’t include node_modules in zips like that.

    Thanks for the suggestion. We have provided node_modules for the ease of the user to run the sample.

    —-
    Manoj Mohan
    Team CanvasJS

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

You must be logged in to reply to this topic.