如何将数组[0]之类的数组元素调用为highcharts数据 [英] How to call array elements like array[0] into data of highcharts

查看:70
本文介绍了如何将数组[0]之类的数组元素调用为highcharts数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在html页面中调用highcharts(barcharts)。

我如何打电话。



这里我没有得到条形图当我们给出1,2,3这样的静态数字时,图表即将到来。

当我们传递数组值时,来自控制器的动态数据然后图表没有得到。



我尝试过:



i want to call highcharts(barcharts) in html pages.
how do i call.

here i am not getting barchart.when we give static number like 1,2,3 then chart is coming.
when we pass array values which r comming from controller dynamicaly then chart is not getting.

What I have tried:

tbuff = ["20","40","20"];
var series = [{
        name: 'PhaseVolatges&Currents',
        data: [50]
    }, {
        name: 'DC Bus Voltage',
        data: [tbuff[1]]
    }, {
        name: 'LoadCurrent',
        data: [tbuff[2]]
    }, {
        name: 'BatteryCurrent',
        data: [tbuff[3]]
    }, {
        name: 'DC RectifierO/PCurrent',
        data: [tbuff[4]]"
    }
];

推荐答案

我想问题是,你传递的是字符串数据而不是整数。请尝试以下方法。



Hi, I guess the problem is, you are passing string data rather than integer. Please try the following.

tbuff=["20","40","20"];

var series= [
    {
        name: 'PhaseVolatges&Currents',
        data: [50]
    }, {
        name: 'DC Bus Voltage',
        data: [parseInt(tbuff[1])]
    }, {
        name: 'LoadCurrent',
        data: [parseInt(tbuff[2])]
    }, {
        name: 'BatteryCurrent',
        data: [parseInt(tbuff[3])]
    }, {
        name: 'DC RectifierO/PCurrent',
        data: [parseInt(tbuff[4])]"
    }
]; 





注意:将数据输入转换为Integer以显示聊天。



我希望这会对你有所帮助。如果您在更改后仍然面临同样的问题,请告诉我。



Note: Convert the data input into Integer for showing the chat.

I hope this will help you. Please let me know if you are still facing the same issue after the changes.


这篇关于如何将数组[0]之类的数组元素调用为highcharts数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆