Amcharts的stockchart:javascript中的行太简单了,而不是旧的flash版本

时间:2015-10-22 09:23:37

标签: javascript amcharts

我必须将flash版本中的旧amcharts的库存表更新为javascript版本。我做到了,但结果对我的客户来说太不一样了。

Flash版本: The old graph

新的javascript版本: The new graph

正如您所看到的,与旧版本相比,新版本的图表线条过于简单,但没有足够的细节。

这是新图的代码:

var chart = new AmCharts.AmStockChart();
chart.dataSets = dataSets;

var stockPanel = new AmCharts.StockPanel();
stockPanel.showCategoryAxis = true;
stockPanel.numberFormatter = {precision:2, decimalSeparator:',', thousandsSeparator:' '};
stockPanel.percentFormatter = {precision:2, decimalSeparator:',', thousandsSeparator:' '};


var graph = new AmCharts.StockGraph();
graph.valueField = 'value';
graph.openField = 'open';

graph.closeField = 'close';
graph.comparable = true;
graph.type = 'line';
graph.minDistance = 0;
graph.noStepRisers = true;
graph.clustered = false;

stockPanel.addStockGraph(graph);

var stockLegend = new AmCharts.StockLegend();
stockLegend.markerType = 'bubble';
stockLegend.markerSize = 8;
stockLegend.periodValueText = '[[value.close]]';
stockLegend.valueTextComparing = '[[value]] | [[percents.value]]%';
stockLegend.periodValueTextComparing = '[[value.close]] | [[percents.value.close]]%';
stockLegend.horizontalGap = 1;
stockLegend.spacing = 100;

stockPanel.stockLegend = stockLegend;


chart.panels = [ stockPanel ];

var categoryAxesSettings = new AmCharts.CategoryAxesSettings();

chart.categoryAxesSettings  = categoryAxesSettings;


var scrollbarSettings = new AmCharts.ChartScrollbarSettings();
scrollbarSettings.color = '#000';
scrollbarSettings.gridColor = '#fff';
scrollbarSettings.backgroundColor = '#fff';
scrollbarSettings.gridColor = '#fff';
scrollbarSettings.graphFillColor = '#F5F5F5'; //jsonData.funds.color;
scrollbarSettings.selectedGraphFillColor = '#CCDDE9';
scrollbarSettings.selectedBackgroundColor = '#fff'
scrollbarSettings.graph = graph;
scrollbarSettings.graphType = 'line';
scrollbarSettings.usePeriod = "MM";


chart.chartScrollbarSettings = scrollbarSettings;

var periodSelector = new AmCharts.PeriodSelector();
periodSelector.position = 'top';
periodSelector.fromText = '';
periodSelector.toText = ' - ';
periodSelector.periodsText = '';
periodSelector.dateFormat = 'DD/MM/YYYY';
periodSelector.periods = [
    { period: 'MM', count: 1, label: '1M' },
    { period: 'MM', count: 3, label: '3M' },
    { period: 'YYYY', count: 1, label: '1Y' },
    { period: 'YYYY', count: 3, label: '3Y' },
    { period: 'YYYY', count: 5, label: '5Y' },
    { period: 'YTD', label: 'YTD' },
    { period: 'MAX', label: 'MAX' }
];
chart.periodSelector = periodSelector;

chart.write('fund_historic');

我必须添加或更改哪个参数? 感谢

1 个答案:

答案 0 :(得分:1)

好的,我找到了。 当我比较闪存设置文件时,我看到max_series参数固定为300,是javascript版本默认值的两倍。

所以这就是解决方案:

var categoryAxesSettings = new AmCharts.CategoryAxesSettings();
categoryAxesSettings.maxSeries = 300;
chart.categoryAxesSettings  = categoryAxesSettings;