SharpPlot Reference > SharpPlot Methods > RenderJsonChartMap

SharpPlot.RenderJsonChartMap

Return a JSON-formatted array to facilitate active graphics applications.

public string RenderJsonChartMap();

Example

string map = sp.RenderJsonChartMap();

Description

All data items processed by the chart construction create hotspots which may react to mouse events. There are 3 types of hotspot recorded, depending on the chart type:

  1. Rectangles – used by barcharts and also any text regions such as headings and axis labels
  2. Circles – used by ScatterPlots to create a fixed-radius area around all markers
  3. Polygons – used by Piecharts to outline each wedge (in 20deg segments)

If AddAttibutes has been used to put handlers on text items, hotspots will be created for these. Otherwise there will be on hotspot for each data item, keyed by chart name and series name. A typical array would contain several of these, for example a barchart with 2 data series (each with 3 bars) would generate a section of the array like this:

["Apparel","Hats","rect",[84,249,123,362],[["title","Hat 3"]]],
["Apparel","Hats","rect",[249,174,288,362],[["title","Hat 5"]]],
["Apparel","Hats","rect",[413,99,452,362],[["title","Hat 7"]]],
["Apparel","Coats","rect",[147,61,186,362],[["title","Coat 8"]]],
["Apparel","Coats","rect",[311,174,350,362],[["title","Coat 5"]]],
["Apparel","Coats","rect",[476,212,515,362],[["title","Coat 4"]]],

Here we have named both the chart “Apparel”” and each series to make the example clearer. By default, SharpPlot will generate names “chart1” and ‘Series1,Series2” for you.

The format of each hotspot is standard, and consists of:

  1. The chart name as a string
  2. The series name as a string
  3. The hotspot type as a string (“rect”,”circ”, or “poly” as used in ImageMaps)
  4. The hotspot location as an array. Rectangles are x,y,x,y, circles are x,y,r, polys are x,y, ... x,y pairs.
  5. Additional attributes as an array of Property,Value pairs of strings.

If we add some attributes to the chart legend, the map will contain lines like this:

["Guesses","Key","rect",[59,392,157,407],[["KeyFactor","100"],["KeyStyle","Low"]]],
["Guesses","Key","rect",[161,392,261,407],[["KeyFactor","200"],["KeyStyle","Medium"]]],
["Guesses","Key","rect",[266,392,374,407],[["KeyFactor","300"],["KeyStyle","High"]]],

Here the second element is the value from the HotspotType enumeration, rather than a series identifier.

The entire array will be enclosed with an opening ‘[’ and a closing ‘];’ to allow the programmer to recover the content with a simple eval statement and then to add appropriate behaviours when the mouse is within any of the defined regions.

Overloads

See also ...

Active charts in GUI Applications | SharpPlot Members | HotspotType Enumeration


Send comments on this topic
© Dyalog Ltd 2021