PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 4, 2022

[FIXED] How to specify custom y-axis tick interval with pChart

 July 04, 2022     pchart     No comments   

Issue

I'm wanting my y-axis to show the ticker at intervals of 8. I've set my scale mode to manual with a min of 0 and a max of 48 but it still defaults to showing a tick at intervals of 5.

I haven't seen a setting or option to customise this yet, is there a way to do it?

/* Draw the scale */
$scaleSettings = array("Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>array(0=>array("Min"=>1,"Max"=>56)));
$myPicture->drawScale($scaleSettings);

enter image description here


Solution

I'm fairly new to pChart and was looking for a way to do the same thing. I ended up finding a discussion in pchart's forums about the "Factors" setting for drawScale(). It can be used to set the tick intervals.

So your code would need to be:

$scaleSettings = array("Factors"=>array(8));
$myPicture->drawScale($scaleSettings);

It's mentioned in the documentation, but I haven't been able to find a whole lot of information on it. I can't tell you why the number must be in an array, just that it did not work for me what I tried "Factors"=>8.

Here are the docs for drawScale: http://wiki.pchart.net/doc.doc.draw.scale.html

And here's the discussion I found useful: http://wiki.pchart.net/forum/viewtopic.php?f=1&t=397



Answered By - xtc
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing