doucongmishang2385 2016-11-12 08:22
浏览 38

Highcharts为每个选择框选择添加系列

I'm using Highcharts with MySQL and PHP... I have a Selectbox (Multiple Selections allowed) which contains company sections. What I'm trying to do is create a new chart series for every selection the user chooses.

Example: If I choose from selectbox "option1,option2,option3" ... the chart will have 3 series for these 3 selected options. However, If I chose only option1, the chart will have only 1 series.

My code so far:

<script type="text/javascript">
$(function () {
$('#container').highcharts({
    title: {
        text: 'Daily Volume of Calls',
        x: -20 //center
    },

    xAxis: {
           type: 'datetime'
    },
       plotOptions: {
        series: {
            pointStart: Date.UTC(<?php echo $datefixed; ?>),
            pointInterval: 24 * 3600 * 1000 // one day
        }
    },
    yAxis: {
        title: {
            text: 'Total Calls'
        },
        plotLines: [{
            value: 0,
            width: 1,
            color: '#808080'
        }]
    },
    tooltip: {
        valueSuffix: ' Calls'
    },
    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle',
        borderWidth: 0
    },
    series: [{
        name: <?php echo $firstselection ?>,

        data: [<?php echo join($callsarray, ',') ?>]
    }, {
        name: <?php echo $secondselection ?>, //**<<< THE PROBLEM IS HERE**  
        showInLegend: true, 
        data: []
    }]
});

The problem on my code is if the variable $secondselection is empty or not set(meaning the user didn't chose more than 1 option), the chart will return a blank page even if $firstselection variable is set. But if the user chooses a second option, it will show fine.

Any help guys? :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题