【问题标题】:Angular + Canvasjs: Octal literals are not allowed in strict modeAngular + Canvasjs:严格模式下不允许使用八进制文字
【发布时间】:2021-03-31 11:54:43
【问题描述】:

我正在使用 Angular、Node/Express 和 MySQL 进行全栈开发。我正在尝试在我的角度应用程序中添加一个图表,该图表将根据我的数据库中可用的数据显示。我已经下载了canvasjs 网站上的示例代码。在根据我的需要修改它之前,我尝试运行示例代码并且它抛出了一个错误。

代码如下:

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 }

    ]
  }

  ]
});

它抛出一个错误:

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

【问题讨论】:

    标签: angular canvas angular-fullstack


    【解决方案1】:

    在严格模式下,octal literals & escape characters are not allowed。您可以在您的情况下使用standard date-formats 之一。

    【讨论】:

      猜你喜欢
      • 2016-08-21
      • 2021-08-18
      • 1970-01-01
      • 2014-06-29
      • 2018-11-11
      • 1970-01-01
      • 1970-01-01
      • 2021-08-29
      • 2016-03-25
      相关资源
      最近更新 更多