doxqszx09742 2013-12-04 06:23
浏览 130
已采纳

Highcharts动态集类别更新图表但仅显示点但不显示线

I have Highchart LINE type graph which show line graph correctly.I have button to change the data dynamically.i.e. First chart renders 7 days data.On click of 14 days chart renders data correctly but the when i use.

function requestData(response,point){
...data fetching code......
var series = chart.series[0];
chart.series[1].setData(eval(oneArray),false,true);
chart.series[0].setData(eval(twoArray),false,true);
chart.xAxis[0].setCategories(json array, true,true);}

if i remove the chart.xAxis[0].setCategories(json array, true,true); then it show the lines with correct data but x-axis is only numbers,I have to set x-axis with days name.The json array show all correct. Here is my chart code.

                   var chart;
                   chart = new Highcharts.Chart({
                   chart: {
                       renderTo: "progresschart",
                       type: "line",
                       events: {
                           load: requestData   
                       }
                   },
                   credits: {
                           enabled: false
                       },
                   title: {
                       text: "Calories Burned Vs Calorie Consumed"
                   },
                    xAxis: {

                           categories: [],
                           },

                   yAxis: {
                       title: {
                           text: "Calories"
                       },
                   },
                   series: [{
                       name: "Consumed",
                        data:[] 
                   },{
                       name: "Burned",
                        data:[] 
                   }],
                   exporting: {
                                enabled: false
                            }
              });
        });

First the category array is:

["Thu,28th", "Fri,29th", "Sat,30th", "Sun,1st", "Mon,2nd", "Tue,3rd", "Wed,4th"]

categories array to be set is:

["Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"]

Series[1]:

[403.91604166667, 0, 0, 156.421875, 190.48708333333, 121.66145833333, 52.140625, 104.28125, 440.41447916667, 472.04645833334, 0, 178.3209375, 191.18229166666, 139.04166666667]

Series[2]:

[100, 112, 0, 0, 360, 330, 141, 150, 100, 0, 0, 0, 0, 0]
  • 写回答

1条回答 默认 最新

  • duanchuanqu593743 2013-12-05 14:31
    关注

    It's probably bug in old version of Highcharts, updating to 3.0.7+ should resolve that issue.

    Working example: http://jsfiddle.net/24dXX/

    Code:

        var arr = ["Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"],
            oneArray = "[403.91604166667, 0, 0, 156.421875, 190.48708333333, 121.66145833333, 52.140625, 104.28125, 440.41447916667, 472.04645833334, 0, 178.3209375, 191.18229166666, 139.04166666667]",
            twoArray = "[100, 112, 0, 0, 360, 330, 141, 150, 100, 0, 0, 0, 0, 0]";
    
        chart.series[1].setData(eval(oneArray), false, true);
        chart.series[0].setData(eval(twoArray), false, true);
        chart.xAxis[0].setCategories(arr, true, true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛