簡體   English   中英

如何在jqchart的X軸上添加日期

[英]How to add date on X-axis in jqchart

  • 我的數據庫中有一些如下所述的日期,

    ['2017-09-18','2017-09-19','2017-09-22','2017-09-23','2017-09-24','2017-09-26']

需要將此添加到jqchart

              axes: [
                        {
                            type: 'dateTime',
                            location: 'bottom',
                            labels: {stringFormat: 'dd-mm-yyyy'},
                            minimum: new Date(<?php echo str_replace("-",",",substr(min($dtarray),0,-8)); ?>),
                            maximum: new Date(<?php echo str_replace("-",",",substr(max($dtarray),0,-8)); ?>),
                            title: { text: 'Days in month' }
                        },

我的代碼是這樣的,但是我需要添加日期而不是最小值和最大值,因為在檢查時缺少某些日期。

  • 這是我的 jqchart屏幕截圖

這里有兩個X軸,我只需要一個約會。 請幫忙

我們可以連續添加日期,

 $(document).ready(function () { $('#jqChart').jqChart({ title: { text: 'Efficiency' }, animation: { duration: 1 }, shadows: { enabled: true }, axes: [ { type: 'category', location: 'bottom', title: { text: 'Days in month' }, categories: [<?php echo $dateData; ?>], zoomEnabled: true, }, { type: 'linear', name: 'y1', location: 'left', title: { text: 'Working hours' }, labels: { stringFormat: '%d' }, minimum:0, maximum:15, interval:1 }, { type: 'category', name: 'y2', location: 'right', strokeStyle: '#FCB441', majorGridLines: { strokeStyle: '#FCB441' }, majorTickMarks: { strokeStyle: '#FCB441' }, title: { text: 'LUF/Efficiency' }, labels: { stringFormat: '%.1f' }, minimum:0, maximum:5 } ], series: [ { type: 'stackedColumn', axisY: 'y1', title: 'Effective time', fillStyle: 'green', data: [<?php echo $dat1; ?>], labels: { font: '12px sans-serif' } }, { type: 'stackedColumn', axisY: 'y1', title: 'Idle time', fillStyle: 'red', data: [<?php echo $dat3; ?>], labels: { font: '12px sans-serif' } } ] }); }); 
 <?php $dat1=""; $dat2=""; $obj->AssetStatbyTeam($frmdt,$todt,$empcode); $res = $obj->execute(); while($row1=mysql_fetch_array($res)) { if($i==1) { $dat1=$dat1.sec_to_time($row1['wrk_time']); $dat2=$dat2.sec_to_time($row1['idle_time']); } else { $dat1=$dat1.",".sec_to_time($row1['wrk_time']); $dat2=$dat2.",".sec_to_time($row1['idle_time']); } $i++; } ?> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM