簡體   English   中英

高位圖覆蓋系列數據對象的X或Y軸鍵

[英]Highcharts overriding X or Y axis key for series data objects

在highchart文檔的示例中,我看到您可以像這樣定義數據:

[{ x: 100, y: 3}, { x: 105, y: 4} ...]

但是我有這樣的非標准密鑰:

[{ myCustomXKey: 100, myCustomYKey: 3}, { myCustomXKey: 105, myCustomYKey: 4} ...]

當然,必須有一種使用我的自定義鍵的方法,而不是標准的“ x”和“ y”,對嗎? 有人可以幫忙嗎?

您可以像這樣更新數據系列

 var dataServer = [{ myCustomXKey: 100, myCustomYKey: 3, myCustomZKey: 4 }, { myCustomXKey: 105, myCustomYKey: 4, myCustomZKey: 5 }, { myCustomXKey: 110, myCustomYKey: 5, myCustomZKey: 6 }, { myCustomXKey: 120, myCustomYKey: 6, myCustomZKey: 7 }] function initialize(dataServer) { //suppose you need x,y,z data var dataH = [];//creating array for chart for (var i = 0; i < dataServer.length; i++) { /*pushing objects into array*/ dataH.push({ x: dataServer[i].myCustomXKey, y: dataServer[i].myCustomYKey, z: dataServer[i].myCustomZKey }) } Highcharts.chart('container', { chart: { type: 'bubble', plotBorderWidth: 1, zoomType: 'xy' }, title: { text: 'update chart data from server data' }, series: [{ data: dataH //add the variable here }] }); } initialize(dataServer) 
 <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/highcharts-more.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="height: 400px; min-width: 310px; max-width: 600px; margin: 0 auto"></div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM