只要我的日期超过one year
,amcharts
就不会显示图表。我认为(也许)原因是format
中的CategoryAxis
日期只有Month
,如果有一年以上,那就没有意义了,我试着改变它,但它不起作用,所以如何解决它,这是我的代码:
(数据是输入的,实际上我不知道fromDate
和toDate
的实用程序是什么
<script type="text/javascript">
var mask = '<div class="k-loading-mask" style="width: 100%; height: 100%; top: 0px; left: 0px;"><span class="k-loading-text" style="text-indent: 0; width:60%; top: 40%; left: 20%; background-color: #0F0;">Please wait while the Back Test results are being generated. <br />This could take up to 30 seconds.</span><div class="k-loading-image" style="display:none;"></div><div class="k-loading-color"></div></div>';
var fromDate = new Date(2016, 2, 1, 0, 0, 0, 0);
var toDate = new Date(2016, 2, 31, 0, 0, 0, 0);
AmCharts.ready(function () {
drawStockChartData();
});
function drawStockChartData() {
$.ajax({
url: "/Home/TestAmStockChartData",
type: "POST",
dataType: "json",
success: function (result) {
for (var i = 0 ; i < result.length; i++) {
result[i].Date = new Date(parseInt(result[i].Date.slice(6, 19)));
}
createStockChart(result);
},
});
}
function createStockChart(data) {
var chart = new AmCharts.AmStockChart();
// DATASETS
var dataSet1 = new AmCharts.DataSet();
dataSet1.color = "#b0de09";
dataSet1.fieldMappings = [{
fromField: "NAV",
toField: "NAV"
},
{
fromField: "PNL",
toField: "PNL"
}];
dataSet1.dataProvider = data;
dataSet1.categoryField = "Date";
chart.dataSets = [dataSet1];
// PANELS
var stockPanel1 = new AmCharts.StockPanel();
stockPanel1.showCategoryAxis = true;
stockPanel1.title = "NAV";
stockPanel1.percentHeight = 100;
stockPanel1.eraseAll = false;
//stockPanel.addLabel(0, 100, "Click on the pencil icon on top-right to start drawing", "center", 16);
var graph1 = new AmCharts.StockGraph();
graph1.title = "NAV";
graph1.valueField = "NAV";
graph1.bullet = "round";
graph1.bulletColor = "#FFFFFF";
graph1.bulletBorderColor = "#00BBCC";
graph1.bulletBorderAlpha = 1;
graph1.bulletBorderThickness = 2;
graph1.bulletSize = 7;
graph1.lineThickness = 2;
graph1.lineColor = "#00BBCC";
graph1.useDataSetColors = false;
graph1.comparable = true;
graph1.compareField = "HSI";
stockPanel1.addStockGraph(graph1);
var stockLegend1 = new AmCharts.StockLegend();
stockLegend1.valueTextRegular = " ";
stockLegend1.markerType = "none";
stockPanel1.stockLegend = stockLegend1;
stockPanel1.drawingIconsEnabled = true;
chart.panels = [stockPanel1];
// OTHER SETTINGS
var scrollbarSettings = new AmCharts.ChartScrollbarSettings();
scrollbarSettings.graph = graph1;
scrollbarSettings.updateOnReleaseOnly = false;
chart.chartScrollbarSettings = scrollbarSettings;
var cursorSettings = new AmCharts.ChartCursorSettings();
cursorSettings.valueBalloonsEnabled = true;
chart.chartCursorSettings = cursorSettings;
var panelsSettings = new AmCharts.PanelsSettings();
panelsSettings.creditsPosition = "bottom-right";
//panelsSettings.creditsPosition = null;
panelsSettings.marginRight = 16;
panelsSettings.marginLeft = 16;
chart.panelsSettings = panelsSettings;
// PERIOD SELECTOR
var periodSelector = new AmCharts.PeriodSelector();
periodSelector.position = "bottom";
periodSelector.periods = [{
period: "DD",
count: 10,
label: "10 days"
}, {
period: "MM",
count: 1,
label: "1 month"
}, {
period: "YYYY",
count: 1,
label: "1 year"
}, {
period: "YTD",
label: "YTD"
}, {
period: "MAX",
label: "MAX"
}];
chart.periodSelector = periodSelector;
chart.write('divPnlAmChart');
};
</script>
我测试breakpoint
无法进入
function createStockChart(data) {
var chart = new AmCharts.AmStockChart();
,如果data
还有更多内容,则无法显示1 year