我正在使用CanvasJS按周创建堆积的条形图。我们的周从周六开始,但是CanvasJS似乎默认为从周日开始的周。因此,此图表的标签从11/3开始,而不是我需要的11/2。
[我在CanvasJS论坛上发现了this帖子,它提示设置最小值和最大值可能会有所帮助,但是当我尝试这样做时,它只是改变了绘图区域(如您所愿),但是标签仍然反映了星期日,而不是星期六
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Evening Sales of a Restaurant"
},
axisX: {
intervalType: "week",
interval: 1
},
data: [
{
type: "stackedBar",
dataPoints: [
{ x: new Date("11/2/2019"), y: 71 },
{ x: new Date("11/9/2019"), y: 55},
{ x: new Date("11/16/2019"), y: 50 },
{ x: new Date("11/23/2019"), y: 65 },
{ x: new Date("11/30/2019"), y: 95 }
]
},
{
type: "stackedBar",
dataPoints: [
{ x: new Date("11/2/2019"), y: 20 },
{ x: new Date("11/9/2019"), y: 35},
{ x: new Date("11/16/2019"), y: 30 },
{ x: new Date("11/23/2019"), y: 45 },
{ x: new Date("11/30/2019"), y: 25 }
]
}
]
});
chart.render();
}
</script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script></head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;">
</div>
</body>
</html>
从CanvasJS:
到目前为止,无法控制标签的起点。我们将在以后的版本中重新考虑此行为。
https://canvasjs.com/forums/topic/how-to-label-axisx-by-week-starting-on-saturday/