Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abnitchauhan opened this issue Mar 19, 2019 · 6 comments
Open

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

abnitchauhan opened this issue Mar 19, 2019 · 6 comments

Comments

@abnitchauhan
Copy link

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
Copy link

Hello,

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

@abnitchauhan
Copy link
Author

abnitchauhan commented Mar 19, 2019

Hi there
Here is my php code ,
<?php $query = "SELECT tots.*, @var := @var + tots.countFROM ( SELECT YEAR(created_at) ASyear, MONTHNAME(created_at) AS month, COUNT(*) AS count`
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 :
'<script>
Morris.Line({
element: 'chart',
// json_encode returns JSON representation of a value
data: ,
xkey: ['label'],
ykeys: ['value'],
// Set to false to skip time/date parsing for X values, instead treating them as an equally-spaced
series.
parseTime:false,
labels: ['Number graph example'],
resize: true
});
</script> '

The data I am fetching is this
data

@pierresh
Copy link

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
Copy link
Author

abnitchauhan commented Mar 19, 2019

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
Copy link

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

@xie3120
Copy link

xie3120 commented Apr 19, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants