Defined X and Y Axis in pChart 2.0 - php

I'm using the line graph of pChart for a partograph.
Now, my problem is, I can't define the values for the x and y axis. The y-axis will adjust automatically depending on the data that is set on the graph. This is not what I want.
Please see illustration:
By default, when no data is to be plotted in the graph.
When loaded with data.
Notice that the values of the Y-axis changed. What I want is to make the scale of axis from 0 to 10 (1,2,3,4,5,6,7,8,9,10).

You will need to set the scale manualy. For example:
$AxisBoundaries = array(0=>array("Min"=>0,"Max"=>100));
$ScaleSettings = array
("Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>$AxisBoundaries,"DrawSubTicks"=>TRUE,"DrawArrows"=>TRUE,"ArrowSize"=>6);
$myPicture->drawScale($ScaleSettings);
Hope this helps

Related

OpenTBS / PHP - How do I dynamically generate horizontal values for embedded graph inside of docx template?

I have a graph for which I was able to manually create x axis values in a docx template. The template outputs the correct graph. Instead of relying upon manually entering all x values and substituting the values from the php array, I want to dynamically populate the horizontal axis with values from a php array.
PHP Code
// --------------------------------------------
// Merging and other operations on the template
// --------------------------------------------
// Change chart series
$ChartNameOrNum = 'Buildup'; // Title of the shape that embeds the chart
$SeriesNameOrNum = 'Series 1';
$NewValues = array($buildupLabels['TotalActionItems'], $buildupSeries['TotalActionItems'] );
$NewLegend = "Total Action Items";
$TBS->PlugIn(OPENTBS_CHART, $ChartNameOrNum, $SeriesNameOrNum, $NewValues, $NewLegend);
// Delete comments
$TBS->PlugIn(OPENTBS_DELETE_COMMENTS);
Output File with Rendered Chart
Chart Template
Table of x-axis values
How can I achieve the above? Is this possible using the OpenTBS, or do I need to manually enter all x axis values?
OpenTBS enables you to change x and y values for any of the series.
So you just have to change all (x,y) items for all of your series then old x values should totally disappear in your chart. You have to get an automatic min and max for the x axis in order to have it adapted to the new values.
You also have to keep in mind the Ms Office Charts behavior :
If your chart type is a XY (also named Scatter), then (x,y) of your series entries can be in any order, and the x axis will not necessary display values used by items. This is nice when you have several series with different x values and you want to display unused x values in the x axe.
If your chart type different from a XY then x values are considered as categories. Only used values will be displayed in the x axis. If tow series have different categories all possible values are displayed in the x axis.
I just discovered that I do not need to automatically generate all of the horizontal values in the embedded chart. All I need to do is put one date in the first record (e.g. Mar 05 15 or anything else not even in the range of dates I am populating) and the series will automatically populate all available dates from my PHP array.

PChart Right axis to show labels for specific values

I currently have the wind chart shown below working with the mean, low and high values.
What i would like to add but i can figure out is:
I need a plot a right hand scale that would show the wind force. I would guess this would be set as a label for a specific value.
So in this case
label for force 1 should be in line with wind speed 1
label for force 2 should be in line with wind speed 4
label for force 3 should be in line with wind speed 7
label for force 4 should be in line with wind speed 11
label for force 5 should be in line with wind speed 17
is there anyway i can create a y axis that shows a specic label at specific value?
thus creating something like this: but where the numbers line up to the right values
Here is what worked for my application. I was making a particle count graph:
$MyData->addPoints(array(7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24),"ISO");
$MyData->setSerieOnAxis("ISO",1);
$MyData->setAxisName(1,"ISO Code");
$MyData->setAxisPosition(1,AXIS_POSITION_RIGHT);
$MyData->setSerieDrawable("ISO", FALSE); //dont plot results just show axis
then further down where you do your scale:
$AxisBoundaries = array(0=>array("Min"=>0,"Max"=>5),1=>array("Min"=>7,"Max"=>24));
$ScaleSettings = array("Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>$AxisBoundaries);
$myPicture->drawScale($ScaleSettings);
So you set the scale for the left and right axis there. In my application my right side needed to go from 7 to 24 and my left side from 0 to 5. I didnt plot my right side graph, as I just wanted to show the scale.
You pretty much have to fiddle with your min and max to get them to line up where you want and you have to make sure the left axis is fixed. If its dynamic then it will be different each time depending on your data.

Draw textual PHP graph

I need to draw a line chart using PHP which fullfills the following requirements:
Textual X-Axis descriptors
Not every serie has values for all X-Axis values
Markers on the given points
I have already detailed watched pChart, JpGraph and LibChart, but I didn't manage to get the expected result. It should look like this (poorly drawn with MsPaint):
EDIT: The exact problems:
With Libchart, I didn't manage to get different series with not all x axis values filled
With pChart, there was the same problem (e.g. at the above example, pChart would not make a line at the blue series from desc 3 to desc 6, when values 4 and 5 have the value VOID). I could also calculate the values between, but then they would also have markers (e.g. at desc 4 and desc 5)
With JpGraph, I didn't manage to create textual x axis values
Thank you for your help, Community!
Found a solution using pChart:
I can use VOID for points which do not have an own value, and set a config setting like the following one:
$myPicture->drawLineChart(array('BreakVoid'=>false,'VoidTicks'=>0));
Using this settings, VOID will draw correct lines to the next known value.

Minimum value for graph axis

I am trying to make a bargraph that plots times.
So what the technical issue we are trying to get the minimum plot value to something.
For example if what I was trying to graph was 4 min 30 s (4:30), 4:45, 4:15, and 4:20,
I would like the y=0 value to be 4 minutes and each increment in the y axis to be 1 second.
Effectively, it would be a bargraph of 30, 45, 15, and 20 with the y = 0 axis labelled as.
Is there anyway of doing this without have to man handle the data?
Help please if you know how to do this with jpgrah.
Otherwise, does anyone know what this feature is called in general so I can google it up?
I was reading the documentation of jpgrah:
SetYBase seemed a like a good candidate but all it seemed to do when I played with the parameters was shrink the upper limit y-value [Specify the start plot for bars, (minimum Y-value). By default the base uses the value 0 as base.]
Found the appropriate method in the JPGraph documentation:
$aGraph = new Graph($aWidth,$aHeight,'auto');
$graph->SetScale('textlin',$aMinY,$aMaxY);
$aMinY and $aMaxY give the minimum and maximum values included in the graph.
Also, they are optional arguments.

PHP Flash Charts API w/ Missing Dates?

I have some data of balances ($), dates, and memos. I want to plot this as a line graph. I was happily plotting away with http://www.maani.us/xml_charts/ until I realized that my x-axis was off: there aren't balances for every day, and sometimes there are multiple balances on a single day. How can I compensate for this (space out the dates appropriately)?. I tried using unix_timestamps for the dates so that it could have a numeric value, but this only works for scatter plots (and it sucks at that). The memos I want to appear as tooltips.
Are there any other libraries/APIs that can handle this? Will Fusion Charts do it? Basically I need a chart API that can handle numeric values for both the X and Y axis, but allows me to rename the X axis so it doesn't actually appear as numbers, and supports tooltips (ie is flash based).
Mark,
In FusionCharts scatter chart, we've numeric x and y axis. The good part is that the scatter chart can be made to behave like a line chart. You can connect the points of the scatter chart using a line by setting:
<dataset drawLine='1' ....>
So to show dates on the x-axis, do the following:
Set the value of the least date in your dataset as 0
For every other date, calculate the dateDiff(leastDate, days) and set that as the x-axis value.
Hope that helps...

Categories