var data = {
labels: ["MON", "TUS", "WED", "THU", "FRI", "SAT","SUN"],
datasets: [{
// lineItemName: "test1",
fillColor: 'rgba(238,90,133,0.7)',
strokeColor: "rgb(238,90,133)",
pointColor: "#5b5956",
pointStrokeColor: "#a54d65",
data: [50, 38, 20, 40, 58, 50 ,40]
},
]
};
var chartLine = null;
window.onload = function() {
var ctx = document.getElementById("myChart").getContext("2d");
chartLine = new Chart(ctx).Line(data, {
scaleOverride: true, //是否用硬编码重写y轴网格线
scaleSteps: 3, //y轴刻度的个数
scaleStepWidth: 20, //y轴每个刻度的宽度
scaleStartValue: 0, //y轴的起始值
pointDot: true, //是否显示点
pointDotRadius: 3, //点的半径
pointDotStrokeWidth: 2, //点的线宽
datasetStrokeWidth: 1, //数据线的线宽
animation: true, //是否有动画效果
animationSteps: 60 ,//动画的步数
scaleLineWidth : 1,
// Y/X轴的颜色
scaleLineColor : '#686665',
scaleGridLineColor : "#686665",
scaleFontSize : 12,
scaleFontColor : "#fff",
});
}
=================================================================
问题就是,加了viewport那行,图表就不缩放了,始终是固定大小,不加那行,就是自适应大小。这怎么搞?也没有对canvas实际内容设置大小的地方。给myChart动态设置宽高也根本不管用,求解求解!