views:

63

answers:

1

I've been looking for a good open-source tool for creating graphs in PHP, and pChart is looking like a great candidate.

One need I have is to be able to click on certain elements of the graph, like a category label or an individual bar, to drill-down into the data, and display new data and new graphs on a new page.

Is this something that pChart supports? I know that it outputs image files, and I know that, in a pinch, I could try using HTML Image Maps to make parts of the chart clickable, but I'm hoping there's a more automated way.

If pCharts doesn't support this functionality, is there another php charting package you would reccomend that does? It would need to be open-source, and locally hosted (no Google Chart-type API's).

Thanks!

+1  A: 

pChart does not support this directly, last I checked.

However, you can do it with CSS and overlaid elements! One site where you can see an example of this in action is http://craftcult.com/heartchart.php?userid=sugarpinkboutique (press the Get Chart button on the top chart for an example, choose 'seller buyers separate' first for a more elaborate example).

Essentially, you can overlay clickable elements over the chart using JavaScript and/or CSS/HTML. I suggest using absolute positioning in your CSS, and creating the elements with JS based on the data used to create the chart.

I do enjoy working with pChart. It's pretty well-written and flexible. I also saw this link here on SO relating to a library for doing something similar in JS : http://pchart.sunyday.net/ImageMap/

Alex JL