Reputation: 55
I am trying to Plot some simple Line Charts ... I Thought. I've done this so far:
XAML
<DVC:Chart x:Name="DVA_Cycle_Chart" BorderThickness="0" BorderBrush="{x:Null}" >
<DVC:Chart.Axes>
<DVC:LinearAxis Orientation="X" Title="Zeit"/>
<DVC:LinearAxis Orientation="Y" Location="Left" Title="Volumenstrom Q "/>
<DVC:LinearAxis Orientation="Y" Location="Right" Title="Druck p"/>
</DVC:Chart.Axes>
</DVC:Chart>
This generates a Chart where the x-axis is labeled with "Zeit", the left y-axis with "Volumenstrom Q " and the right y-axis with "Druck p". Fine. Now I added two Lineseries:
C#
KeyValuePair<double, double>[] single_pressure_KeyValuePair = new KeyValuePair<double, double>[2];
KeyValuePair<double, double>[] single_flow_rate_KeyValuePair = new KeyValuePair<double, double>[2];
for (int i = 0; i < 2; i++)
{
single_pressure_KeyValuePair[i] = new KeyValuePair<double, double>(i, 3);
single_flow_rate_KeyValuePair[i] = new KeyValuePair<double, double>(i, 4);
}
LineSeries single_pressure_LS = new LineSeries();
single_pressure_LS.Title = "Pressure";
single_pressure_LS.IndependentValueBinding = new Binding("Key");
single_pressure_LS.DependentValueBinding = new Binding("Value");
single_pressure_LS.ItemsSource = single_pressure_KeyValuePair;
DVA_Cycle_Chart.Series.Add(single_pressure_LS);
LineSeries single_flow_rate_LS = new LineSeries();
single_flow_rate_LS.Title = "Flow Rate";
single_flow_rate_LS.IndependentValueBinding = new Binding("Key");
single_flow_rate_LS.DependentValueBinding = new Binding("Value");
single_flow_rate_LS.ItemsSource = single_flow_rate_KeyValuePair;
DVA_Cycle_Chart.Series.Add(single_flow_rate_LS);
This leads to two simple horizontal Lines! Fine. Unfortunately, Both Lines are related to the left Y-Axis, but I want to relade the first series to the left and the second series to the right y-Axis. Where can I set up this. I perfer to do this in C# instead of XAML. Small extra question: how can I set the range of an axis? Lets say I want to plot x values between x=0.5 and x=33.1.
Google showed me a lot of related posts but non answered this question. Does anyone know where to find a complete documentation of DVC:Chart from WPF Toolbox?
Upvotes: 4
Views: 1063
Reputation: 13188
You can remove the corresponding LinearAxis
code from your XAML and define it in code-behind like this:
single_pressure_LS.DependentRangeAxis = new LinearAxis {
Orientation = AxisOrientation.Y,
Location = AxisLocation.Left,
Title = "Volumenstrom Q",
Minimum = 1,
Maximum = 4 };
single_flow_rate_LS.DependentRangeAxis = new LinearAxis {
Orientation = AxisOrientation.Y,
Location = AxisLocation.Right,
Title = "Druck p",
Minimum = 3,
Maximum = 5 };
Upvotes: 2