前台绑定:
<c1:C1Chart
x:Name="chart"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Data="{Binding ChartData}"
ChartType="LineSymbols" >
<c1:C1ChartLegend/>
<c1:C1Chart.View>
<c1:ChartView>
<c1:ChartView.Layers>
<c1:ChartPanel>
<c1:ChartPanelObject
Attach="DataXY"
Action="MouseMove"
DataPoint="-1,-1"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Width="60" Height="50">
<c1:ChartPanelObject.RenderTransform>
<TranslateTransform Y="-50"/>
</c1:ChartPanelObject.RenderTransform>
<Grid DataContext="{Binding RelativeSource={x:Static RelativeSource.Self},Path=Parent}" Opacity="0.8">
<Path Data="M0.5,0.5 L23,0.5 23,23 11.61165,29.286408 0.5,23 z" Stretch="Fill" Fill="#FFF1F1F1" Stroke="DarkGray" StrokeThickness="1"/>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="{Binding DataPoint.X}" Margin="2 0"/>
<TextBlock x:Name="label2" Text="{Binding DataPoint.Y}" FontWeight="Bold" Margin="2"/>
</StackPanel>
</Grid>
</c1:ChartPanelObject>
</c1:ChartPanel>
</c1:ChartView.Layers>
</c1:ChartView>
</c1:C1Chart.View>
</c1:C1Chart>
后台绑定:
XYDataSeries series = new XYDataSeries()
{
ValueBinding = new System.Windows.Data.Binding("Value"),
XValueBinding = new System.Windows.Data.Binding("TimePoint"),
Label = item,
};
return series;
数据源TimePoint为DateTime类型。
展示图片如下:
控件版本:
|