如何知道新版本的js文件中的更改功能?

时间:2017-05-24 07:18:05

标签: javascript

在我的项目中,我使用ChartJS生成不同类型的图表,例如折线图,饼图,圆环图等,之前我使用的是1.0.2版本的js文件,它工作正常,但现在我改变了它到2.3.0。改变后我得到Error while evaluating javascript input: TypeError: (intermediate value).Line is not a function

如何解决这个问题?

1.0.2 mo代码

var lineChartData = {   
labels: ["Data 1", "Data 2", "Data 3", "Data 4", "Data 5", "Data 6", "Data 7"],
datasets: [{
    fillColor: "rgba(220,220,220,0)",
    strokeColor: "rgba(220,180,0,1)",
    pointColor: "rgba(220,180,0,1)",
    data: [20, 30, 80, 20, 40, 10, 60]
}, {
    fillColor: "rgba(151,187,205,0)",
    strokeColor: "rgba(151,187,205,1)",
    pointColor: "rgba(151,187,205,1)",
    data: [60, 10, 40, 30, 80, 30, 20]
}]

}

Chart.defaults.global.animationSteps = 50;
Chart.defaults.global.tooltipYPadding = 16;
Chart.defaults.global.tooltipCornerRadius = 0;
Chart.defaults.global.tooltipTitleFontStyle = "normal";
Chart.defaults.global.tooltipFillColor = "rgba(0,160,0,0.8)";
Chart.defaults.global.animationEasing = "easeOutBounce";
Chart.defaults.global.responsive = true;
Chart.defaults.global.scaleLineColor = "black";
Chart.defaults.global.scaleFontSize = 16;

var ctx = document.getElementById("canvas").getContext("2d");
var LineChartDemo = new Chart(ctx).Line(lineChartData, {
  pointDotRadius: 10,
  bezierCurve: false,
  scaleShowVerticalLines: false,
  scaleGridLineColor: "black"
});

1 个答案:

答案 0 :(得分:0)

切换到任何软件包的新主要版本或多或少guaranteed to break。您必须手动修补所有代码。

Chart.js似乎没有升级指南,因此建议手动执行:http://www.chartjs.org/docs/#notes-previous-versions。当然,每个项目的过程都不同。