绘制任意维度的矩形 [英] Charting Rectangles of arbitrary dimensions
问题描述
我需要在 C# 应用程序中绘制不同高度和宽度的矩形.矩形可以重叠也可以不重叠.
I need to graph rectangles of different heights and widths in a C# application. The rectangles may or may not overlap.
我认为 System.Windows.Forms.DataVisualization.Charting
可以满足我的需求,但我探索过的每种图表类型都希望数据点由一维中的单个值和多个值组成在另一个.
I thought the System.Windows.Forms.DataVisualization.Charting
would have what I need, but every chart type I've explored wants data points composed of a single value in one dimension and multiple values in the other.
我考虑过:框、气泡和范围条
.
推荐答案
事实证明,Richard Eriksson 给出了最接近的答案,因为 Charting 包不包含我需要的内容.我正在推进的解决方案是使用点图来管理轴等,但重载 PostPaint 事件以有效地在顶部绘制我需要的矩形.图表提供了从价值到像素(反之亦然)的转换.
It turns out that Richard Eriksson has the closest answer in that the Charting package doesn't contain what I needed. The solution I'm moving forward with is to use a Point chart to manage axes and whatnot, but overload the PostPaint event to effectively draw the rectangles I need on top. The Chart provides value-to-pixel (and vice versa) conversions.
这篇关于绘制任意维度的矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!