Reference > Active Charts > PageMap Class – Introduction

PageMap Class – Introduction

Creating Active Charts in a Gui Application

It is relatively easy to make simple interactive graphics on the internet, using a combination of JavaScript (attached to data series) and the SharpPlot Addxxx methods to associate Hints, Tips, Actions and Hyperlinks with elements of a data series. Typically you could allow a user to ‘drill down’ on summary data by clicking on the bars of a barchart, and linking to a detailed display of the underlying figures. The chart below is used for all the worked examples in this section.


The methods in this class allow an application to implement similar capabilities, by converting raw co-ordinates into hotspot information, and using this to extract the hints, tips and links associated with the data. An obvious application would be to show any hints in a status field as the mouse passes over the corresponding items of the data series.

Example

// Typical PageMap calls on data series and heading
 pm = sp.RenderPageMap();  
 System.Console.WriteLine("Pagemap has " + pm.ToString());
 
 int hix = pm.FindHotspot(200,120);        // Middle bar
 HotspotInfo hi = pm.GetHotspotInfo(hix);  // Full details so we can see it
 System.Console.WriteLine("Series detail is " + hi.ToString());
 
 tip = pm.FindTip(hi);
 System.Console.WriteLine("Tip for this element is " + tip);

All co-ordinates are required as (x,y) in points, with the origin at the lower-left corner of the chart. If your application allows the user to resize the form containing the chart, you will need to scale any mouse-move values back to match the paper-size that SharpPlot was called with when the chart was created. The output from the sample is:

Pagemap has Series/targets=12, Hints=2, Tips=10, Links=0, Scripts=4
Series detail is Chart=Bar1, Series=Hats, Item=2, Type=Bar, Locator=186 .9 52 216 193.3 0
Tip for this data item is Hat 5

The locator is stored to full precision, but is rounded off to the nearest 10th pt for display here.

See also ...

HotspotInfo Struct | HotspotType Enumeration | PageMap Members


Send comments on this topic
© Dyalog Ltd 2013