如何比较具有不同minPeriod值的数据集

时间:2017-01-06 18:46:47

标签: amcharts

我的主要数据集的minPeriod为一天,"DD"。 然后,我添加一个新数据集以与主数据集进行比较。这个新数据集的minPeriod为1分钟,"mm"

但是,即使将chart.categoryAxesSettings.minPeriod更改为等于mm,新数据集也不会显示。 但是当我使用也具有minPeriod='mm'的主数据集时,会出现新的比较数据集。

所以,我想知道如何使用带有minPeriod='DD'的主数据集,并将其与minPeriod='mm'的新数据集进行比较。

如果您需要更多信息,请与我们联系。 谢谢!找到下面的代码。

chart = new AmCharts.AmStockChart();

//this is my main dataset
//the data in it has a minPeriod of one day
dataSet = new AmCharts.DataSet();
dataSet.title = 'Price';
dataSet.dataProvider = chartData;
dataSet.fieldMappings = [{fromField:"Open", toField:"open"}, {fromField:"High", toField:"high"}, {fromField:"Low", toField:"low"}, {fromField:"Close", toField:"close"}, {fromField:"Volume", toField:"volume"}, {fromField:"orderPrice", toField:"orderPrice"}];
dataSet.categoryField = "date";
chart.dataSets = [dataSet];

categoryAxesSettings = new AmCharts.CategoryAxesSettings();
categoryAxesSettings.minPeriod = "DD";
categoryAxesSettings.maxSeries = 750;
chart.categoryAxesSettings = categoryAxesSettings;   

//main panel
pricePanel = new AmCharts.StockPanel();
pricePanel.recalculateToPercents = "never";

//create priceGraph
var priceGraph = new AmCharts.StockGraph();
priceGraph.valueField = "closeField";
priceGraph.type = "ohlc";
priceGraph.title = "Price";
priceGraph.openField = 'open';
priceGraph.highField = 'high';
priceGraph.lowField = 'low';
priceGraph.closeField = 'close';
pricePanel.addStockGraph(priceGraph); 

//display chart
chart.write("chartdiv");



//create new dataset where data has minPeriod = 'mm'
var orderDataset = new AmCharts.DataSet();
orderDataset.title = 'orderSet';
orderDataset.dataProvider = orderGraphData;
orderDataset.fieldMappings = [{fromField:"orderPrice", toField:"orderPrice"}];
orderDataset.categoryField = "date";
orderDataset.compared = true;
chart.dataSets.push(orderDataset);

//create priceGraph
var orderGraph = new AmCharts.StockGraph();
orderGraph.comparable = true;
orderGraph.compareField = 'orderPrice';
orderGraph.compareGraph = {
    "type": "step",
    "bullet": "round",
    "lineThickness": 2,
    "bulletBorderColor": "#FFFFFF",
    "bulletBorderAlpha": 1,
    "bulletBorderThickness": 3
};
pricePanel.addStockGraph(orderGraph);

//change minPeriod to mm
chart.categoryAxesSettings.minPeriod = "mm";

chart.validateData();

0 个答案:

没有答案