Author |
Message |
mykchan
Regular pChart user
Joined: Mon Dec 13, 2010 7:54 am Posts: 13 Location: Gold Coast, Australia
|
return pixel coordinate offsets for any chart (for html map)
hi,
i have a feature request but im not sure how possible it would be to implement.
can pChart return the coordinates (pixel offsets - top right bottom and left) for each element on a chart, to construct a html map element with appropriate area coordinates?
this would enable tooltips for individual bars, or slices of a pie chart, or lines of a line chart, etc.
in the case of overlaid datasets and filled-type charts, it could be up to the developer to control how the map works with conflicting area tags...
|
Fri Dec 17, 2010 4:23 am |
|
|
mykchan
Regular pChart user
Joined: Mon Dec 13, 2010 7:54 am Posts: 13 Location: Gold Coast, Australia
|
Re: return pixel coordinate offsets for any chart (for html
Bar Chart Onlyokay, this was extraordinarily easy to do - i love pChart! JD, youve coded it very well for people who want to explore and extend it the changes (to pChart2.0.7) i had to make to accomplish this: pImage.class: line 63: Code: /* Pixel Offset Coordinate Map */ var $PixelOffsetCoordinates = NULL; // Populated in Drawing functions, accessable to instantialiser
pDraw.class: line 3056: Code: $this->PixelOffsetCoordinates[$SerieName]=array();
pDraw.class: line 3056: Code: $this->PixelOffsetCoordinates[$SerieName][$Key]=array(array($X+$XOffset+$XSpace,$Y2),array($X+$XOffset+$XSize-$XSpace,$Y1));
then in your chart-generating php file: Code: if (isset($_GET['output'])) { $chart->Stroke(); exit; } else { $map="<map name='report_map>"; foreach ($graph_data->Data['Series'] as $SeriesName => $Serie) { if ($SeriesName==$graph_data->Data['Abscissa']) continue; foreach ($this->chart->PixelOffsetCoordinates[$SeriesName] as $key=>$pos) { $map.="<area shape='rect' coords='".ceil($pos[0][0]).",".ceil($pos[0][1]).",".ceil($pos[1][0]).",".ceil($pos[1][1])."' title='".$SeriesName." ".$graph_data->Data['Series'][$graph_data->Data['Abscissa']]['Data'][$key].": ".number_format($graph_data->Data['Series'][$SeriesName]['Data'][$key])."' />"; } } $map.="</map>"; return "<img src='".$chart_image_url."&output' usemap='#report_map' />".$map; }
Last edited by mykchan on Mon Dec 20, 2010 1:04 am, edited 1 time in total.
|
Fri Dec 17, 2010 5:02 am |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: return pixel coordinate offsets for any chart (for html
This will be added to all charting function. I plan to re-build an interface for HTML maps like in the v1 with some JS client side extensions.
|
Fri Dec 17, 2010 9:29 am |
|
|
mykchan
Regular pChart user
Joined: Mon Dec 13, 2010 7:54 am Posts: 13 Location: Gold Coast, Australia
|
Re: return pixel coordinate offsets for any chart (for html
until JD builds this properly into pChart, i have created extended functionality for bar, line and pie charts.
ive posted a how-to for bar charts above; if anyone wants pie charts or line charts too, let me know and i'll write about them here too.
|
Mon Dec 20, 2010 4:59 am |
|
|
mice32
Experienced pChart user
Joined: Thu Dec 02, 2010 3:03 pm Posts: 36 Location: Somerville, MA, USA
|
Re: return pixel coordinate offsets for any chart (for html
> until JD builds this properly into pChart, i have created extended functionality for bar, line and pie charts. Hmm... Interesting... I think, you could post your tutorial in viewforum.php?f=4.
_________________
|
Mon Dec 20, 2010 6:11 am |
|
|
sbekker
New pChart user
Joined: Mon Apr 18, 2011 11:18 pm Posts: 2
|
Re: return pixel coordinate offsets for any chart (for html
Hi JD, When will you be adding hover tooltips to the graphs? My client likes your charts but needs this functionality URGENTLY as usual.
|
Mon Apr 18, 2011 11:22 pm |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: return pixel coordinate offsets for any chart (for html
Implementation is almost done and will be release in the next minor ;o)
JD.
|
Tue Apr 19, 2011 7:30 am |
|
|
sbekker
New pChart user
Joined: Mon Apr 18, 2011 11:18 pm Posts: 2
|
Re: return pixel coordinate offsets for any chart (for html
Darn. This clients wants it this week. Oh well just have to use google charts for now..
|
Tue Apr 19, 2011 11:24 am |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: return pixel coordinate offsets for any chart (for html
It's not that easy ;o) it involves both PHP, JavaScript and HTML parts.
|
Tue Apr 19, 2011 12:10 pm |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: return pixel coordinate offsets for any chart (for html
The 2.1.2 version has been published yesterday implementing this feature and is now available for download at http://www.pchart.net/download. JD.
|
Fri Aug 05, 2011 8:44 am |
|
|