Data is scaled from 0 to 100 by default. if adjust_resolution is TRUE, the data values are altered to fit in with a 0- 100 data range. This does not acheive the results I need, e.g. where the theoretical maximum value is 10 but the highest value is 7, I can either have a very tiny lines at the bottom, or lines reaching the top, neither of which portray the real situation: what I want in this case is that the hightest line should reach 70% of the way up.
I have added a few lines of code (shown below) to my local version of chart.module to allow the data scaling parameters of the google API to be accessed. I've not commited my version back to CVS as I'm not sure how helpful it will be for other people. If it is useful, please feel free to make the change or assign the issue to me and I'll commit it. Hope this helps
Line 220, insert:
* #data_scale
Line 277, insert:
_chart_append('chds', $chart['#data_scale'], $data);
Line 554, insert:
// Bar chart data scaling
case 'chds':
$data[$attr] .= implode(',', array($value['#min'], $value['#max']));
break;
Line 1042, insert:
/**
* Bar chart data scaling
*
* @param int $min
* (optional) minimum value for data scale.
*
* @param int $max
* (optional) maximum value for data scale.
*
* @return array
*/
function chart_data_scale($min = 1, $max = 100) {
return array(
'#min' => $min,
'#max' => $max,
);
}
Comment | File | Size | Author |
---|---|---|---|
#14 | 536472-14-add_datascaling_chds.patch | 2.17 KB | Anonymous (not verified) |
#7 | 536472-add_datascaling_chds-reroll.patch | 2.29 KB | xurizaemon |
#4 | chart.module.patch | 1.84 KB | Anonymous (not verified) |
Comments
Comment #1
SirClickalotThis sounds like exactly what I need and what many users would also need - I'm puzzled as to why it wasn't in place anyway surely any user will need what you describe before long?
Anyway, I have made all the additions to my local version of the chart module as per your instructions but can't get it working. Here's the details.
What I want is for my line chart (comprising two data sets) to scale its actual data values (which range from between roughly 80 and 100) so that they 'fill' the whole of the vertical available space.
In order to achieve this, am I correct in thinking that the following will do the job...
I set up an array which I called data_scalers to hold the min and max values for the two series.
So that the data_scalers array is filled
{80,100,80,100}
to accomodate both data sets.I then followed this with ...
'#data_scale' => $data_scalers
... as the last line of the
'$chart = array(.....)
bit inside the brackets of course.The only reference 'chds' that I can see in the output URI is as follows...
...&chxt=y%2Cy%2Cx&chds=%2Cchd=t%3A87.912777500%2C...
Any guidance?
Thanks
Nick
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedJust what I needed. Ineeded scaling.
The above code works for me when used in the following manner
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedThis should be looked at and properly patched.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedSince the code above works fine for me when I use the google-o-meter (gom) chart type (only one tested), I decided to try my hand at a patch using the code submitted by jwinstanley above.
So, please find attached a patch. Hope this is what a patch should be.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedJust changed the title.
Comment #6
ppcc CreditAttribution: ppcc commented@SirClickaLot, and anyone else who wants to use this with multiple series...
you'll need to add extra array elements in the functions.
eg, for xy charts, change the code snippets like this:
And pass the values in like this:
Comment #7
xurizaemonHandles multiple ranges as per @ppcc's comment above, which I haven't tested extensively.
Rerolled against current HEAD, previous patch was no longer applying.
Comment #8
xurizaemonComment #9
texas-bronius CreditAttribution: texas-bronius commentedThanks for the patch, folks. Works for me, too.
But the module status is "Minimally maintained" and "Maintenance fixes only". Rather than piecemeal patches of this sort, if anyone has any thoughts on #1109472: Hook chart_post_build to append custom GIC parms (to be commented on in that thread, not this one), maybe we could encourage another more encompassing, future-proof release?
Comment #10
j_ten_man CreditAttribution: j_ten_man commentedI think the following would be a better solution since you can have multiple series (more than just 2 like the previous patch handled):
Usage:
Comment #11
Pedro Lozano CreditAttribution: Pedro Lozano commentedWith the patch I posted at #1109472: Hook chart_post_build to append custom GIC parms you can use a new hook to implement more API parameters.
Comment #12
Tilo CreditAttribution: Tilo commentedMany thanks to grobot
This patch works great! However, it is somehow disappointing because it is still not released.
Regards, Tilo
Comment #13
13rac1 CreditAttribution: 13rac1 commentedI'm stuck on a large project, I'll be working on this issue queue again as soon as I am done.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedSame patch as #7 for the latest dev version. Don't see #6 changes included though, so they aren't included in mine either.
Thanks to all involved. This solved my problems (bar-chart bars getting cut off and negative values not working). Tested with bar-chart and pie-chart.
Comment #15
Pierre.Vriens CreditAttribution: Pierre.Vriens commentedTrying to get this issue moving again, refer to the parent link I added for details.
Comment #16
Pierre.Vriens CreditAttribution: Pierre.Vriens commentedComment #17
apadernoI am closing this issue, as Drupal 6 is no longer supported.