Tho*_*ian 23 javascript jquery chart.js
我Chart.js用来生成地图并在很大程度上对其进行了定制.但无论如何我都无法移除垂直网格线.有人遇到过这样的情况吗?非常感谢.
JavaScript的
var ChartDataHome = {
labels: ["",
"NOV", "DEC", "JAN", "FEB",
],
datasets: [{
strokeColor: "rgba(255.255,255,1)",
pointColor: "rgba(159,209,154,1)",
pointStrokeColor: "rgba(255,255,255,1.00)",
data: [4.5, 8.8, 7.5, 9.5, 7.8, 9]
}, ]
};
var step = 2;
var max = 10;
var start = 0;
ChartOptionsHome = {
scaleLabel: "<%= value + ' K ' %>",
pointDot: false,
bezierCurve: false,
scaleOverride: true,
scaleSteps: 10,
// scaleStepWidth: Math.ceil(4/2),
scaleSteps: Math.ceil((max - start) / step),
scaleStepWidth: step,
scaleStartValue: start,
scaleShowGridLines: true,
scaleGridLineWidth: 0,
scaleGridLineColor: "rgba(0,0,0,0.1)",
datasetFill: false,
animation: true,
animationSteps: 60,
scaleFontColor: "#ffffff",
scaleFontSize: 14,
scaleLineColor: "rgba(255,255,255,1)",
datasetStrokeWidth: 6,
responsive: true,
}
ChartOptions = {
}
if ($("#chartHome")[0]) {
DrawTheChart(ChartDataHome, ChartOptionsHome, "chartHome", "Line");
}
Run Code Online (Sandbox Code Playgroud)
xna*_*kos 71
以下内容适用于Chart.js 2.*.
如果只有一个x轴,则是否显示垂直网格线(与此x轴相关)是否由布尔值指定options.scales.xAxes[0].gridLines.display.更准确地说,以下图表选项禁用单个x轴情况的垂直网格线的显示.
options : {
scales : {
xAxes : [ {
gridLines : {
display : false
}
} ]
}
}
Run Code Online (Sandbox Code Playgroud)
JBM*_*ure 19
两天前,新版本的Chart.js发布了一个新的全局选项.
var options = {
scaleShowVerticalLines: false
}
Run Code Online (Sandbox Code Playgroud)
小智 16
上面的答案似乎已经过时了,因为它们对我来说在 ChartJs 3.4.1(也可能是较低版本)中不起作用。
您现在可以使用以下内容:
options: {
scales: {
x: {
grid: {
display: false
}
},
}
}
Run Code Online (Sandbox Code Playgroud)
这是不言自明的,但要删除水平线,您可以将 x 替换为 y。
options : {
scales: {
yAxes: [{
gridLines: {
lineWidth: 0,
color: "rgba(255,255,255,0)"
}
}]
}
};
Charts.js v2.0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25389 次 |
| 最近记录: |