HighChart没有显示任何内容

时间:2016-02-17 15:37:25

标签: highcharts

任何人都可以告诉我这里做错了什么。因为我的图表显示了X值,但我的Y值没有在图表上绘制。

注意这个x:和y:的原因是因为我使用的是dotnet highchart helper。

chart: {    renderTo:'chart_0_container', backgroundColor: '#FFFFFF', className: 'chart1', defaultSeriesType: 'line', marginRight: 10, plotShadow: false, resetZoomButton: { position: { align: 'left' } }, zoomType: 'xy' }, 
    xAxis: { allowDecimals: false, type: 'linear' },
    yAxis: [{ labels: { formatter: function () {return Highcharts.numberFormat(this.value,2,'.' ,' ');} }, max: 0, title: { text: '' } }], 
    legend: { enabled: true },
    tooltip: { enabled: true, formatter: function() { return '<span style="color:' + this.series.color + ';">●</span> ' + this.series.name + ': <b>' + Highcharts.numberFormat(this.y,',','.') + '</b><br/>' + Highcharts.dateFormat(' %Y-%m-%d %H:%M (%A)' , new Date(this.x)); } },  
    title: { text: '' },  
    plotOptions: { line: { marker: { enabled: true } } }, 
    exporting: { enabled: true, filename: 'TrendExport' }, 
    series: [{ data: 
        [{ x: 49.898418, y: 21.32 }, 
        { x: 49.882478, y: 21.32 }, 
        { x: 51.759454, y: 21.57 }, 
        { x: 51.385514, y: 21.56 }, 
        { x: 50.678916, y: 21.47 }, 
        { x: 50.226594, y: 21.35 }, 
        { x: 49.956602, y: 21.25 }, 
        { x: 49.841858, y: 21.24 }, 
        { x: 49.865894, y: 21.28 }, 
        { x: 49.845258, y: 21.31 }, 
        { x: 49.797864, y: 21.21 }, 
        { x: 49.880792, y: 21.29 }, 
        { x: 50.863658, y: 21.31 }, 
        { x: 50.017988, y: 21.21 }, 
        { x: 49.98614, y: 21.21 }, 
        { x: 50.105496, y: 21.29 }, 
        { x: 49.712604, y: 21.19 }, 
        { x: 49.714074, y: 21.2 }, 
        { x: 49.756014, y: 21.19 }, 
        { x: 49.817874, y: 21.23 }, 
        { x: 49.798772, y: 21.21 }, 
        { x: 50.006356, y: 21.3 }, 
        { x: 50.06892, y: 21.32 }, 
        { x: 49.77289, y: 21.21 }, 
        { x: 49.700852, y: 21.2 }, 
        { x: 49.653704, y: 21.19 }, 
        { x: 49.736278, y: 21.21 }, 
        { x: 49.757966, y: 21.21 }, 
        { x: 49.7942, y: 21.22 }, 
        { x: 49.75787, y: 21.21 }], name: 'ABSA Capital Durban Incomer (kVAr)' }]

提前谢谢你。

2 个答案:

答案 0 :(得分:1)

yAxis中的最大值为:0。 修复此处:),检查jsfiddle

print ArbSynFinal.encode('utf-8')

答案 1 :(得分:1)

理想情况下,您应该从后端逻辑中获取排序数据并将其提供给您的图表。如果它不能按排序顺序执行以下操作: 将系列数据放入变量并使用以下方法对数据进行排序:

   var dataToSort = [{ x: 49.898418, y: 21.32 }, 
                     { x: 49.882478, y: 21.32 }, 
                     { x: 51.759454, y: 21.57 }, 
                     { x: 51.385514, y: 21.56 }, 
                     { x: 50.678916, y: 21.47 }, 
                     { x: 50.226594, y: 21.35 }, 
                      //  .......and so on

   dataToSort.sort(function(a, b) {
   return parseFloat(a.x) - parseFloat(b.x);
   });

同时删除工具提示中的日期格式化程序,看来你的数据在x字段中没有任何时间戳或UTC日期。

同样如@mekhatria所述,删除max:0

请参阅Working fiddle here