2017-03-02 5 views
2

私はいくつかの単純な線図をプロットしようとしています...私は思った。私はこれまでやった:WPF DVC:Lineseriesスタイルと軸の設定を使用してC#

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> 

これは、x軸が「ツァイト」、「Volumenstrom Q」と、左のy軸とy右で標識されたチャートを生成し、 "Druck p"と一緒に - 軸。ファイン。

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); 

これは、2本の単純な水平線につながる: は今、私は2つのlineを追加しました!ファイン。残念ながら、両方の線は左Y軸に関連していますが、最初の系列を左に、第2系列を右のY軸に戻したいと思います。どこでこれを設定できますか?私はXAMLではなくC#でこれを行うことをお勧めします。 少し余分な質問:どのように軸の範囲を設定できますか? x = 0.5とx = 33.1の間のx値をプロットしたいとします。

Googleは私に多くの関連記事を表示しましたが、この質問には答えませんでした。誰でもDVCの完全なドキュメントを見つける場所を知っていますか?WPF Toolboxのチャート?

答えて

0

あなたのXAMLから対応するLinearAxisコードを削除し、それを定義することができ、コードビハインドのように:

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 }; 

enter image description here

+0

おかげで多くのことを、これは正常に動作します!データポイントの色や背景色を設定する方法が分かっているのでしょうか?再びXAMLの例が見つかりました... –

+0

Okを使用して線の色に影響を与えます。Style DataPointStyle_Red = new Style(typeof(DataPoint)); Setter DataPointStyle_Red.Setters.Add(新しいSetter(DataPoint.BackgroundProperty、新しいSolidColorBrush(Colors.Red)));そして最後にsingle_pressure_LS.DataPointStyle = DataPointStyle_Red; –

関連する問題