* UILineChart:可重载,增加一些函数

This commit is contained in:
Sunny 2020-12-22 20:23:12 +08:00
parent c4e4257128
commit f90a994969
4 changed files with 23 additions and 5 deletions

Binary file not shown.

View File

@ -31,7 +31,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(true)]
public sealed class UILineChart : UIChart
public class UILineChart : UIChart
{
private bool NeedDraw;
@ -41,8 +41,8 @@ namespace Sunny.UI
CalcData();
}
private Point DrawOrigin;
private Size DrawSize;
protected Point DrawOrigin;
protected Size DrawSize;
protected override void CalcData()
{
@ -67,8 +67,8 @@ namespace Sunny.UI
NeedDraw = true;
}
private UIScale XScale;
private UIScale YScale;
protected UIScale XScale;
protected UIScale YScale;
private double[] YLabels;
private double[] XLabels;
@ -160,6 +160,12 @@ namespace Sunny.UI
DrawSeries(g);
// if (BarOption.ToolTip != null && BarOption.ToolTip.AxisPointer.Type == UIAxisPointerType.Line) DrawToolTip(g);
DrawLegend(g, Option.Legend);
DrawOther(g);
}
protected virtual void DrawOther(Graphics g)
{
}
private void DrawAxis(Graphics g)

View File

@ -47,6 +47,8 @@ namespace Sunny.UI
public UILeftAlignment Left { get; set; } = UILeftAlignment.Left;
public float Size { get; set; } = 1.0f;
public object Tag { get; set; }
}
public class UILegend

View File

@ -56,11 +56,21 @@ namespace Sunny.UI
return origin + (float)((value - _min) * 1.0f * width / (_max - _min));
}
public double CalcXPos(double value, int origin, int width)
{
return (float)(_min + (value - origin) * (_max - _min) * 1.0f / width);
}
public float CalcYPixel(double value, int origin, int height)
{
return origin - (float)((value - _min) * 1.0f * height / (_max - _min));
}
public double CalcYPos(double value, int origin, int height)
{
return (float)(_min + (origin - value) * (_max - _min) * 1.0f / height);
}
public float[] CalcXPixels(double[] labels, int origin, int width)
{
if (labels == null) return null;