Setting layer ID in exported SVG


https://www.nevron.com/Forum/Topic12093.aspx
Print Topic | Close Window

By rich dudley - 7 Years Ago
Elements in SVG images can have ID set for them which can be programmatically searchable in image editing software, does Nevron make this an accessible option?
By Nevron Support - 7 Years Ago
Hi Rich,
By default the control will export the element/atom pair as id attribute in SVG. You can however inject any attribute name/value pair inside the generated SVG using the interactivity style - for example:

   NChart chart = nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();

   NInteractivityStyle interactivityStyle = new NInteractivityStyle();
   interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = "AttributeName='bar'";
   bar.Values.Add(10);
   bar.InteractivityStyles.Add(0, interactivityStyle);
   bar.Values.Add(20);
   bar.Values.Add(30);

   chart.Series.Add(bar);

   NSvgImageFormat svgImageFormat = new NSvgImageFormat();
   svgImageFormat.EnableInteractivity = true;
   nChartControl1.ImageExporter.SaveToFile("c:\\temp\\test.svg", svgImageFormat);

In the above example all svg export that is associated with the first bar will have a custom attribute. Hope this helps - let us know if you meet any problems or have any questions.
By rich dudley - 7 Years Ago
Unfortunately enabling interactivity severally impacts the aesthetic of the graph. Its not usable with the line broken up like this.
Example:
https://www.nevron.com/forum/uploads/images/1e5196a1-d549-4f01-88fa-b7ac.png
By Nevron Support - 7 Years Ago
Hi Rich,
Try using the following code:
lineSeries.SamplingMode = SeriesSamplingMode.Enabled;
In this mode the line series will not export interactivity information per data point and the line joins should work.
Let us know if you meet any problems.