本文整理汇总了C#中System.Windows.Controls.DataVisualization.Charting.Chart.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.SetValue方法的具体用法?C# Chart.SetValue怎么用?C# Chart.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.DataVisualization.Charting.Chart
的用法示例。
在下文中一共展示了Chart.SetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: service_GetGroupDataCompleted
private void service_GetGroupDataCompleted(object sender, GetGroupDataCompletedEventArgs e)
{
this.Busy.IsBusy = false;
if (e.Error != null)
{
e.Error.ShowError();
return;
}
if (e.Result != null)
{
ListChartTab.Tag = e.Result.ToList();
var data = e.Result.ToList();
foreach (var group in data)
{
//没数据的就不用显示了
var groupItems = group.GroupItems.Where(i => i.Values.Count > 0).ToList();
var scroll = new ScrollViewer()
{
};
var tab = new TabItem
{
Header = group.TableName,
Tag = group.TableName,
};
var grid = new Grid();
var chartWidth = (this.ListChartTab.Width - 50) / 2;
var chartHeight = 300;
//最大列索引
var maxColumnIndex = Math.Floor(ListChartTab.Width / chartWidth);
//最大行索引
var maxRowIndex = ((groupItems.Count % maxColumnIndex == 0 ? 0 : (maxColumnIndex - groupItems.Count % maxColumnIndex))
+ groupItems.Count) / maxColumnIndex;
//初始化表格布局控件
for (int j = 0; j < maxRowIndex; j++)
{
RowDefinition rd = new RowDefinition();
rd.Height = new GridLength(chartHeight);
grid.RowDefinitions.Add(rd);
}
for (int j = 0; j < maxColumnIndex; j++)
{
ColumnDefinition cd = new ColumnDefinition();
cd.Width = new GridLength(chartWidth);
grid.ColumnDefinitions.Add(cd);
}
var rowIndex = 0;
var columnIndex = 0;
foreach (var groupItem in groupItems)
{
var chart = new Chart()
{
Margin = new Thickness(10)
};
//把图表放置到相应的单元格中
chart.SetValue(Grid.ColumnProperty, columnIndex);
chart.SetValue(Grid.RowProperty, rowIndex);
if (columnIndex < maxColumnIndex - 1)
{
columnIndex++;
}
else
{
columnIndex = 0;
rowIndex++;
}
var ps = new PieSeries();
ps.ItemsSource = CombineData(groupItem.Values, 10);
ps.IsSelectionEnabled = true;
ps.IndependentValuePath = "Key";
ps.DependentValuePath = "Value";
ps.AnimationSequence = AnimationSequence.Simultaneous;
ps.SelectionChanged += new SelectionChangedEventHandler(ps_SelectionChanged);
chart.Title = groupItem.DisplayName;
if (!string.IsNullOrEmpty(groupItem.Description))
chart.Title += string.Format(" ({0})", groupItem.Description);
chart.Series.Add(ps);
grid.Children.Add(chart);
}
//滚动控件中包含表格布局
scroll.Content = grid;
//tab页中包含滚动控件
tab.Content = scroll;
//tab页容器中包含tab页
ListChartTab.Items.Add(tab);
if (!string.IsNullOrEmpty(SearchCondition.SelectedTableName) && group.TableName == SearchCondition.SelectedTableName)
tab.IsSelected = true;
}
}
}