父元素设置了圆角,但是子元素没有设置圆角,子元素的直角遮挡了父元素的圆角

博客给出一个解决办法,即在父元素上添加overflow:auto来解决相关问题,属于前端开发领域的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决办法:在父元素上添加 overflow:auto

// 创建 CartesianChart var cartesianChart = new LiveCharts.Wpf.CartesianChart { Height = 65, // 设置高度 // Width=100 }; // 初始化数据 var seriesCollection = new LiveCharts.SeriesCollection(); var style = new Style(typeof(ColumnSeries)); style.Setters.Add(new Setter(ColumnSeries.FillProperty, new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 120, 215)))); style.Setters.Add(new Setter(ColumnSeries.StrokeProperty, new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 120, 215)))); style.Setters.Add(new Setter(ColumnSeries.StrokeThicknessProperty, 0.0)); style.Setters.Add(new Setter(ColumnSeries.ClipProperty, new RectangleGeometry(new Rect(0, 0, double.PositiveInfinity, 30), 15, 15))); // 添加进度条数据 var progressSeries1 = new RoundedRowSeries { Values = new ChartValues<double> { value }, // 进度值(0-100) Fill = color, // 设置进度条颜色 Stroke = System.Windows.Media.Brushes.Red, PointGeometry = DefaultGeometries.Circle, DataLabels = true, // 显示数据标签 LabelPoint = point => $"{value}%", // 显示进度百分比 FontSize = 15, Foreground = System.Windows.Media.Brushes.White, RowPadding = 5, CornerRadius = 28f, }; // 将进度条添加到 SeriesCollection seriesCollection.Add(progressSeries1); // 绑定数据到图表 cartesianChart.Series = seriesCollection; // 隐藏 X 轴和 Y 轴 cartesianChart.AxisX.Clear(); cartesianChart.AxisY.Clear(); cartesianChart.AxisX.Add(new LiveCharts.Wpf.Axis { IsEnabled = false, // 隐藏 X 轴 MinValue = 0, MaxValue = 100, Labels = new List<string>(), // 设置为空列表以清除所有标签 Separator = new LiveCharts.Wpf.Separator // 设置网格线 { StrokeThickness = 0, // 网格线宽度为 0(隐藏网格线) IsEnabled = false // 禁用网格线 } }); var Name = new List<string> { title }; cartesianChart.AxisY.Add(new LiveCharts.Wpf.Axis { Labels = Name, FontSize = 15, Foreground = System.Windows.Media.Brushes.White, Separator = new LiveCharts.Wpf.Separator // 设置网格线 { StrokeThickness = 0, // 网格线宽度为 0(隐藏网格线) IsEnabled = false // 禁用网格线 }, Position = AxisPosition.LeftBottom, LabelsRotation = 0, // 名称水平显示 }); cartesianChart.VisualElements.Add(new VisualElement { X = 0, Y = 0, UIElement = new System.Windows.Shapes.Rectangle { Width = 800, Height = 200, RadiusX = 50, // 圆角半径 RadiusY = 50, Fill = System.Windows.Media.Brushes.Red, // 背景颜色 Stroke = System.Windows.Media.Brushes.Gray, StrokeThickness = 10 } }); return cartesianChart; 如何让 水平柱状图 为圆角显示
04-02
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值