如何在WPF图表中获取特定点的值?

时间:2014-02-10 10:17:52

标签: wpf wpf-controls

此图表如何显示特定月份的特定收入。 我正在使用此图表控件 <chartingToolkit:Chart HorizontalAlignment="Left" Margin="10,10,0,0" Name="chart1" VerticalAlignment="Top" Height="348" Width="536" />

System.Windows.Controls.DataVisualization.Charting.LineSeries series = new System.Windows.Controls.DataVisualization.Charting.LineSeries();
        List<KeyValuePair<string, decimal>> valueList = new List<KeyValuePair<string, decimal>>();
        DataTable dtblMain = new DataTable();
        graphSP spGraph = new graphSP();
        dtblMain = spGraph.ViewAllCustomer();
        foreach (DataRow dra in dtblMain.Rows)
        {
            valueList.Add(new KeyValuePair<string, decimal>((string)dra["month"], (decimal)dra["income"]));
        }
        series.DependentValuePath = "Value";
        series.IndependentValuePath = "Key";         
        series.ItemsSource = valueList;
        series.Title = "Monthly Income";
        chart1.Series.Add(series);

0 个答案:

没有答案