2016-07-15 40 views
0

我使用Highstockchart在圖表上繪製4個系列,主要是燭臺,然後我有2個系列繪製priceplus,pricelower價格,然後另一個來表示體積。 我有自pricelower/priceplus的提示一個問題,顯示的時間爲UNIX日期時間,而不是在人redeable形式(你可以在這個截圖中看到)定製工具提示離開蠟燭棒,因爲它是

enter image description here

我想這不會進行修改

enter image description here

我怎樣才能做到這一點? 感謝

這裏是我的JS代碼

function onSuccess(data) { 
    var r = JSON.stringify(data); 
    debugger; 
    kendo.ui.progress($('#container'), false); 
    $('#container') 
     .highcharts('StockChart', 
     { 
      exporting: { 
       enabled: false 
      }, 
      credits: 
      { 
       enabled: false 
      }, 
      rangeSelector: { 
       selected: 1, 
       inputEnabled:false, 
       buttonTheme: { 
        visibility: 'hidden' 
       }, 
       labelStyle: { 
        visibility: 'hidden' 
       } 
      }, 
      yAxis: [ 
       { 
        height: '80%', 
        lineWidth: 2 
       }, { 
        top: '85%', 
        height: '15%', 
        offset: 0, 
        lineWidth: 2 
       } 
      ], 
      xAxis: 
      { 
       ordinal: true 
      } 
     , 
      series: [ 
       { 
        type: 'candlestick', 
        name: 'Price', 
        data: data.Prices, 
        id: 'dataseries', 
        upColor: "#31D431", 
        color: "#D22F2F", 
        marker:{ 
         enabled: true 
        } 
       }, 
       { 
        type: 'scatter', 
        name: 'Prices plus', 
        data: data.PricesPlus 

       }, 

      { 
       type: 'scatter', 
       name: 'Price less', 
       data: data.PricesLess 

      } 
       , { 
        type: 'column', 
        name: 'Volume', 
        data: data.Volume, 
        yAxis: 1, 
        dataGrouping: { 
         units: groupingUnits 
        } 
       } 
      ], 
      width: 4, 
      tooltip: { 
     shared: false 

} 

     }); 
} 

回答

2

您應該使用tooltip.formatter,然後創建彈出的內容。每個值都可以從點參考中提取。

tooltip:{ 
    formatter: function() { 
     var points = this.point ? Highcharts.splat(this.point) : this.points, 
      point = points[0], 
      each = Highcharts.each, 
      txt = ''; 

     txt += '<span style="font-size: 10px">' + Highcharts.dateFormat('%A, %b, %H:%M', point.x) + '</span><br/>'; 

     each(points, function(p, i) { 

     if(p.point && p.point.open) { 
      txt += '<span style="color:' + p.color + '">\u25CF</span><b> ' + p.series.name + '</b>:<br/>Open: ' + p.point.open + '<br/>High: ' + p.point.high + '<br/>Low: ' + p.point.low + '<br/>Close: ' + p.point.close + '<br/>'; 
     } else { 
      txt += '<span style="color:' + p.color + '">\u25CF</span> ' + p.series.name + ': <b>' + p.y + '</b><br/>'; 
     } 
     }); 

     return txt; 
    } 
    }, 

例子: - http://jsfiddle.net/abpbyx8z/

+0

原諒我,我添加了一個標記系列在此集合,但它並沒有顯示我的文字,它說不確定......我怎麼在這個hadle格式化程序? – advapi

+0

你增加了額外的系列?你能用你的代碼更新我的jsfiddle嗎? –

相關問題