PHP Flash Charts API w/ Missing Dates? - php

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...

Related

Jpgraph axis number format: Engineering notation for large numbers

I'm using jpgraph to create some plots from measured data.
Now I have a scatter-plot with large numbers on the y-axis.
I would like to change the number format to a number and exponent instead of just showing an integer. Unfortunately I did not find any solution on-line.
The y-axis has a range of 0 to 12000000. I want to display 12E6 instead of 12000000.
Is this possible? Maybe with the SetFormat?

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.

Can text be inserted into a fusion chart?

I'm using the Grid component in fusion charts and need a date string to be used in the value place. It will always fail when i do this as it is looking for a number. Is there anyway it can allow text to be used aswell?
Thanks
The ability to have date-time axis values is not yet available in FusionCharts. Nevertheless, the use case for you does not fit right.
Ideally, the grid component's right column should show a number (value). The left column is text showing the labels. For a grid, it makes very less sense to have text on both columns.
Instead of a date, the right column should show how many month's or days or hours, etc.
Excerpts from FusionCharts documentation: http://docs.fusioncharts.com/charts/contents/advanced/number-format/Number_Scaling.html
Say we're plotting a chart which indicates the time taken by a list of automated processes. Each process in the list can take time ranging from a few seconds to few days. And we've the data for each process in seconds itself. Now, if we were to show all the data on the chart in seconds only, it won't appear too legible. What we can do is build a scale indicating time and then specify it to the chart. This scale, in human terms, would look something as under:
60 seconds = 1 minute
60 minute = 1 hr
24 hrs = 1 day
7 days = 1 week
Now, to convert this scale into FusionCharts XML format, you'll have to do it as under:
First you would need to define the unit of the data which you're providing. Like, in this example, you're providing all data in seconds. So, default number scale would be represented in seconds. We can represent it as <chart defaultNumberScale='s' ...>
Next, we define our own scale for the chart as: <chart numberScaleValue='60,60,24,7' numberScaleUnit='min,hr,day,wk' >. If you carefully see this and match it with our range, you'll find that whatever numeric figures are present on the left hand side of the range is put in numberScaleValue and whatever units are present on the right side of the scale has been put under numberScaleUnit - all separated by commas.
Set the chart formatting flags to on as: <chart formatNumber='1' formatNumberScale='1' ...>
The entire XML would look like:
<chart defaultNumberScale='s' numberScaleValue='60,60,24,7' numberScaleUnit='min,hr,day,wk'><set label='A' value='38' /><set label='B' value='150' /><set label='C' value='11050' /><set label='D' value='334345' /><set label='E' value='1334345' /></chart>
A sample grid (not with the above data) would look like this:

Categories