WPF工具包图表-在条形图上绘制平滑曲线
我似乎无法在同一图表中的条形图上绘制平滑曲线。我没有看到任何与此相关的问题,但可能遗漏了 无论如何,要做到这一点,我想用一个柱系列来表示条形图,用一个线系列来表示曲线。问题似乎是: 1即使X值介于ColumnSeries中存在的点之间,线系列中但不在ColumnSeries中的点始终显示在图表的末尾。我在想,这些中间值可以用来使线性系列曲线平滑 2线型还控制X值之间的间距。我想要的只是用于绘制条之间平滑曲线的线系列。实际上,线系列中有许多点会使钢筋在其应厚的位置非常薄。换句话说,理想情况下,ColumnSeries将控制记号标记和条的厚度,而不是线系列 xaml是WPF工具包图表-在条形图上绘制平滑曲线,wpf,charts,wpftoolkit,lineseries,Wpf,Charts,Wpftoolkit,Lineseries,我似乎无法在同一图表中的条形图上绘制平滑曲线。我没有看到任何与此相关的问题,但可能遗漏了 无论如何,要做到这一点,我想用一个柱系列来表示条形图,用一个线系列来表示曲线。问题似乎是: 1即使X值介于ColumnSeries中存在的点之间,线系列中但不在ColumnSeries中的点始终显示在图表的末尾。我在想,这些中间值可以用来使线性系列曲线平滑 2线型还控制X值之间的间距。我想要的只是用于绘制条之间平滑曲线的线系列。实际上,线系列中有许多点会使钢筋在其应厚的位置非常薄。换句话说,理想情况下,Co
<Grid>
<chartingToolkit:Chart x:Name="MainChart" HorizontalAlignment="Left" Margin="59,35,0,0" Title="Chart Title" VerticalAlignment="Top" Height="246" Width="405">
<chartingToolkit:ColumnSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding BarCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding LineCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</chartingToolkit:Chart>
</Grid>
背后的代码是
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
// Add sample curve points
LineCollection.Add(new KeyValuePair<double, double>(1, 11));
LineCollection.Add(new KeyValuePair<double, double>(1.5, 18));
LineCollection.Add(new KeyValuePair<double, double>(2, 22));
LineCollection.Add(new KeyValuePair<double, double>(2.5, 35));
LineCollection.Add(new KeyValuePair<double, double>(3, 42));
// Primary bars being added
BarCollection.Add(new KeyValuePair<double, double>(1, 10));
BarCollection.Add(new KeyValuePair<double, double>(2, 20));
BarCollection.Add(new KeyValuePair<double, double>(3, 40));
}
/// <summary>
/// Core event handler for the view model.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Routes property changed events.
/// </summary>
/// <param name="propertyName"> Defines the property name upon which routing is determined. </param>
public void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
ObservableCollection<KeyValuePair<double, double>> barCollection = new ObservableCollection<KeyValuePair<double, double>>();
public ObservableCollection<KeyValuePair<double, double>> BarCollection
{
get
{
return barCollection;
}
set
{
barCollection = value;
}
}
ObservableCollection<KeyValuePair<double, double>> lineCollection = new ObservableCollection<KeyValuePair<double, double>>();
public ObservableCollection<KeyValuePair<double, double>> LineCollection
{
get
{
return lineCollection;
}
set
{
lineCollection = value;
}
}
}
谢谢
Buck注意:样本仅包括条形图X值之间的单个数据点。要从线系列中获得平滑曲线,需要更多的数据点。谢谢