我在axisCanvas中画了个矩形
如图:
为什么矩形边框的粗细与坐标轴的不一致呢?
代码为
private ChartPanel cp = new ChartPanel();
//......
if (c1Chart.Data.Children.Count > 0)
{
cp.Children.Clear();
var obj = new ChartPanelObject();
var rect = c1Chart.View.AxisX.GetAxisRect();
Rectangle rectangle = new Rectangle();//矩形对象
//属性设置,填充颜色、边粗细、边颜色、宽、高等
rectangle.StrokeThickness = c1Chart.View.AxisX.AxisLine.StrokeThickness;
rectangle.Stroke = c1Chart.View.AxisX.AxisLine.Stroke;
rectangle.Width = rect.Width;
rectangle.Height = rect.Height;
//矩形对象相对于父容器对象Canvas的位置,左边距、上边距
Canvas.SetLeft(rectangle, 0);
Canvas.SetTop(rectangle, 0);
obj.Content = rectangle;
obj.Action = ChartPanelAction.None;
cp.Children.Add(obj);
if (c1Chart.View.Layers.Contains(cp) == false)
c1Chart.View.Layers.Add(cp);
cp.SetValue(Canvas.LeftProperty, rect.Left);
cp.SetValue(Canvas.TopProperty, rect.Top);
cp.Height = rect.Height;
cp.Width = rect.Width;
}
} |