0
  • I have some dates as below mentioned from my database,

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

Need to add this into 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' }
                        },

My code goes like this , but i need to add dates instead of min & max value, because some dates are missing while checking.

  • This is my jqchart screenshot

Here two X-axis is coming i need only one having date. Please help

sherin.k
  • 63
  • 10

1 Answers1

0

We can add date in series,

$(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++;
}
?>
sherin.k
  • 63
  • 10