mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-07 18:20:51 +08:00
35 lines
915 B
C#
35 lines
915 B
C#
using System;
|
|
using System.Windows.Controls;
|
|
using LiveCharts;
|
|
using LiveCharts.Wpf;
|
|
|
|
namespace Wpf.PieChart
|
|
{
|
|
public partial class PieChartExample : UserControl
|
|
{
|
|
public PieChartExample()
|
|
{
|
|
InitializeComponent();
|
|
|
|
PointLabel = chartPoint =>
|
|
string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
|
|
|
|
DataContext = this;
|
|
}
|
|
|
|
public Func<ChartPoint, string> PointLabel { get; set; }
|
|
|
|
private void Chart_OnDataClick(object sender, ChartPoint chartpoint)
|
|
{
|
|
var chart = (LiveCharts.Wpf.PieChart) chartpoint.ChartView;
|
|
|
|
//clear selected slice.
|
|
foreach (PieSeries series in chart.Series)
|
|
series.PushOut = 0;
|
|
|
|
var selectedSeries = (PieSeries) chartpoint.SeriesView;
|
|
selectedSeries.PushOut = 8;
|
|
}
|
|
}
|
|
}
|