WPF编程,Live Charts使用说明(20)——饼图

news/2025/3/17 17:18:18/

在这里插入图片描述

后台

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;}}
}

前台

<UserControl x:Class="Wpf.PieChart.PieChartExample"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Wpf.PieChart"xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500" d:DataContext="{d:DesignInstance local:PieChartExample}"><Grid><lvc:PieChart LegendLocation="Bottom" DataClick="Chart_OnDataClick" Hoverable="False" DataTooltip="{x:Null}"><lvc:PieChart.Series><lvc:PieSeries Title="Maria" Values="3" DataLabels="True"LabelPoint="{Binding PointLabel}"/><lvc:PieSeries Title="Charles" Values="4" DataLabels="True" LabelPoint="{Binding PointLabel}"/><lvc:PieSeries Title="Frida" Values="6" DataLabels="True" LabelPoint="{Binding PointLabel}"/><lvc:PieSeries Title="Frederic" Values="2" DataLabels="True" LabelPoint="{Binding PointLabel}"/></lvc:PieChart.Series></lvc:PieChart>  </Grid>
</UserControl>

http://www.ppmy.cn/news/488385.html

相关文章

自定义LiveCD

目录 为什么要自定义LiveCD如何自定义Ubuntu Desktop CD系统要求安装预先安排获得基本系统 提取CD .iso内容解压缩桌面系统准备和chroot自定义 易于 先决条件任务GNOME的自定义背景更改gconf值&#xff08;字体&#xff0c;面板等&#xff09; 进行几次gconf更改设置区域默认…

Live2D看板娘详细实现

Live2D看板娘实现 国际惯例先上图&#xff1a; 所需资源&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/1s7IJIqGnn-cNRAfoS-qG5w 提取码&#xff1a;dhf4 其中包含了看板娘所需的CSS&#xff0c;image,JS,Live2d所需的基本资源。 下面就来实现吧 开发工具ideato…

使用Open Live Writer配置CSDN及http500错误的解决

原贴地址连接:http://blog.csdn.net/qq_31105447/article/details/53468689 背景 作为一个菜鸟&#xff0c;了解到的信息总是非常滞后的。之前将博客园与Open Live Writer关联起来&#xff0c;发现在对博文的排版等变得很是便捷了。因此我就去查找CSDN是否支持Open Live Writer…

直播获奖(live)

题目描述&#xff1a; NOI2130 即将举行。为了增加观赏性&#xff0c;CCF决定逐一评出每个选手的成绩&#xff0c;并直播即时的获奖分数线。本次竞赛的获奖率为w%&#xff0c;即当前排名前w%的选手的最低成绩就是即时的分数线。 更具体地&#xff0c;若当前已评出了p个选手的…

OceanBase—02(入门篇——使用obd安装OceanBase的几种方式)

OceanBase—02&#xff08;入门篇——使用obd安装OceanBase的几种方式&#xff09; 1. 一键部署1.1 下载并安装 all-in-one 安装包1.2 单机部署 OceanBase 数据库1.2.1 部署命令 1.3 使用 OBClient 客户端连接 OceanBase 数据库1.3.1 两种连接方式1.3.2 遇到的问题1.3.2.1 通过…

live555 source

Source和Sink&#xff1a;可以把source理解为发送端的流&#xff0c;sink理解为接受端。MediaSink是各种类型的Sink的基类&#xff0c;MediaSource是各种类型Source的基类&#xff0c;各种类型的流媒体格式和编码的支持即是通过对这两个类的派生实现的。Source和Sink通过RTP子会…

WPF使用Live Chart之动态更新数据

WPF使用Live Chart之动态更新数据 效果如下&#xff1a; 前台代码&#xff1a; <Window x:Class"Chapter3.MainWindow"xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x"http://schemas.microsoft.com/winfx/2006/xam…

live555源码分析(五)DESCRIBE请求的处理

live555源码分析系列 live555源码分析&#xff08;一&#xff09;live555初体验 live555源码分析&#xff08;二&#xff09;基本组件上 live555源码分析&#xff08;三&#xff09;基本组件下 live555源码分析&#xff08;四&#xff09;RTSPServer分析 live555源码分析&…