Page 1 of 1

WPF Design adding series.

Posted: Thu Nov 19, 2009 3:55 pm
by 15654006
Hello,
Is it possible to define the series and chart in xaml at design time when using TeeChart.WPF? We are using TeeChart.WPF.dll 4.0.2009.35592.
Using the VCL version of Tchart, it was extremely useful to see the chart with it's series being populated at design time.

When we attempt this at design time in Blend/Visual Studio using TeeChart.WPF we encounter errors.

The xaml listed below compiles correctly, but an exception is thrown when it attempts to render (in design or runtime).

Is there anything we can do to edit the chart properties/series at design time, without requiring to create the series at runtime?

Code: Select all

<?xml version='1.0' encoding='utf-8' ?>
<Window x:Class="WindowsApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WindowsApplication1" Height="300" Width="300" 
    xmlns:chart="clr-namespace:Steema.TeeChart.WPF;assembly=TeeChart.WPF"
    xmlns:series="clr-namespace:Steema.TeeChart.WPF.Styles;assembly=TeeChart.WPF"
    xmlns:tools="clr-namespace:Steema.TeeChart.WPF.Tools;assembly=TeeChart.WPF"
    xmlns:drawing="clr-namespace:Steema.TeeChart.WPF.Drawing;assembly=TeeChart.WPF">
  <Grid>
		<chart:TChart x:Name="tChart1" Margin="0, 0, 0, 50" Width="700" 
Height="350">
		<chart:TChart.Panel>
			<chart:Panel>
				<chart:Panel.Gradient>
					<drawing:Gradient Visible="True" StartColor="Blue" 
EndColor="Red"/>
				</chart:Panel.Gradient>
			</chart:Panel>
		</chart:TChart.Panel>
		<chart:TChart.Aspect>
			<drawing:Aspect View3D="False"/>
		</chart:TChart.Aspect>
		<chart:TChart.Series>
			<series:Points Color="Green">
				<series:Points.SeriesPoints>
					<series:SeriesXYPoint X="50" Y="50"/>
					<series:SeriesXYPoint X="150" Y="150"/>
					<series:SeriesXYPoint X="260" Y="250"/>
				</series:Points.SeriesPoints>
			</series:Points>
		</chart:TChart.Series>
		<chart:TChart.Tools>
			<tools:Annotation Text="Hello"/>
		</chart:TChart.Tools>
		</chart:TChart>
	</Grid>
</Window>
The Exception information is:

Code: Select all

Object reference not set to an instance of an object.
   at Steema.TeeChart.WPF.Legend.DrawSymbol(Series series, Int32 index, Rect r)
   at Steema.TeeChart.WPF.Legend.DrawLegendItem(Int32 ItemIndex, Int32 ItemOrder)
   at Steema.TeeChart.WPF.Legend.DrawItems()
   at Steema.TeeChart.WPF.Legend.Paint(Graphics3D g, Rect rect)
   at Steema.TeeChart.WPF.Chart.DoDrawLegend(Rect& tmp)
   at Steema.TeeChart.WPF.Chart.DrawTitlesAndLegend(DrawingContext g, Rect& tmp, Boolean BeforeSeries)
   at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g, Boolean noTools)
   at Steema.TeeChart.WPF.TChart.Draw(DrawingContext g)
   at Steema.TeeChart.WPF.TChart.OnRender(DrawingContext drawingContext)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize)
   at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
Thanks!

Re: WPF Design adding series.

Posted: Fri Nov 20, 2009 10:12 am
by 10050769
Hello Ancere,
Is it possible to define the series and chart in xaml at design time when using TeeChart.WPF? We are using TeeChart.WPF.dll 4.0.2009.35592.
Using the VCL version of Tchart, it was extremely useful to see the chart with it's series being populated at design time.

When we attempt this at design time in Blend/Visual Studio using TeeChart.WPF we encounter errors.

The xaml listed below compiles correctly, but an exception is thrown when it attempts to render (in design or runtime).

Is there anything we can do to edit the chart properties/series at design time, without requiring to create the series at runtime?

I am sorry at the moment TeeChart.WPF.dll doesn't include support in desingtime, we have been added in wish-list to consider it for future versions of TeeChartWPF, but at he moment you only can do all to runtime. You could find examples of how to use TeeChartWPF in Demos and Tutorials of WPF.

I made a simple example. This I think works if you want, but in runtime.


Create Chart

Code: Select all

        <chart:TChart x:Name="tChart1" Margin="26,-13,0,69" />    
This is only component that can be put in desingtime.

Code runtime

Code: Select all

      public Window1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            Steema.TeeChart.WPF.Styles.Points points = new Steema.TeeChart.WPF.Styles.Points(tChart1.Chart);
            Steema.TeeChart.WPF.Tools.Annotation annotation1 = new Steema.TeeChart.WPF.Tools.Annotation(tChart1.Chart);
            tChart1.Aspect.View3D = false;
            tChart1.Panel.Gradient.Visible=true;
            tChart1.Panel.Gradient.StartColor= Colors.Blue;
            tChart1.Panel.Gradient.StartColor = Colors.Red; 
            points.Add(50,50);
            points.Add(150,150);
            points.Add(260, 250);
            points.Color = Colors.Green;
            annotation1.Text = "Hello";
            annotation1.Position = Steema.TeeChart.WPF.Tools.AnnotationPositions.LeftBottom;
        }
I hope will helps.

Thanks,