morrisjs / morris.js

Pretty time-series line graphs
http://morrisjs.github.com/morris.js/
6.92k stars 1.23k forks source link

First and last xlabels are not showing on the Line Chart . #779

Open abnitchauhan opened 5 years ago

abnitchauhan commented 5 years ago

I have created A morris Line chart By fetching data from the MySQL Table . The problem I am getting is that Its not showing the first and last label of the x-axis.

Here is the Image : datewise

pierresh commented 5 years ago

Hello,

Please give your code, including the dataset, so that we could reproduce your problem

abnitchauhan commented 5 years ago

Hi there Here is my php code , <?php $query = "SELECT tots.*, @var := @var + tots.count FROM ( SELECT YEAR(created_at) ASyear, MONTHNAME(created_at) ASmonth, COUNT(*) AScount` FROM users GROUP BY month ORDER BY year DESC ) AS tots, (SELECT @var := 0) AS inc" ;

$result = mysqli_query($conn, $query) ;

 $json_data=array();  
  foreach($result as $rec)  
  { 
  // value on x axis 
  $json_array['label']=$rec['month']."/".$rec['year'];  
  // value on y axis 
  $json_array['value']=$rec['count'];  
  array_push($json_data,$json_array);
  } 
 //$chart_data = substr($chart_data, 0, -2) ;
 ?>`

And Here is my javascript Code :
' '

The data I am fetching is this data

pierresh commented 5 years ago

It would be great you provide directly the dataset in javascript, I mean the content of JSON... So I just need to copy / paste... I do not need the PHP / MySQL..

abnitchauhan commented 5 years ago

Ofcourse . Here is the JSON

{"label":"February 2019","value":"4"}{"label":"January 2019","value":"6"}{"label":"March 2019","value":"5"}{"label":"December 2018","value":"2"}{"label":"November 2018","value":"3"}{"label":"October 2018","value":"2"}

pierresh commented 5 years ago

Seems the label are too long. You can try with shorter label, like Jan-19 instead of January 2019.

xie3120 commented 5 years ago

The x-axis of my chart shows the phone number ,like 082111111750,last lable is not showing,i can not fix it