0
  • 我的数据库中有如下提到的一些日期,

    ['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 轴,我只需要一个有日期。请帮忙

4

1 回答 1

0

我们可以在系列中添加日期,

$(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++;
}
?>

于 2018-05-25T06:39:34.473 回答