View unanswered posts | View active topics It is currently Fri Apr 19, 2024 1:08 am



Reply to topic  [ 10 posts ] 
return pixel coordinate offsets for any chart (for html map) 
Author Message
Regular pChart user
Regular pChart user

Joined: Mon Dec 13, 2010 7:54 am
Posts: 13
Location: Gold Coast, Australia
Post 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
Profile
Regular pChart user
Regular pChart user

Joined: Mon Dec 13, 2010 7:54 am
Posts: 13
Location: Gold Coast, Australia
Post Re: return pixel coordinate offsets for any chart (for html
Bar Chart Only

okay, this was extraordinarily easy to do - i love pChart! JD, youve coded it very well for people who want to explore and extend it :D

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
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post 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
Profile WWW
Regular pChart user
Regular pChart user

Joined: Mon Dec 13, 2010 7:54 am
Posts: 13
Location: Gold Coast, Australia
Post 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
Profile
Experienced pChart user
Experienced pChart user

Joined: Thu Dec 02, 2010 3:03 pm
Posts: 36
Location: Somerville, MA, USA
Post 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.

_________________
Image


Mon Dec 20, 2010 6:11 am
Profile WWW
New pChart user
New pChart user

Joined: Mon Apr 18, 2011 11:18 pm
Posts: 2
Post 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. :D


Mon Apr 18, 2011 11:22 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post 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
Profile WWW
New pChart user
New pChart user

Joined: Mon Apr 18, 2011 11:18 pm
Posts: 2
Post 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
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post 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
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron