0

我有这样的日期数据,没有2017/07/17, 2017/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");

我使用这个 chartData 作为 dataProvider 来制作图表。

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/152017/07/16 2017/07/16是在 X 轴上绘制的,即使没有数据。

甚至.equalSpacing看起来都是徒劳的。

我怎样才能删除这个???

4

1 回答 1

1

您必须在股票图表中设置equalSpacing属性categoryAxesSettings才能使其工作。

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

演示

于 2017-08-17T11:30:30.870 回答