Sign in to follow this  
yhsantosa

x-axis scale

Recommended Posts

I have daily data, and i want to show 1 year data in a narrow x-axis.

 

how can i set the scale of x-axis?

 

i.e: monthly (1 jan, 1 feb, 1 mar, ....., 1 des)

 

but i want those daily data still appear on the 2d line chart.

 

 

 

please help me.

 

 

 

regards,

 

YH Santosa

Share this post


Link to post
Share on other sites

Hi,

 

 

 

I assume you mean that you want daily data to be plotted, but only show the legend on the x-axis for certain values, like 1st of Jan, 1st of Feb.

 

 

 

I wanted only 15 values to be shown, but had between 30 - 720 values to be plotted, and solved it like this in PHP:

 

 

 


$strXML .= "";



// show only ca 15 dates on the calendar.

$show_frequency = $num_days / 15;

// create the calendar (catigories)

$cur_row = 0;

foreach ( $cur_calendar as $cur_day ) {

	if ($cur_row++%$show_frequency == 0 ) {

		$cur_display = 1;

	} else {

		$cur_display = 0;

	}

	$strXML .= "";

	$cur_row++;

}

$strXML .= "";

 

 

 

This produces XML that looks like this:

 

 

 


categories

category name='2008-03-29' showName='1' /

category name='2008-03-30' showName='0' /

category name='2008-03-31' showName='0' /

category name='2008-04-01' showName='0' /

category name='2008-04-02' showName='0' /

category name='2008-04-03' showName='0' /

category name='2008-04-04' showName='1' /

category name='2008-04-05' showName='0' /

category name='2008-04-06' showName='0' /

...

 

 

 

Sorry for the weird xml, but the forum does not display the code within "<" and ">", weird.

 

 

 

This means that you've got a category for each and every "bucket"/date, but only the ones with showName=1 will be visible in your chart.

 

 

 

Good luck!

 

 

 

//magnus

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this