Page 1 of 1

Teechart.NetV3: SVG Export does not Work

Posted: Fri May 16, 2008 2:48 pm
by 13046026
Hi,

There is an error in the SVG Format routine if you use clipping to draw
the series (as recommend in the faq).

In addition it would be useful if the generated svg root node
declares the svg namespace ( xmlns="http://www.w3.org/2000/svg" )eg:

Code: Select all

<svg width="1000px" height="581px" style="text-antialiasing:true" xmlns="http://www.w3.org/2000/svg">

See the following example

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
using Steema.TeeChart.Styles;

namespace TeeChartTest
{
	public partial class SvgExport : Form
	{
		public SvgExport()
		{
			InitializeComponent();
			SetupChart();
		}

		private void SetupChart()
		{
			TChart chart = new TChart();
			this.Controls.Add(chart);
			chart.Dock = System.Windows.Forms.DockStyle.Fill;
			chart.Location = new System.Drawing.Point(0, 0);
			chart.Name = "tChart1";
			chart.Size = new System.Drawing.Size(945, 575);
			chart.TabIndex = 0;
			chart.Legend.Visible = false;
			chart.Aspect.View3D = false;

			Line line1 = new Line();
			
			chart.Series.Add(line1);
			line1.FillSampleValues();

			line1.BeforeDrawValues += new PaintChartEventHandler(line1_BeforeDrawValues);
			line1.AfterDrawValues += new PaintChartEventHandler(line1_AfterDrawValues);
			
			
			chart.Export.Image.SVG.Save("test.svg");
			System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
			doc.LoadXml("test.svg"); //throws Execption because <g clip-path="url(#Clip2)"> has no close tag
		}
		
		public const bool DRAW_OPAQUE = true;

		void line1_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			if (DRAW_OPAQUE)
            {
                Series s = sender as Series;
                int left = s.GetHorizAxis.IStartPos - 1;
                int right = s.GetHorizAxis.IEndPos + 1;
                int top = s.GetVertAxis.IStartPos - 1;
                int bottom = s.GetVertAxis.IEndPos + 1;
                g.ClipRectangle(left, top, right, bottom);

            }
        }

		void line1_BeforeDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			if (DRAW_OPAQUE)
            {
                g.ClearClipRegions();
            }
		}
	}
}