douqiaotong8682 2015-09-14 09:30
浏览 102

高图表条形图,如何在系列中显示日期?

I want to Develop a Bar Chart, where in X-axis there will be some data about Line Number. In my Chart i want to show date interval. Assume there will be a start date and an end date. I have done something like this:
1. My connection page (demo.php) is like that:

<?php
$con = mysql_connect("localhost","root","");

if (!$con) {
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("demo_planning", $con);

$query = mysql_query("SELECT alocate_line, sewing_end, sewing_start FROM demo_input");

$category = array();
$category['name'] = 'Line';

$series1 = array();
$series1['name'] = 'Sewing End';

$series2 = array();
$series2['name'] = 'Sewing Start';


while($r = mysql_fetch_array($query)) {
    $category['data'][] = $r['alocate_line'];
    $series1['data'][] = str_replace("-",",",$r['sewing_end']);
    $series2['data'][] = str_replace("-",",",$r['sewing_start']);

}

$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);



print json_encode($result, JSON_NUMERIC_CHECK);

mysql_close($con);
?>

My High chart page is like That:

<script type="text/javascript">
$(document).ready(function() {
    var options = {
        chart: {
            renderTo: 'container',
            type: 'bar',
            marginRight: 130,
            marginBottom: 25
        },
        title: {
            text: 'INPUT',
            x: -20 //center
        },
        subtitle: {
            text: '',
            x: -20
        },
        xAxis: {
            categories: []
        },
        yAxis: {
            title: {
                text: 'Requests'
            },
                plotLines: [{
                value: 0,
                width: 3,
                color: '#808080'
            }]
        },
        tooltip: {
            formatter: function() {
                    return '<b>'+ this.series.name +'</b><br/>'+
                    this.x +': '+ this.y;
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -10,
            y: 100,
            borderWidth: 0
        },
         plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                }
            }
        },
        series: []
    }

    $.getJSON("data_demo.php", function(json) {
                options.xAxis.categories = json[0]['data'];
                options.series[0] = json[1];
                options.series[1] = json[2];
     chart = new Highcharts.Chart(options);
    });
});
</script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 400px; height: 600px; margin: 0 auto"></div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答