Open GoogleCodeExporter opened 9 years ago
Apologies, I just worked this out by taking away the 4th addAxisRange parameter
$step
variable and the date labels centred themselves... :)
Original comment by novak...@gmail.com
on 17 May 2010 at 12:11
Great work so far :)
Ok, further to this:
I have a grouped bar chart (gBarChart) with 3 data sets. I want to show labels
for
each bar (each data set has one bar) on the X axis.
I am using the following code:
$myBarChart->addDataSet($dataArray1);
$myBarChart->addDataSet($dataArray2);
$myBarChart->addDataSet($dataArray3);
$myBarChart->setVisibleAxes(array('x','y'));
$myBarChart->addAxisLabel(0, $xaxisLabelsArray); //this array contains 3 labels
- When run, only the first label is shown and it is in the middle of the X
axis...
I would like all 3 labels shown on the x axis - each of the 3 labels under its
relevant bar. It would be great if you could let me know which function(s)
should I
use for this, thanks :)
Also, could the addValueMarkers() function be used to add the values of the
bars -
so they are shown just above the bars?
It would be great to see some sample code of this function in use.
All the best
Original comment by novak...@gmail.com
on 19 May 2010 at 9:02
[deleted comment]
For the labels on the axis:
Since you have $dataArray with only 1 value, the chart API (read Google) thinks
that you have
only 1 group, so Google API thinks you need only 1 label.
You can use the command 'chxp' to specify the position of each label. Please
try using this command and then
let me know the result. In the mean time, I will try to add a function to
handle label positions:
$myBarChart -> setProperty('chxp', '0,33,66,99');
Change 33,66,99 to place the labels evenly under your bars (based on a 0-100
scale).
For addValueMarkers()
I wrote a wiki entry on this. Hope it will be helpful. :)
Bye!
Original comment by bardellie
on 23 May 2010 at 10:26
[deleted comment]
I implemented the new function addAxisLabelPositions(). You can find it in r39
of
gChart.php.
An example of usage:
$chart = new gBarChart(300, 150, 'g', 'v');
$chart -> addDataSet(array(4));
$chart -> addDataSet(array(10));
$chart -> addDataSet(array(3));
$chart -> setDataRange(0,15);
$stat -> setColors(array('000000','0000FF'));
$chart -> setVisibleAxes(array('x'));
$chart -> addAxisLabel(0, array('May', 'Jun', 'Jul'));
$chart -> addAxisRange(0, 0, 3);
$chart -> addAxisLabelPositions(0, array(0.5, 1.5, 2.5));
$chart -> setBarWidth('a');
$chart -> getImgCode();
If you use the command addAxisRange with addAxisLabelPositions you can set the
positions more easily. In
exemple, if you have 3 bars, then your axis range will be 0-3. Then the axis
label positions will be 0.5, 1.5,
2.5. Read this values in this way: the first label is positioned at the middle
of the first bar (and then at 0.5
bars from the beginning of the chart), the second label is positioned at the
middle of second bar (and then
1.5 bars from the beginning of the chart), and so on. If you have more than 3
bars, just change the axis
range.
Original comment by bardellie
on 23 May 2010 at 11:29
Original issue reported on code.google.com by
novak...@gmail.com
on 17 May 2010 at 12:00