简体   繁体   English

高位图覆盖系列数据对象的X或Y轴键

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

In the examples in the highchart docs I see you can define your data like so: 在highchart文档的示例中,我看到您可以像这样定义数据:

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

But I have non standard keys like this: 但是我有这样的非标准密钥:

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

Surely there must be a way to use my custom keys rather than the standard "x" and "y", right? 当然,必须有一种使用我的自定义键的方法,而不是标准的“ x”和“ y”,对吗? Can anyone help? 有人可以帮忙吗?

You can update the data series like this 您可以像这样更新数据系列

 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