关于 syncfusion-wpf-smith-chart
用于实现 Syncfusion WPF SfSmithChart 的技能,面向需要可视化传输线阻抗或导纳数据的工程应用。内容涵盖图表设置、数据系列、坐标轴、样式和交互功能。
主要功能
- 01绘制电阻与电抗数据
- 02配置线系列、标记和标签
- 03切换阻抗与导纳模式
- 04自定义坐标轴、调色板和图例
- 05添加工具提示和动画
适用场景
- 01可视化传输线阻抗
- 02比较多个传输线数据系列
- 03通过标签和工具提示检查数据点
- 04渲染导纳数据
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ syncfusion/ wpf-ui-components-skills --skill syncfusion-wpf-smith-chart安装后在 Claude Code 中输入/syncfusion-wpf-smith-chart确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/axes-configuration.mddata-markers-and-labels.mdgetting-started.mdlegend-and-appearance.mdrendering-and-interactions.mdseries-configuration.md详细介绍
实现 Syncfusion WPF SmithCharts
何时使用此技能
当用户需要执行以下操作时,立即使用此技能:
- 实现 Syncfusion WPF SmithChart(SfSmithChart)组件
- 可视化传输线的阻抗或导纳数据
- 为高频电路应用创建图表
- 使用电阻(水平)轴和电抗(径向)轴绘制数据
- 添加带有数据标记和标签的折线系列
- 配置双轴系统(电阻和电抗)
- 自定义图表的外观、调色板和主题
- 实现工具提示等交互功能
- 在阻抗和导纳渲染类型之间切换
- 使用多个系列可视化时配置图例
- 处理传输线数据可视化
组件概述
SfSmithChart 是专为高频电路应用设计的数据可视化组件。它使用两组圆形来绘制传输线参数,分别表示归一化电阻值和电抗值。
主要功能:
- 双轴系统:水平(电阻)轴和径向(电抗)轴
- 折线系列可视化:使用可自定义的折线系列绘制数据
- 数据标记:支持多种标记形状和自定义模板
- 数据标签:自动定位标签并检测冲突
- 交互式图例:切换系列可见性,支持多种定位选项
- 两种渲染模式:阻抗(默认)和导纳
- 丰富的自定义选项:调色板、颜色、网格线和轴样式
- 工具提示:支持自定义模板的交互式工具提示
- 动画支持:平滑的系列动画
文档与导航指南
入门与安装
📄 阅读: references/getting-started.md
用户需要执行以下操作时,请阅读此文档:
- 安装和设置 SmithChart 组件
- 通过 XAML 或代码隐藏创建 SmithChart
- 添加程序集引用(Syncfusion.SfSmithChart.WPF)
- 使用基本配置初始化图表
- 为传输线数据创建数据模型
- 添加标题、坐标轴、系列和图例
- 应用主题(SfSkinManager)
- 查看完整的可运行示例
系列配置
📄 阅读: references/series-configuration.md
用户需要执行以下操作时,请阅读此文档:
- 配置 LineSeries 以可视化数据
- 设置数据绑定(ItemsSource、ResistancePath、ReactancePath)
- 自定义系列外观(Interior、StrokeThickness)
- 启用系列动画(EnableAnimation、AnimationDuration)
- 以编程方式控制系列可见性
- 在一个图表中处理多个系列
- 自定义数据绘制顺序(ArrangeByIndex)
- 应用系列专属调色板
坐标轴配置
📄 阅读: references/axes-configuration.md
用户需要执行以下操作时,请阅读此文档:
- 配置水平轴(电阻)属性
- 配置径向轴(电抗)属性
- 自定义主网格线和次网格线
- 控制网格线的可见性和数量
- 设置坐标轴线和网格线样式
- 定位坐标轴标签(Inside/Outside)
- 处理标签交叉和重叠
- 响应坐标轴标签事件(LabelCreated)
数据标记和标签
📄 阅读: references/data-markers-and-labels.md
用户需要执行以下操作时,请阅读此文档:
- 为数据点添加标记(ShowMarker、MarkerType)
- 使用内置标记形状(Circle、Rectangle、Diamond 等)
- 自定义标记大小、颜色和描边
- 创建自定义标记模板
- 启用数据标签(ShowLabel)
- 处理标签的自动定位和冲突检测
- 设置数据标签样式(LabelStyle)
- 创建自定义标签模板(LabelTemplate)
图例和外观
📄 阅读: references/legend-and-appearance.md
在用户需要以下操作时阅读:
- 添加和配置图表图例
- 设置图例位置(停靠或浮动)
- 自定义图例图标和外观
- 通过图例切换系列可见性
- 应用调色板(Metro、BlueChrome 等)
- 自定义图表区域(Background、BorderBrush)
- 设置系列专属调色板
- 控制圆的半径
- 获取图表属性(AreaBounds、CenterPoint、Radius)
- 设置图例项样式(FontSize、颜色、间距)
渲染类型和用户交互
📄 阅读: references/rendering-and-interactions.md
在用户需要以下操作时阅读:
- 了解阻抗与导纳渲染的区别
- 切换渲染类型(RenderingType 属性)
- 为数据点启用工具提示(ShowToolTip)
- 配置工具提示持续时间
- 创建自定义工具提示模板
- 实现交互功能
快速入门示例
下面是一个简洁示例,用于创建带有传输线数据的可用 SmithChart:
XAML 方式
<Window xmlns:syncfusion="clr-namespace:Syncfusion.UI.Xaml.SmithChart;assembly=Syncfusion.SfSmithChart.WPF">
<Grid>
<syncfusion:SfSmithChart Header="Impedance Transmission" Height="400" Width="500">
<syncfusion:LineSeries ResistancePath="Resistance"
ReactancePath="Reactance"
ItemsSource="{Binding Data}"
Label="TransmissionLine"
ShowMarker="True">
</syncfusion:LineSeries>
<syncfusion:SfSmithChart.HorizontalAxis>
<syncfusion:HorizontalAxis FontSize="11"/>
</syncfusion:SfSmithChart.HorizontalAxis>
<syncfusion:SfSmithChart.RadialAxis>
<syncfusion:RadialAxis FontSize="11"/>
</syncfusion:SfSmithChart.RadialAxis>
<syncfusion:SfSmithChart.Legend>
<syncfusion:SmithChartLegend/>
</syncfusion:SfSmithChart.Legend>
</syncfusion:SfSmithChart>
</Grid>
</Window>
代码隐藏方式
using Syncfusion.UI.Xaml.SmithChart;
// Create SmithChart
SfSmithChart chart = new SfSmithChart();
chart.Header = "Impedance Transmission";
// Configure axes
chart.HorizontalAxis = new HorizontalAxis { FontSize = 11 };
chart.RadialAxis = new RadialAxis { FontSize = 11 };
// Add series
LineSeries series = new LineSeries
{
ItemsSource = Data,
ResistancePath = "Resistance",
ReactancePath = "Reactance",
Label = "TransmissionLine",
ShowMarker = true
};
chart.Series.Add(series);
// Add legend
chart.Legend = new SmithChartLegend();
// Add to layout
this.Content = chart;
数据模型
public class TransmissionData
{
public double Resistance { get; set; }
public double Reactance { get; set; }
}
// Sample data
ObservableCollection<TransmissionData> Data = new ObservableCollection<TransmissionData>
{
new TransmissionData { Resistance = 0, Reactance = 0.05 },
new TransmissionData { Resistance = 0.3, Reactance = 0.1 },
new TransmissionData { Resistance = 1.0, Reactance = 0.4 },
new TransmissionData { Resistance = 2.0, Reactance = 0.5 }
};
常见模式
模式 1:多个系列对比
// Add multiple series for comparison
LineSeries series1 = new LineSeries
{
ItemsSource = Data1,
ResistancePath = "Resistance",
ReactancePath = "Reactance",
Label = "Transmission-1",
ShowMarker = true
};
LineSeries series2 = new LineSeries
{
ItemsSource = Data2,
ResistancePath = "Resistance",
ReactancePath = "Reactance",
Label = "Transmission-2",
ShowMarker = true,
Interior = new SolidColorBrush(Colors.Orange)
};
chart.Series.Add(series1);
chart.Series.Add(series2);
模式 2:增强视觉反馈
// Series with markers, labels, and tooltip
LineSeries series = new LineSeries
{
ShowMarker = true,
MarkerType = MarkerType.Circle,
MarkerHeight = 10,
MarkerWidth = 10,
ShowToolTip = true,
ToolTipDuration = TimeSpan.FromSeconds(3),
StrokeThickness = 2,
EnableAnimation = true,
AnimationDuration = TimeSpan.FromSeconds(1)
};
series.DataLabel.ShowLabel = true;
模式 3:自定义外观
// Apply custom palette and styling
chart.ColorModel = new SmithChartColorModel
{
Palette = ColorPalette.BlueChrome
};
chart.Background = new SolidColorBrush(Colors.WhiteSmoke);
chart.ChartAreaBackground = new SolidColorBrush(Colors.White);
chart.ChartAreaBorderBrush = new SolidColorBrush(Colors.Gray);
chart.ChartAreaBorderThickness = new Thickness(1);
chart.Radius = 0.9; // 90% of plot area
模式 4:导纳渲染
// Switch to Admittance mode for different visualization
chart.RenderingType = RenderingType.Admittance;
// Data is now rendered from left to right
关键属性
SfSmithChart 核心属性
| 属性 | 类型 | 描述 |
|---|---|---|
Header | object | 图表标题/标题文本 |
HorizontalAxis | HorizontalAxis | 电阻轴配置 |
RadialAxis | RadialAxis | 电抗轴配置 |
Series | ObservableCollection | 图表系列集合 |
Legend | SmithChartLegend | 图例配置 |
RenderingType | RenderingType | 阻抗或导纳模式 |
Radius | double | 图表圆半径(0.1 到 1) |
ColorModel | SmithChartColorModel | 调色板和颜色设置 |
ChartAreaBackground | Brush | 图表绘图区背景 |
LineSeries 关键属性
| 属性 | 类型 | 描述 |
|---|---|---|
ItemsSource | IEnumerable | 系列的数据源 |
ResistancePath | string | 电阻值的属性路径 |
ReactancePath | string | 电抗值的属性路径 |
Label | string | 系列名称(显示在图例中) |
Interior | Brush | 线条颜色 |
StrokeThickness | double | 线条粗细 |
ShowMarker | bool | 在数据点处显示标记 |
MarkerType | MarkerType | 标记形状(圆形、矩形等) |
ShowToolTip | bool | 启用悬停工具提示 |
EnableAnimation | bool | 加载时为系列添加动画 |
IsSeriesVisible | bool | 显示/隐藏系列 |
轴的通用属性
| 属性 | 类型 | 描述 |
|---|---|---|
ShowMajorGridlines | bool | 显示主要网格线 |
ShowMinorGridlines | bool | 显示次要网格线 |
MinorGridlinesCount | int | 次要网格线数量(默认值:8) |
MajorGridlineStyle | Style | 主要网格线样式 |
MinorGridlineStyle | Style | 次要网格线样式 |
ShowAxisLine | bool | 显示轴线 |
AxisLineStyle | Style | 轴线样式 |
LabelPlacement | LabelPlacement | 标签位置(内部或外部) |
LabelIntersectAction | LabelIntersectActions | 处理标签重叠(隐藏/无) |
常见用例
用例 1:基本传输线可视化
目标:显示传输线的阻抗数据
方法:
- 创建包含 Resistance 和 Reactance 属性的数据模型
- 设置带标题的基本 SmithChart
- 添加绑定数据的 LineSeries
- 配置两个轴
- 添加图例以供参考
参考: 请参阅 getting-started.md
用例 2:比较多条传输线
目标:比较不同传输线的阻抗特性
方法:
- 添加多个具有不同 ItemsSource 的 LineSeries
- 为每个系列分配唯一的 Label
- 使用不同的 Interior 颜色加以区分
- 启用图例以识别系列
- 可考虑使用标记以提高清晰度
参考:请参阅 series-configuration.md 和 legend-and-appearance.md
用例 3:详细分析数据点
目标:提供每个数据点的详细信息
方法:
- 启用 ShowMarker 以显示数据点
- 启用数据标签(DataLabel.ShowLabel)
- 配置工具提示(ShowToolTip)
- 自定义标记和标签的外观
- 可考虑使用自定义模板展示专用信息
参考:请参阅 data-markers-and-labels.md 和 rendering-and-interactions.md
用例 4:导纳分析
目标:可视化导纳而非阻抗
方法:
- 将 RenderingType 设置为 Admittance
- 数据会自动从左向右渲染
- 坐标轴标签会自动调整
- 其他所有功能均可继续使用
参考:请参阅 rendering-and-interactions.md
用例 5:专业报告可视化
目标:创建带有自定义品牌标识、可用于出版物的 SmithChart
方法:
- 应用自定义 ColorModel 调色板
- 自定义图表区域和背景颜色
- 使用自定义网格线样式设置坐标轴
- 使用自定义图标配置图例
- 调整 Radius 以获得最佳尺寸
- 使用 SfSkinManager 应用主题
参考:请参阅 legend-and-appearance.md 和 getting-started.md
边缘情况与故障排除
程序集引用问题
- 确保已正确引用 Syncfusion.SfSmithChart.WPF 程序集
- 检查 .NET Framework 版本兼容性
- 验证 XAML 中的 xmlns 命名空间声明
未显示数据
- 验证 ItemsSource 是否已正确绑定
- 检查 ResistancePath 和 ReactancePath 是否与属性名称完全匹配
- 确保已设置用于数据绑定的 DataContext
- 验证数据集合不为空
标签重叠
- 使用 LabelIntersectAction 属性控制重叠行为
- ShowLabel 为 true 时,标签会自动重新定位
- 可考虑减少数据点或调整标签模板
大型数据集的性能
- 对已排序的数据使用 ArrangeByIndex = false(默认行为)
- 有选择地启用动画,以改善初始加载效果
- 对超大型数据集可考虑进行数据采样
总结
Syncfusion WPF SmithChart 是一个面向高频电路应用的专用组件,尤其适用于可视化传输线阻抗和导纳数据。它具有双坐标轴系统、丰富的自定义选项和交互功能,适用于工程和科学应用。请始终从入门参考开始完成初始设置,然后根据用例需要探索特定功能。