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.
Related
I was going through the first answer on How do I calculate a trendline for a graph?. The answer says
Given that the trendline is straight, find the slope by choosing any
two points and calculating:
(A) slope = (y1-y2)/(x1-x2)
Then you need to find the offset for the line. The line is specified
by the equation:
(B) y = offset + slope*x
So you need to solve for offset. Pick any point on the line, and solve
for offset:
(C) offset = y/(slope*x)
I'm pathetic in Math. So I need some help to understand the equation in programming term. Lets say I have stock data containing Date, Open, High Low, Close and Volume. If I am not wrong I have to calculate X Axis first as per this answer Calculate a trendline when the x-axis uses dates I could use mysql query to calculate X1-X2( which I am assuming difference between First and Last Date). And for Y axis Last Low Price - First Low Price (Still Assuming).
But in next stage I'm stuck. How would I calculate x or offset and on third y? Can someone please help me to understand it?
I am having an issue with saving a PDF file from PHPExcel and it creating widow/orphans with my data.
I know of the function to create page breaks,
$objPHPExcel->getActiveSheet()->setBreak( 'A10' , PHPExcel_Worksheet::BREAK_ROW );
but I would like to know if there is a function to know the current height of a range of cells.
I have found references to "getRowDimension" in functions like
$objPHPExcel->getActiveSheet()->getRowDimension('10')->setRowHeight(100);
but I cannot find any documentation on that function. Does anyone know if it can calculate the height of the chosen row and/or take a range of rows?
Also, is there a function to calculate the usable space between the header and footer of each page? Or should I calculate that from the page margin?
Thank you,
Nick
$objPHPExcel->getActiveSheet()
->getRowDimension('10')
->getRowHeight();
Will return the row height for the specified row. This is the height in "points", where 1 point is the equivalent of about 1/72 of an inch (or about 0.35mm). A value of 0 indicates a hidden row; while a value of -1 is the default value, which is 12.75pt (about 1/6 of an inch).
The PHPExcel_Shared_Drawing class contains a number of functions for converting between points and other units of measure, such as pointsToPixels() and pixelsToPoints(), and pixelsToEMU() and EMUToPixels() (English Metric Units).
The whole issue of Microsoft's units of measure is really a confusing minefield, but there's a useful blog post here discussing the different units of measure use in MS Office
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.
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.
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