Angular + Canvasjs:严格模式下不允许使用八进制文字
Angular + Canvasjs: Octal literals are not allowed in strict mode
我正在从事全栈开发并使用 Angular、Node/Express 和 MySQL。我正在尝试在我的 angular 应用程序中添加一个图表,该图表将根据我的数据库中可用的数据显示。我已经在 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'.
在严格模式下,octal literals & escape characters are not allowed. You can use one of the standard date-formats 你的情况。
我正在从事全栈开发并使用 Angular、Node/Express 和 MySQL。我正在尝试在我的 angular 应用程序中添加一个图表,该图表将根据我的数据库中可用的数据显示。我已经在 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'.
在严格模式下,octal literals & escape characters are not allowed. You can use one of the standard date-formats 你的情况。