EJSC.Chart.exportSVGLegend

See Also

 

Definition

 

string exportSVGLegend( object Options )

 

Options Described (parameter {default value})

orientation {"horizontal"}

The orientation property defines how the legend dimensions will be calculated. Valid options are "horizontal" and "vertical". When using horizontal, the legend's width will match the chart's width and the legend items will be displayed left to right, top to bottom. The height will expand as needed to accomidate all legend items. Specifying vertical for orientation will cause the legend to match the charts height and display the legend items top to bottom, left to right, expanding the width of the legend as necessary.

includeHeader {true}

The includeHeader property defines whether the result should include the xml declaration (<?xml version="1.0"?>) and the SVG doctype tags.

height {chart height in pixels}

The height property defines the height attribute of the viewbox attribute in the output svg tag (see viewbox). By default this is the pixel height of the chart but may be set to an arbitrary number or percentage such as "100%"

width {chart width in pixels}

The width property defines the width attribute of the viewbox attribute in the output svg tag (see viewbox). By default this is the pixel width of the chart but may be set to an arbitrary number or percentage such as "100%"

namespace {none}

The namespace property defines the prefix namespace to use for the svg tags. This is useful when used with includeHeader=false if including the resulting svg inside another document type. By default, this left undefined and the resulting svg will look something like <svg ... >...</svg>. If defined, for example as namespace = mysvg, the resulting svg will look like <mysvg:svg ...>...</mysvg:svg>.

border {}
show {true}

The show property determines whether or not to draw a border around the entire legend area.

color {"#000"}

The color property specifies the color of the border, only applicable if show is true.

size {1}

The size specifies the size (thickness) of the border drawn, only applicable if show is true.

show_title {true}

The show_title property determines whether to draw the title area of the legend. If false or if the chart's title property is blank, the legend title area will not be drawn.

 

Description

 

This method will export the chart legend as it relates to the currently rendered chart.  The legend is exported in a more print friendly manner and may be customized using the options described above.  The exported SVG string can be returned to the server for processing into many different forms such as png or pdf.  The server-side processing of this data is beyond the scope of this help document.

 

Example:

<script type="text/javascript">

 

       var chart = new EJSC.Chart("myChart", {});

       var series = new EJSC.LineSeries(

               new EJSC.ArrayDataHandler([[1,1],[2,2],[3,3],[4,2],[5,1]]),

               {}

       );

       chart.addSeries(series);

       

       function buttonClick() {

               alert(chart.exportSVG({

                       height: "50%",

                       width: "50%",

                       border: {

                               show: true,

                               color: "#F00",

                               size: 4

                       },

                       show_title: false

               }));

       }

 

</script>

<button onclick="buttonClick();">Export SVG</button>