EJSC.Chart.exportSVG

See Also

Top  Previous  Next

 

Definition

 

string exportSVG( object Options )

 

Options Described (parameter {default value})

       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>.

 

Description

 

This method will export the chart as it is currently rendered as SVG.  This 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({

                                               includeHeader: false,

                                               height: "50%",

                                               width: "50%",

                                               namespace: "mySVG"

                               }));

               }

 

</script>

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