Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
980 views
in Technique[技术] by (71.8m points)

canvas - Angular + Canvasjs: Octal literals are not allowed in strict mode

I am working on full stack development and using Angular, Node/Express and MySQL. I am trying to add a graph in my angular application which will be displayed on the basis of the data available in my database. I have downloaded the sample code available on canvasjs website. Before modifying it to my needs, I have tried to run the sample code and it's throwing an error.

Here's the code:

var chart = new CanvasJS.Chart("chartContainer",
{
  title:{
  text: "Projects by their Status"
  },
  axisX: {
    valueFormatString: "MMMM",
    interval: 1,
    intervalType: "month"

  },
  data: [
  {
    type: "stackedColumn",
    legendText: "Completed",
    showInLegend: "true",
    dataPoints: [
    { x: new Date(2012, 01, 1), y: 71 },
    { x: new Date(2012, 02, 1), y: 55},
    { x: new Date(2012, 03, 1), y: 50 },
    { x: new Date(2012, 04, 1), y: 65 },
    { x: new Date(2012, 05, 1), y: 95 }

    ]
  },
    {
    type: "stackedColumn",
    legendText: "snacks",
    showInLegend: "true",
    dataPoints: [
    { x: new Date(2012, 01, 1), y: 71 },
    { x: new Date(2012, 02, 1), y: 55},
    { x: new Date(2012, 03, 1), y: 50 },
    { x: new Date(2012, 04, 1), y: 65 },
    { x: new Date(2012, 05, 1), y: 95 }

    ]
  },
    {
    type: "stackedColumn",
    legendText: "Drinks",
    showInLegend: "true",
    dataPoints: [
    { x: new Date(2012, 01, 1), y: 71 },
    { x: new Date(2012, 02, 1), y: 55},
    { x: new Date(2012, 03, 1), y: 50 },
    { x: new Date(2012, 04, 1), y: 65 },
    { x: new Date(2012, 05, 1), y: 95 }

    ]
  },

    {
    type: "stackedColumn",
    legendText: "dessert",
    showInLegend: "true",
    dataPoints: [
    { x: new Date(2012, 01, 1), y: 61 },
    { x: new Date(2012, 02, 1), y: 75},
    { x: new Date(2012, 03, 1), y: 80 },
    { x: new Date(2012, 04, 1), y: 85 },
    { x: new Date(2012, 05, 1), y: 105 }

    ]
  },
    {
    type: "stackedColumn",
    legendText: "pick-ups",
    showInLegend: "true",
    dataPoints: [
    { x: new Date(2012, 01, 1), y: 20 },
    { x: new Date(2012, 02, 1), y: 35},
    { x: new Date(2012, 03, 1), y: 30 },
    { x: new Date(2012, 04, 1), y: 45 },
    { x: new Date(2012, 05, 1), y: 25 }

    ]
  }

  ]
});

It's throwing an error:

Octal literals are not allowed in strict mode.
Octal literals are not available when targeting ECMAScript 5 and higher. Use 
the syntax '0o5'.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In strict mode, octal literals & escape characters are not allowed. You can use one of the standard date-formats in your case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...