gpt4 book ai didi

javascript - 通过 amchart 从 X 轴删除银行假日

转载 作者:行者123 更新时间:2023-12-03 03:38:46 25 4
gpt4 key购买 nike

我有这样的日期数据,没有 2017/07/172017/07/162017/07/15因为它们是银行假日。

chartData = new Array();
chartData[0] = new Array();
chartData[0].closePrice = 1207;
chartData[0].date = new Date("2017/07/12");
chartData[1] = new Array();
chartData[1].closePrice = 1227;
chartData[1].date = new Date("2017/07/13");
chartData[2] = new Array();
chartData[2].closePrice = 1216;
chartData[2].date = new Date("2017/07/14");
chartData[3] = new Array();
chartData[3].closePrice = 1234;
chartData[3].date = new Date("2017/07/18");

我使用这个图表数据作为数据提供者来制作图表。

var dataSet = new AmCharts.DataSet();
dataSet.dataProvider = chartData;
dataSet.categoryField = "date";

chart.dataSets = [dataSet];


var stockPanel = new AmCharts.StockPanel();
stockPanel.title = "Stock Main";
stockPanel.id = "stockPanel";
stockPanel.showCategoryAxis = false;
stockPanel.recalculateToPercents = "never";

var valueAxis = new AmCharts.ValueAxis();
valueAxis.dashLength = 5;
stockPanel.addValueAxis(valueAxis);
stockPanel.categoryAxis.dashLength = 5;
stockPanel.categoryAxis.equalSpacing = true; // it doesn't work ....

var graph = new AmCharts.StockGraph();
graph.type = "line";
graph.valueField = "closePrice";
stockPanel.addStockGraph(graph);

但是 2017/07/15,2017/07/16 2017/07/16 绘制在 X 轴上,即使有没有数据。

即使 .equalSpacing 看起来也是徒劳的。

如何删除这个???

最佳答案

您必须在categoryAxesSettings中设置equalSpacing股票图表中的属性使其发挥作用。

//object-based setup
chart.categoryAxesSettings = new AmCharts.CategoryAxesSettings();
chart.categoryAxesSettings.equalSpacing = true;
//makeChart version
AmCharts.makeChart("chartdiv", {
// ...
"categoryAxesSettings": {
"equalSpacing": true
},
// ...
});

Demo

关于javascript - 通过 amchart 从 X 轴删除银行假日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45726968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com