WPF Chart Control einbinden

WPF Chart Control einbinden

Hallo liebe Community,
ich habe mit Hilfe des Artikels ".NET in Zenon" http://www.copadata.com/fileadmin/user_upload/cms/downloads/iu/IU_Magazine_22_EN.pdf
ein PieChart Control in Zenon einbinden können. Das gleiche habe ich mit einem LineSeries Chart reproduzieren können, wenn man nur eine LineSeries benutzt. Wenn ich allerdings mehrere LineSeries in dem Chart habe, zeigt Zenon nur den ersten Punkt anstatt die Linien zu zeichnen. Muss ich in dem Fall mein Loose XAML File anders gestalten?
Was ich bisher überprüft habe:
1) Control funktioniert in einer normalen WPF Application in Visual Studio
2) der WPF Cache Ordner des Projektes beinhaltet die neuesten DLL's.
3) Control wurde für Framework 3.5 erstellt
Was könnte ich noch falsch machen?
Anbei der relevante Teil vom Code:
Loose-XAML-File
C# Code:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:WPFControls="clr-namespace:WPFControls;assembly=WPFControls" x:Name="UserControl">




XAML Teil des Controls
C# Code:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="WPFControls.Chart"
mc:Ignorable="d" Width="991" Height="475">














Der C# Code des Controls
C# Code:
public partial class Chart : UserControl
{
public Chart()
{
InitializeComponent();
m_Data = null;
m_Data_0 = null;
m_Data_1 = null;
m_Data_2 = null;
m_Data_3 = null;
m_Data_4 = null;
CurveArray = new KeyValuePair[][] { m_Data_0, m_Data_1, m_Data_2, m_Data_3, m_Data_4 };
for (int i = 0; i < CurveArray.Length; i++)
{
CurveArray= null;
}
}

//Data storage, containing the Value-Description pairs
private KeyValuePair[] m_Data, m_Data_0, m_Data_1, m_Data_2, m_Data_3, m_Data_4;
public KeyValuePair[][] CurveArray;
public double xPos { get; set; }
public double Value { get; set; }
public double which { get; set; }
public bool AddValueToCurve
{
get
{
return true;
}
set
{
AddValueToChart(xPos,Value,which);
}
}
private void AddValueToChart(double x_Po, double dblValue, double whichCurve)
{
int whichCurve_int = (int) whichCurve;
switch (whichCurve_int)
{
case 0:
{ m_Data = m_Data_0; break; }
case 1:
{ m_Data = m_Data_1; break; }
case 2:
{ m_Data = m_Data_2; break; }
case 3:
{ m_Data = m_Data_3; break; }
case 4:
{ m_Data = m_Data_4; break; }
case -1:
{
m_Data = null;
m_Data_0 = null;
m_Data_1 = null;
m_Data_2 = null;
m_Data_3 = null;
m_Data_4 = null;
return;
}
default:
{ m_Data = m_Data_0; break; }
}
if (m_Data == null)
{
m_Data = new KeyValuePair[1];
}
else
{
KeyValuePair[] new_Data = new KeyValuePair[m_Data.Length + 1];
System.Array.Copy(m_Data,new_Data,m_Data.Length);
m_Data = new_Data;
}
m_Data.SetValue(new KeyValuePair(xPos, Value), m_Data.Length - 1);

switch (whichCurve_int)
{
case 0:
{ m_Data_0 = m_Data; break; }
case 1:
{ m_Data_1 = m_Data; break; }
case 2:
{ m_Data_2 = m_Data; break; }
case 3:
{ m_Data_3 = m_Data; break; }
case 4:
{ m_Data_4 = m_Data; break; }
default:
{ m_Data_0 = m_Data; break; }
}
for (int i = 0; i < CurveArray.Length; i++)
{
if (CurveArray== null)
{
KeyValuePair[] new_Data = new KeyValuePair[1];
new_Data.SetValue(new KeyValuePair(0, 0),0);
CurveArray= new_Data;
}
}
CurveArray[0] = m_Data_0;
CurveArray[1] = m_Data_1;
CurveArray[2] = m_Data_2;
CurveArray[3] = m_Data_3;
CurveArray[4] = m_Data_4;
mainChart.DataContext = CurveArray;
mainChart.UpdateLayout();
}
}

VSTA Macro
C# Code:

IElement WPF = null; ;
try
{
WPF = this.DynPictures().Item("DotNet").Elements().Item("WPF-Element_1");
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
if (WPF == null)
{
MessageBox.Show("WPF element not found");
}
else
{
// MessageBox.Show("WPF is something "+WPF.GetType() + " "+ WPF.ID.ToString() + " "+ WPF.Name );
}
WPF.Enable = true;

WPF.set_WPFProperty("mainChartie", "xPos", -780);
WPF.set_WPFProperty("mainChartie", "Value", 10);
WPF.set_WPFProperty("mainChartie", "which", 4);
WPF.set_WPFProperty("mainChartie", "AddValueToCurve", true);
WPF.set_WPFProperty("mainChartie", "xPos", 200);
WPF.set_WPFProperty("mainChartie","Value",100);
WPF.set_WPFProperty("mainChartie","AddValueToCurve", true);

WPF.set_WPFProperty("mainChartie", "which", 0);
WPF.set_WPFProperty("mainChartie", "xPos", 80);
WPF.set_WPFProperty("mainChartie", "Value", 50);
WPF.set_WPFProperty("mainChartie", "AddValueToCurve", true);
WPF.set_WPFProperty("mainChartie", "xPos", -20);
WPF.set_WPFProperty("mainChartie", "Value", 50);
WPF.set_WPFProperty("mainChartie", "AddValueToCurve", true);
WPF.Update();
}

Im Anhang gibt es ein Bild, wie es in der einfachen WPF Application ausschaut. Vielen Dank!

This is a migrated post! Originally posted on 24.07.2015 by user sudoaptget. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com