DotNet 4.8.1 build of DotNetBar
This commit is contained in:
303
PROMS/DotNetBar Source Code/MicroCharts/AreaMicroChart.cs
Normal file
303
PROMS/DotNetBar Source Code/MicroCharts/AreaMicroChart.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class AreaMicroChart : MicroChartBase
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int pointRadius = Dpi.Width(PointRadius);
|
||||
int chartHeight = info.ChartHeight - pointRadius * 2;
|
||||
int chartWidth = info.ChartWidth - pointRadius * 2;
|
||||
|
||||
int drawStep = Math.Max(3, (chartWidth / (Math.Max(1, info.DataPoints.Count - 1))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
int x = pointRadius;
|
||||
double dataPointMinValue = info.DataPointMinValue;
|
||||
|
||||
double zeroValue = _MicroChartStyle.ZeroLineValue;
|
||||
if (dataPointMinValue > zeroValue)
|
||||
dataPointMinValue = zeroValue;
|
||||
|
||||
double range = info.DataPointMaxValue - dataPointMinValue;
|
||||
if (range == 0) range = 1;
|
||||
int zeroY = Math.Min((int)(chartHeight * (1 - (zeroValue - dataPointMinValue) / range)), chartHeight - 1) + pointRadius;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
Point[] chartPoints = new Point[totalPoints];
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int index = 0;
|
||||
GraphicsPath areaPath = new GraphicsPath();
|
||||
Point lastPoint = new Point(0, zeroY);
|
||||
Point lowPoint = Point.Empty, highPoint = Point.Empty;
|
||||
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
double nextValue = (i < (info.DataPoints.Count - 1)) ? info.DataPoints[i + 1] : zeroValue;
|
||||
Point p = new Point(x, Math.Min((int)(chartHeight * (1 - (value - dataPointMinValue) / range)), chartHeight - 1) + pointRadius);
|
||||
Point endPoint = new Point(x + drawStep, Math.Min((int)(chartHeight * (1 - (nextValue - dataPointMinValue) / range)), chartHeight - 1));
|
||||
|
||||
if (lowPoint.IsEmpty && value == info.DataPointMinValue)
|
||||
lowPoint = p;
|
||||
else if (/*highPoint.IsEmpty &&*/ value == info.DataPointMaxValue)
|
||||
highPoint = p;
|
||||
|
||||
chartPoints[index] = p;
|
||||
|
||||
if (i + dataStep >= info.DataPoints.Count)
|
||||
areaPath.AddPolygon(new Point[] { new Point(x, zeroY), p, endPoint, new Point(chartWidth, endPoint.Y), new Point(chartWidth, zeroY) });
|
||||
else
|
||||
areaPath.AddPolygon(new Point[] { new Point(x, zeroY), p, endPoint, new Point(endPoint.X, zeroY) });
|
||||
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(p, info), new Rectangle(p.X - drawStep / 2, 0, endPoint.X - p.X, chartHeight), Color.Gray /*_MicroChartStyle.LineColor*/, value, index);
|
||||
index++;
|
||||
x += drawStep;
|
||||
}
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.AreaColor))
|
||||
graphics.FillPath(brush, areaPath);
|
||||
areaPath.Dispose();
|
||||
|
||||
if (!lowPoint.IsEmpty && !_MicroChartStyle.LowPointColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.LowPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(lowPoint));
|
||||
}
|
||||
|
||||
if (!highPoint.IsEmpty && !_MicroChartStyle.HighPointColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.HighPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(highPoint));
|
||||
}
|
||||
|
||||
if (!_MicroChartStyle.FirstPointColor.IsEmpty && chartPoints.Length > 0)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.FirstPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[0]));
|
||||
}
|
||||
|
||||
if (!_MicroChartStyle.LastPointColor.IsEmpty && chartPoints.Length > 1)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.LastPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[chartPoints.Length - 1]));
|
||||
}
|
||||
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
|
||||
}
|
||||
private static int HotPointOffset
|
||||
{
|
||||
get { return Dpi.Width4; }
|
||||
}
|
||||
private Rectangle GetHotPointBounds(Point hotPoint, MicroChartRenderInfo info)
|
||||
{
|
||||
//Rectangle bounds = new Rectangle(Math.Min(info.ChartWidth - HotPointOffset * 2, Math.Max(-1, hotPoint.X - HotPointOffset)),
|
||||
// Math.Min(info.ChartHeight - HotPointOffset * 2, Math.Max(-1, hotPoint.Y - HotPointOffset)),
|
||||
// HotPointOffset * 2,
|
||||
// HotPointOffset * 2);
|
||||
Rectangle bounds = new Rectangle(hotPoint.X - HotPointOffset,
|
||||
hotPoint.Y - HotPointOffset,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private AreaMicroChartStyle _MicroChartStyle;
|
||||
public AreaMicroChartStyle Style
|
||||
{
|
||||
get { return _MicroChartStyle; }
|
||||
set { _MicroChartStyle = value; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the style for Area micro chart.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class AreaMicroChartStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AreaMicroChartStyle class.
|
||||
/// </summary>
|
||||
public AreaMicroChartStyle()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
private double _ZeroLineValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the zero line, i.e. where zero line is drawn. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Category("Appearance"), Description("Indicates value of the zero line, i.e. where zero line is drawn.")]
|
||||
public double ZeroLineValue
|
||||
{
|
||||
get { return _ZeroLineValue; }
|
||||
set
|
||||
{
|
||||
_ZeroLineValue = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _AreaColor = ColorScheme.GetColor(0x938953);
|
||||
/// <summary>
|
||||
/// Gets or sets the chart area color.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates chart area color.")]
|
||||
public Color AreaColor
|
||||
{
|
||||
get { return _AreaColor; }
|
||||
set { _AreaColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeAreaColor()
|
||||
{
|
||||
return _AreaColor != ColorScheme.GetColor(0x938953);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetAreaColor()
|
||||
{
|
||||
this.AreaColor = ColorScheme.GetColor(0x938953);
|
||||
}
|
||||
|
||||
private Color _HighPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the high point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of high point dot on chart..")]
|
||||
public Color HighPointColor
|
||||
{
|
||||
get { return _HighPointColor; }
|
||||
set { _HighPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeHighPointColor()
|
||||
{
|
||||
return !_HighPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHighPointColor()
|
||||
{
|
||||
this.HighPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LowPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the low point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of low point dot on chart.")]
|
||||
public Color LowPointColor
|
||||
{
|
||||
get { return _LowPointColor; }
|
||||
set { _LowPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLowPointColor()
|
||||
{
|
||||
return !_LowPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLowPointColor()
|
||||
{
|
||||
this.LowPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _FirstPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the first point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of first point dot on chart..")]
|
||||
public Color FirstPointColor
|
||||
{
|
||||
get { return _FirstPointColor; }
|
||||
set { _FirstPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeFirstPointColor()
|
||||
{
|
||||
return !_FirstPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetFirstPointColor()
|
||||
{
|
||||
this.FirstPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LastPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the last point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of last point dot on chart.")]
|
||||
public Color LastPointColor
|
||||
{
|
||||
get { return _LastPointColor; }
|
||||
set { _LastPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLastPointColor()
|
||||
{
|
||||
return !_LastPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLastPointColor()
|
||||
{
|
||||
this.LastPointColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
41
PROMS/DotNetBar Source Code/MicroCharts/BarBaseMicroChart.cs
Normal file
41
PROMS/DotNetBar Source Code/MicroCharts/BarBaseMicroChart.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal abstract class BarBaseMicroChart : MicroChartBase
|
||||
{
|
||||
internal static int HotPointOffset
|
||||
{
|
||||
get { return Dpi.Width4; }
|
||||
}
|
||||
protected virtual Rectangle GetHotPointBounds(Rectangle barBounds, bool isPositiveValue)
|
||||
{
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (isPositiveValue)
|
||||
{
|
||||
bounds = new Rectangle(barBounds.X + (barBounds.Width - HotPointOffset * 2) / 2,
|
||||
barBounds.Y - HotPointOffset,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds = new Rectangle(barBounds.X + (barBounds.Width - HotPointOffset * 2) / 2,
|
||||
barBounds.Bottom - HotPointOffset,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private BarMicroChartStyle _Style;
|
||||
public virtual BarMicroChartStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set { _Style = value; }
|
||||
}
|
||||
}
|
||||
}
|
104
PROMS/DotNetBar Source Code/MicroCharts/BarMicroChart.cs
Normal file
104
PROMS/DotNetBar Source Code/MicroCharts/BarMicroChart.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class BarMicroChart : BarBaseMicroChart
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int chartHeight = info.ChartHeight;
|
||||
int chartWidth = info.ChartWidth;
|
||||
|
||||
BarMicroChartStyle style = this.Style;
|
||||
int drawStep = Math.Max(style.MinBarSize, (chartHeight / (Math.Max(1, info.DataPoints.Count))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * (drawStep + 1)) / chartHeight));
|
||||
int y = 0;
|
||||
double dataPointMinValue = info.DataPointMinValue;
|
||||
|
||||
if (dataPointMinValue > style.ZeroLineValue)
|
||||
dataPointMinValue = style.ZeroLineValue;
|
||||
|
||||
double range = info.DataPointMaxValue - dataPointMinValue;
|
||||
if (range == 0) range = 1;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int index = 0;
|
||||
int zeroX = Math.Min((int)(chartWidth * (1 - (style.ZeroLineValue - dataPointMinValue) / range)), chartWidth);
|
||||
|
||||
System.Drawing.Drawing2D.SmoothingMode smoothingMode = graphics.SmoothingMode;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
|
||||
using (SolidBrush positiveBarBrush = new SolidBrush(style.PositiveBarColor))
|
||||
{
|
||||
using (SolidBrush negativeBarBrush = new SolidBrush(style.NegativeBarColor))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
int x = Math.Min((int)(chartWidth * (1 - (value - dataPointMinValue) / range)), chartWidth - 1);
|
||||
Rectangle barBounds = Rectangle.Empty;
|
||||
if (value > style.ZeroLineValue)
|
||||
{
|
||||
if (zeroX == chartWidth && x == zeroX) x--;
|
||||
barBounds = new Rectangle(x, y, Math.Max(1, zeroX - x), drawStep);
|
||||
|
||||
if (value == info.DataPointMaxValue && !style.HighPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.HighPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(positiveBarBrush, barBounds);
|
||||
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, true), new Rectangle(0, barBounds.Y, chartWidth, barBounds.Height), style.PositiveBarColor, value, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
barBounds = new Rectangle(zeroX, y, Math.Max(1, x - zeroX), drawStep);
|
||||
|
||||
if (value == info.DataPointMinValue && !style.LowPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.LowPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(negativeBarBrush, barBounds);
|
||||
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, false), new Rectangle(0, barBounds.Y, chartWidth, barBounds.Height), style.NegativeBarColor, value, index);
|
||||
}
|
||||
|
||||
index++;
|
||||
y += drawStep + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
graphics.SmoothingMode = smoothingMode;
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
}
|
||||
|
||||
protected override Rectangle GetHotPointBounds(Rectangle barBounds, bool isPositiveValue)
|
||||
{
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (isPositiveValue)
|
||||
{
|
||||
bounds = new Rectangle(barBounds.X - HotPointOffset,
|
||||
barBounds.Y + (barBounds.Height - HotPointOffset * 2) / 2,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds = new Rectangle(barBounds.Right - HotPointOffset,
|
||||
barBounds.Y + (barBounds.Height - HotPointOffset * 2) / 2,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
}
|
262
PROMS/DotNetBar Source Code/MicroCharts/ColumnMicroChart.cs
Normal file
262
PROMS/DotNetBar Source Code/MicroCharts/ColumnMicroChart.cs
Normal file
@@ -0,0 +1,262 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class ColumnMicroChart : BarBaseMicroChart
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int chartHeight = info.ChartHeight;
|
||||
int chartWidth = info.ChartWidth;
|
||||
|
||||
BarMicroChartStyle style = this.Style;
|
||||
int drawStep = Math.Max(style.MinBarSize, (chartWidth / (Math.Max(1, info.DataPoints.Count - 1))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
int x = 0;
|
||||
double dataPointMinValue = info.DataPointMinValue;
|
||||
|
||||
if (dataPointMinValue > style.ZeroLineValue)
|
||||
dataPointMinValue = style.ZeroLineValue;
|
||||
|
||||
double range = info.DataPointMaxValue - dataPointMinValue;
|
||||
if (range == 0) range = 1;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int index = 0;
|
||||
int zeroY = Math.Min((int)(chartHeight * (1 - (style.ZeroLineValue - dataPointMinValue) / range)), chartHeight);
|
||||
|
||||
System.Drawing.Drawing2D.SmoothingMode smoothingMode = graphics.SmoothingMode;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
|
||||
using (SolidBrush positiveBarBrush = new SolidBrush(style.PositiveBarColor))
|
||||
{
|
||||
using (SolidBrush negativeBarBrush = new SolidBrush(style.NegativeBarColor))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
int y = Math.Min((int)(chartHeight * (1 - (value - dataPointMinValue) / range)), chartHeight - 1);
|
||||
Rectangle barBounds = Rectangle.Empty;
|
||||
if (value > style.ZeroLineValue)
|
||||
{
|
||||
if (zeroY == chartHeight && y == zeroY) y--;
|
||||
barBounds = new Rectangle(x, y, drawStep, Math.Max(1, zeroY - y));
|
||||
if (value == info.DataPointMaxValue && !style.HighPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.HighPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(positiveBarBrush, barBounds);
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, true), style.PositiveBarColor, value, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
barBounds = new Rectangle(x, zeroY, drawStep, Math.Max(1, y - zeroY));
|
||||
if (value == info.DataPointMinValue && !style.LowPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.LowPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(negativeBarBrush, barBounds);
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, false), style.NegativeBarColor, value, index);
|
||||
}
|
||||
|
||||
index++;
|
||||
x += drawStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
graphics.SmoothingMode = smoothingMode;
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the style for the bar style micro charts.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class BarMicroChartStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
private int _MinBarWidth = 2;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum single bar width.
|
||||
/// </summary>
|
||||
[DefaultValue(2), Category("Appearance"), Description("Indicates minimum single bar width.")]
|
||||
public int MinBarSize
|
||||
{
|
||||
get { return _MinBarWidth; }
|
||||
set
|
||||
{
|
||||
_MinBarWidth = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Color _PositiveBarColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of positive bar value.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of positive bar value.")]
|
||||
public Color PositiveBarColor
|
||||
{
|
||||
get { return _PositiveBarColor; }
|
||||
set { _PositiveBarColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializePositiveBarColor()
|
||||
{
|
||||
return _PositiveBarColor != Color.Black;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetPositiveBarColor()
|
||||
{
|
||||
this.PositiveBarColor = Color.Black;
|
||||
}
|
||||
|
||||
private Color _NegativeBarColor = Color.Red;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of negative bar value.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of negative bar value.")]
|
||||
public Color NegativeBarColor
|
||||
{
|
||||
get { return _NegativeBarColor; }
|
||||
set { _NegativeBarColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeNegativeBarColor()
|
||||
{
|
||||
return _NegativeBarColor != Color.Red;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetNegativeBarColor()
|
||||
{
|
||||
this.NegativeBarColor = Color.Red;
|
||||
}
|
||||
|
||||
private bool _DrawAverageLine = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether average line is drawn.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
public bool DrawAverageLine
|
||||
{
|
||||
get { return _DrawAverageLine; }
|
||||
set
|
||||
{
|
||||
_DrawAverageLine = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private double _ZeroLineValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the zero line, i.e. pivot point that determines negative and positive values. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Category("Appearance"), Description("Indicates value of the zero line, i.e. pivot point that determines negative and positive values.")]
|
||||
public double ZeroLineValue
|
||||
{
|
||||
get { return _ZeroLineValue; }
|
||||
set
|
||||
{
|
||||
_ZeroLineValue = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _LowPointBarColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the lowest value bar on graph.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of lowest bar on graph.")]
|
||||
public Color LowPointBarColor
|
||||
{
|
||||
get { return _LowPointBarColor; }
|
||||
set { _LowPointBarColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLowPointBarColor()
|
||||
{
|
||||
return !_LowPointBarColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLowPointBarColor()
|
||||
{
|
||||
this.LowPointBarColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _HighPointBarColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the highest value bar on graph.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of highest value bar on graph..")]
|
||||
public Color HighPointBarColor
|
||||
{
|
||||
get { return _HighPointBarColor; }
|
||||
set { _HighPointBarColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeHighPointBarColor()
|
||||
{
|
||||
return !_HighPointBarColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHighPointBarColor()
|
||||
{
|
||||
this.HighPointBarColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
191
PROMS/DotNetBar Source Code/MicroCharts/HundredPctBar.cs
Normal file
191
PROMS/DotNetBar Source Code/MicroCharts/HundredPctBar.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class HundredPctBar : MicroChartBase
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
int chartHeight = info.ChartHeight;
|
||||
int chartWidth = info.ChartWidth;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
HundredPctMicroChartStyle style = this.Style;
|
||||
int drawStep = Math.Max(style.MinBarSize, (chartWidth / (Math.Max(1, info.DataPoints.Count))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
|
||||
Graphics graphics = info.Graphics;
|
||||
double sum = info.Sum;
|
||||
|
||||
if (dataStep > 1)
|
||||
{
|
||||
sum = 0;
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
sum += Math.Abs(info.DataPoints[i]);
|
||||
}
|
||||
|
||||
int colorsCount = style.BarColors.Count;
|
||||
int sliceColor = 0;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int hotPointIndex = 0;
|
||||
|
||||
using (Pen pen = new Pen(style.BarOutlineColor, 1))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = Math.Abs(info.DataPoints[i]);
|
||||
|
||||
Rectangle barBounds = new Rectangle(x, y, (int)Math.Round(chartWidth * value / sum), chartHeight);
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(style.BarColors[sliceColor]))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
graphics.DrawRectangle(pen, barBounds);
|
||||
|
||||
microHotPoints[hotPointIndex] = new MicroChartHotPoint(GetHotPointBounds(barBounds), barBounds, style.BarColors[sliceColor], value, i);
|
||||
|
||||
hotPointIndex++;
|
||||
|
||||
x += barBounds.Width;
|
||||
|
||||
sliceColor++;
|
||||
if (sliceColor >= colorsCount)
|
||||
sliceColor = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
}
|
||||
|
||||
private HundredPctMicroChartStyle _Style;
|
||||
public virtual HundredPctMicroChartStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set { _Style = value; }
|
||||
}
|
||||
|
||||
private static int HotPointOffset
|
||||
{
|
||||
get { return Dpi.Width4; }
|
||||
}
|
||||
private Rectangle GetHotPointBounds(Rectangle barBounds)
|
||||
{
|
||||
return new Rectangle(barBounds.X + (barBounds.Width - HotPointOffset * 2) / 2,
|
||||
barBounds.Y + (barBounds.Height - HotPointOffset * 2) / 2,
|
||||
HotPointOffset * 2, HotPointOffset * 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the style for 100% bar chart.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class HundredPctMicroChartStyle
|
||||
{
|
||||
private List<Color> _BarColors = new List<Color>();
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PieMicroChartStyle class.
|
||||
/// </summary>
|
||||
public HundredPctMicroChartStyle()
|
||||
{
|
||||
_BarColors.AddRange(new Color[]{ColorScheme.GetColor(0xC00000), ColorScheme.GetColor(0xFF0000),
|
||||
ColorScheme.GetColor(0xFFC000), ColorScheme.GetColor(0xFFFF00), ColorScheme.GetColor(0x92D050),
|
||||
ColorScheme.GetColor(0x00B050), ColorScheme.GetColor(0x00B0F0), ColorScheme.GetColor(0x0070C0),
|
||||
ColorScheme.GetColor(0x002060), ColorScheme.GetColor(0x7030A0), ColorScheme.GetColor(0xEEECE1),
|
||||
ColorScheme.GetColor(0x1F497D), ColorScheme.GetColor(0x4F81BD), ColorScheme.GetColor(0xC0504D),
|
||||
ColorScheme.GetColor(0x9BBB59), ColorScheme.GetColor(0x8064A2), ColorScheme.GetColor(0x4BACC6),
|
||||
ColorScheme.GetColor(0xF79646), ColorScheme.GetColor(0xF2F2F2), ColorScheme.GetColor(0xDDD9C3),
|
||||
ColorScheme.GetColor(0xC6D9F0), ColorScheme.GetColor(0xF2DCDB), ColorScheme.GetColor(0xEBF1DD),
|
||||
ColorScheme.GetColor(0xE5E0EC), ColorScheme.GetColor(0xDBEEF3), ColorScheme.GetColor(0xFDEADA),
|
||||
ColorScheme.GetColor(0xD8D8D8), ColorScheme.GetColor(0xC4BD97), ColorScheme.GetColor(0x8DB3E2),
|
||||
ColorScheme.GetColor(0xE5B9B7), ColorScheme.GetColor(0xD7E3BC), ColorScheme.GetColor(0xCCC1D9),
|
||||
ColorScheme.GetColor(0xB7DDE8), ColorScheme.GetColor(0xFBD5B5), ColorScheme.GetColor(0xBFBFBF),
|
||||
ColorScheme.GetColor(0x938953), ColorScheme.GetColor(0x548DD4), ColorScheme.GetColor(0x95B3D7),
|
||||
ColorScheme.GetColor(0xD99694), ColorScheme.GetColor(0xC3D69B), ColorScheme.GetColor(0xB2A1C7),
|
||||
ColorScheme.GetColor(0x92CDDC), ColorScheme.GetColor(0xFAC08F), ColorScheme.GetColor(0xA5A5A5),
|
||||
ColorScheme.GetColor(0x494429), ColorScheme.GetColor(0x17365D), ColorScheme.GetColor(0x366092),
|
||||
ColorScheme.GetColor(0x953734), ColorScheme.GetColor(0x76923C), ColorScheme.GetColor(0x5F497A),
|
||||
ColorScheme.GetColor(0x31859B), ColorScheme.GetColor(0xE36C09)
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
private int _MinBarWidth = 2;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum single bar width.
|
||||
/// </summary>
|
||||
[DefaultValue(2), Category("Appearance"), Description("Indicates minimum single bar width.")]
|
||||
public int MinBarSize
|
||||
{
|
||||
get { return _MinBarWidth; }
|
||||
set
|
||||
{
|
||||
_MinBarWidth = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pre-defined slice colors for the pie chart.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<Color> BarColors
|
||||
{
|
||||
get { return _BarColors; }
|
||||
}
|
||||
|
||||
private Color _BarOutlineColor = ColorScheme.GetColor(0xE2E4E7);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the slice outline.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of slice outline.")]
|
||||
public Color BarOutlineColor
|
||||
{
|
||||
get { return _BarOutlineColor; }
|
||||
set { _BarOutlineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeBarOutlineColor()
|
||||
{
|
||||
return _BarOutlineColor != ColorScheme.GetColor(0xE2E4E7);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetBarOutlineColor()
|
||||
{
|
||||
this.BarOutlineColor = ColorScheme.GetColor(0xE2E4E7);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
596
PROMS/DotNetBar Source Code/MicroCharts/LineMicroChart.cs
Normal file
596
PROMS/DotNetBar Source Code/MicroCharts/LineMicroChart.cs
Normal file
@@ -0,0 +1,596 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class LineMicroChart : MicroChartBase
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int pointRadius = Dpi.Width(PointRadius);
|
||||
int chartHeight = info.ChartHeight - pointRadius * 2;
|
||||
int chartWidth = info.ChartWidth - pointRadius * 2;
|
||||
|
||||
int drawStep = (int)Math.Max(1, chartWidth / (Math.Max(1, info.DataPoints.Count - 1)));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
if (info.DataPoints.Count <= 2) dataStep = 1;
|
||||
int x = pointRadius;
|
||||
double dataPointMinValue = info.DataPointMinValue;
|
||||
double dataPointMaxValue = info.DataPointMaxValue;
|
||||
|
||||
if (_MicroChartStyle.DrawZeroLine && dataPointMinValue > _MicroChartStyle.ZeroLineValue)
|
||||
dataPointMinValue = _MicroChartStyle.ZeroLineValue;
|
||||
if (_MicroChartStyle.DrawControlLine1)
|
||||
{
|
||||
if (dataPointMinValue > _MicroChartStyle.ControlLine1StartValue)
|
||||
dataPointMinValue = _MicroChartStyle.ControlLine1StartValue;
|
||||
if (dataPointMinValue > _MicroChartStyle.ControlLine1EndValue)
|
||||
dataPointMinValue = _MicroChartStyle.ControlLine1EndValue;
|
||||
if (dataPointMaxValue < _MicroChartStyle.ControlLine1StartValue)
|
||||
dataPointMaxValue = _MicroChartStyle.ControlLine1StartValue;
|
||||
if (dataPointMaxValue < _MicroChartStyle.ControlLine1EndValue)
|
||||
dataPointMaxValue = _MicroChartStyle.ControlLine1EndValue;
|
||||
}
|
||||
if (_MicroChartStyle.DrawControlLine2)
|
||||
{
|
||||
if (dataPointMinValue > _MicroChartStyle.ControlLine2StartValue)
|
||||
dataPointMinValue = _MicroChartStyle.ControlLine2StartValue;
|
||||
if (dataPointMinValue > _MicroChartStyle.ControlLine2EndValue)
|
||||
dataPointMinValue = _MicroChartStyle.ControlLine2EndValue;
|
||||
if (dataPointMaxValue < _MicroChartStyle.ControlLine2StartValue)
|
||||
dataPointMaxValue = _MicroChartStyle.ControlLine2StartValue;
|
||||
if (dataPointMaxValue < _MicroChartStyle.ControlLine2EndValue)
|
||||
dataPointMaxValue = _MicroChartStyle.ControlLine2EndValue;
|
||||
}
|
||||
|
||||
|
||||
double range = dataPointMaxValue - dataPointMinValue;
|
||||
if (range == 0) range = 1;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
Point[] chartPoints = new Point[totalPoints];
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
Point lowPoint = Point.Empty, highPoint = Point.Empty;
|
||||
int index = 0;
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
Point p = new Point(x, (int)Math.Min((int)(chartHeight * (1 - (value - dataPointMinValue) / range)), chartHeight - 1) + pointRadius);
|
||||
if (lowPoint.IsEmpty && value == info.DataPointMinValue)
|
||||
lowPoint = p;
|
||||
else if (/*highPoint.IsEmpty &&*/ value == dataPointMaxValue)
|
||||
highPoint = p;
|
||||
|
||||
chartPoints[index] = p;
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(p, info), new Rectangle(p.X - drawStep / 2, 0, drawStep, chartHeight), _MicroChartStyle.LineColor, value, index);
|
||||
index++;
|
||||
x += drawStep;
|
||||
if (x > chartWidth || i >= info.DataPoints.Count - dataStep * 2) x = chartWidth;
|
||||
}
|
||||
|
||||
if (_MicroChartStyle.DrawAverageLine && !_MicroChartStyle.AverageLineColor.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_MicroChartStyle.AverageLineColor, Dpi.Width1))
|
||||
graphics.DrawLine(pen, 0, chartHeight / 2, chartWidth, chartHeight / 2);
|
||||
}
|
||||
|
||||
//if (_MicroChartStyle.DrawTrendLine && !_MicroChartStyle.TrendLineColor.IsEmpty)
|
||||
//{
|
||||
// using (Pen pen = new Pen(_MicroChartStyle.TrendLineColor))
|
||||
// graphics.DrawLine(pen, 0, (int)(chartHeight * (1 - (info.TrendInfo.Start - dataPointMinValue) / range)),
|
||||
// chartWidth, (int)(chartHeight * (1 - (info.TrendInfo.End - dataPointMinValue) / range)));
|
||||
//}
|
||||
|
||||
if (_MicroChartStyle.DrawZeroLine && !_MicroChartStyle.ZeroLineColor.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_MicroChartStyle.ZeroLineColor, Dpi.Width1))
|
||||
{
|
||||
int y = Math.Min((int)(chartHeight * (1 - (_MicroChartStyle.ZeroLineValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y < 0) y = 0;
|
||||
graphics.DrawLine(pen, 0, y, chartWidth, y);
|
||||
}
|
||||
}
|
||||
|
||||
if (_MicroChartStyle.DrawControlLine1 && !_MicroChartStyle.ControlLine1Color.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_MicroChartStyle.ControlLine1Color, Dpi.Width1))
|
||||
{
|
||||
int y1 = Math.Min((int)(chartHeight * (1 - (_MicroChartStyle.ControlLine1StartValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y1 < 0) y1 = 0;
|
||||
int y2 = Math.Min((int)(chartHeight * (1 - (_MicroChartStyle.ControlLine1EndValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y2 < 0) y2 = 0;
|
||||
graphics.DrawLine(pen, 0, y1, chartWidth, y2);
|
||||
}
|
||||
}
|
||||
if (_MicroChartStyle.DrawControlLine2 && !_MicroChartStyle.ControlLine2Color.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_MicroChartStyle.ControlLine2Color, Dpi.Width1))
|
||||
{
|
||||
int y1 = Math.Min((int)(chartHeight * (1 - (_MicroChartStyle.ControlLine2StartValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y1 < 0) y1 = 0;
|
||||
int y2 = Math.Min((int)(chartHeight * (1 - (_MicroChartStyle.ControlLine2EndValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y2 < 0) y2 = 0;
|
||||
graphics.DrawLine(pen, 0, y1, chartWidth, y2);
|
||||
}
|
||||
}
|
||||
|
||||
if (chartPoints.Length > 1)
|
||||
{
|
||||
using (Pen pen = new Pen(_MicroChartStyle.LineColor, Dpi.Width1))
|
||||
graphics.DrawLines(pen, chartPoints);
|
||||
}
|
||||
|
||||
if (!lowPoint.IsEmpty && !_MicroChartStyle.LowPointColor.IsEmpty && chartPoints.Length > 0)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.LowPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(lowPoint));
|
||||
}
|
||||
|
||||
if (!highPoint.IsEmpty && !_MicroChartStyle.HighPointColor.IsEmpty && chartPoints.Length > 0)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.HighPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(highPoint));
|
||||
}
|
||||
|
||||
if (!_MicroChartStyle.FirstPointColor.IsEmpty && chartPoints.Length > 0)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.FirstPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[0]));
|
||||
}
|
||||
|
||||
if (!_MicroChartStyle.LastPointColor.IsEmpty && chartPoints.Length > 1)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_MicroChartStyle.LastPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[chartPoints.Length - 1]));
|
||||
}
|
||||
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
|
||||
}
|
||||
|
||||
private static int HotPointOffset
|
||||
{
|
||||
get { return Dpi.Width4; }
|
||||
}
|
||||
private Rectangle GetHotPointBounds(Point hotPoint, MicroChartRenderInfo info)
|
||||
{
|
||||
//Rectangle bounds = new Rectangle(Math.Min(info.ChartWidth - HotPointOffset * 2, Math.Max(-1, hotPoint.X - HotPointOffset)),
|
||||
// Math.Min(info.ChartHeight - HotPointOffset * 2, Math.Max(-1, hotPoint.Y - HotPointOffset)),
|
||||
// HotPointOffset * 2,
|
||||
// HotPointOffset * 2);
|
||||
Rectangle bounds = new Rectangle(hotPoint.X - HotPointOffset,
|
||||
hotPoint.Y - HotPointOffset,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private LineMicroChartStyle _MicroChartStyle;
|
||||
public LineMicroChartStyle Style
|
||||
{
|
||||
get { return _MicroChartStyle; }
|
||||
set { _MicroChartStyle = value; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the style for the line micro chart.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class LineMicroChartStyle
|
||||
{
|
||||
private Color _LineColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the chart line.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of chart line .")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return _LineColor; }
|
||||
set { _LineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLineColor()
|
||||
{
|
||||
return _LineColor != Color.Black;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLineColor()
|
||||
{
|
||||
this.LineColor = Color.Black;
|
||||
}
|
||||
|
||||
private bool _DrawAverageLine = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether average line is drawn.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
public bool DrawAverageLine
|
||||
{
|
||||
get { return _DrawAverageLine; }
|
||||
set
|
||||
{
|
||||
_DrawAverageLine = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _AverageLineColor = ColorScheme.GetColor(0xFAC08F);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color AverageLineColor
|
||||
{
|
||||
get { return _AverageLineColor; }
|
||||
set { _AverageLineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeAverageLineColor()
|
||||
{
|
||||
return _AverageLineColor != ColorScheme.GetColor(0xFAC08F);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetAverageLineColor()
|
||||
{
|
||||
this.AverageLineColor = ColorScheme.GetColor(0xFAC08F);
|
||||
}
|
||||
|
||||
//private bool _DrawTrendLine = false;
|
||||
//[DefaultValue(false), Category("Appearance")]
|
||||
//public bool DrawTrendLine
|
||||
//{
|
||||
// get { return _DrawTrendLine; }
|
||||
// set
|
||||
// {
|
||||
// _DrawTrendLine = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private Color _TrendLineColor = ColorScheme.GetColor(0xBFBFBF);
|
||||
///// <summary>
|
||||
///// Gets or sets the color of the trend line.
|
||||
///// </summary>
|
||||
//[Category("Columns"), Description("Indicates color of trend line.")]
|
||||
//public Color TrendLineColor
|
||||
//{
|
||||
// get { return _TrendLineColor; }
|
||||
// set { _TrendLineColor = value; }
|
||||
//}
|
||||
///// <summary>
|
||||
///// Gets whether property should be serialized.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public bool ShouldSerializeTrendLineColor()
|
||||
//{
|
||||
// return !_TrendLineColor.IsEmpty;
|
||||
//}
|
||||
///// <summary>
|
||||
///// Resets property to its default value.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public void ResetTrendLineColor()
|
||||
//{
|
||||
// this.TrendLineColor = Color.Empty;
|
||||
//}
|
||||
|
||||
private bool _DrawZeroLine = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether zero-line is drawn on chart.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance"), Description("Gets or sets whether zero-line is drawn on chart.")]
|
||||
public bool DrawZeroLine
|
||||
{
|
||||
get { return _DrawZeroLine; }
|
||||
set
|
||||
{
|
||||
_DrawZeroLine = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private double _ZeroLineValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the zero line, i.e. where zero line is drawn. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Category("Appearance"), Description("Indicates value of the zero line, i.e. where zero line is drawn.")]
|
||||
public double ZeroLineValue
|
||||
{
|
||||
get { return _ZeroLineValue; }
|
||||
set
|
||||
{
|
||||
_ZeroLineValue = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _ZeroLineColor = Color.Red;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color ZeroLineColor
|
||||
{
|
||||
get { return _ZeroLineColor; }
|
||||
set { _ZeroLineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeZeroLineColor()
|
||||
{
|
||||
return _ZeroLineColor != Color.Red;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetZeroLineColor()
|
||||
{
|
||||
this.ZeroLineColor = Color.Red;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
private Color _HighPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the high point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of high point dot on chart..")]
|
||||
public Color HighPointColor
|
||||
{
|
||||
get { return _HighPointColor; }
|
||||
set { _HighPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeHighPointColor()
|
||||
{
|
||||
return !_HighPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHighPointColor()
|
||||
{
|
||||
this.HighPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LowPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the low point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of low point dot on chart.")]
|
||||
public Color LowPointColor
|
||||
{
|
||||
get { return _LowPointColor; }
|
||||
set { _LowPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLowPointColor()
|
||||
{
|
||||
return !_LowPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLowPointColor()
|
||||
{
|
||||
this.LowPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _FirstPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the first point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of first point dot on chart..")]
|
||||
public Color FirstPointColor
|
||||
{
|
||||
get { return _FirstPointColor; }
|
||||
set { _FirstPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeFirstPointColor()
|
||||
{
|
||||
return !_FirstPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetFirstPointColor()
|
||||
{
|
||||
this.FirstPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LastPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the last point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of last point dot on chart.")]
|
||||
public Color LastPointColor
|
||||
{
|
||||
get { return _LastPointColor; }
|
||||
set { _LastPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLastPointColor()
|
||||
{
|
||||
return !_LastPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLastPointColor()
|
||||
{
|
||||
this.LastPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private bool _DrawControlLine1 = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control line is drawn. Default value is false. Control lines can be used to display for example low and high control bounds for the chart.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Description("Indicates whether control line is drawn. Control lines can be used to display for example low and high control bounds for the chart")]
|
||||
public bool DrawControlLine1
|
||||
{
|
||||
get { return _DrawControlLine1; }
|
||||
set { _DrawControlLine1 = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
private Color _ControlLine1Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the first control line.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color ControlLine1Color
|
||||
{
|
||||
get { return _ControlLine1Color; }
|
||||
set { _ControlLine1Color = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeControlLine1Color()
|
||||
{
|
||||
return !_ControlLine1Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetControlLine1Color()
|
||||
{
|
||||
this.ControlLine1Color = Color.Empty;
|
||||
}
|
||||
private double _ControlLine1StartValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets starting value that is used to draw first control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the starting value that is used to draw first control line.")]
|
||||
public double ControlLine1StartValue
|
||||
{
|
||||
get { return _ControlLine1StartValue; }
|
||||
set { _ControlLine1StartValue = value; OnStyleChanged(); }
|
||||
}
|
||||
private double _ControlLine1EndValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets end value that is used to draw first control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the end value that is used to draw first control line.")]
|
||||
public double ControlLine1EndValue
|
||||
{
|
||||
get { return _ControlLine1EndValue; }
|
||||
set { _ControlLine1EndValue = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private bool _DrawControlLine2 = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control line is drawn. Default value is false. Control lines can be used to display for example low and high control bounds for the chart.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Description("Indicates whether control line is drawn. Control lines can be used to display for example low and high control bounds for the chart")]
|
||||
public bool DrawControlLine2
|
||||
{
|
||||
get { return _DrawControlLine2; }
|
||||
set { _DrawControlLine2 = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
private Color _ControlLine2Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the second control line.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of second control line.")]
|
||||
public Color ControlLine2Color
|
||||
{
|
||||
get { return _ControlLine2Color; }
|
||||
set { _ControlLine2Color = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeControlLine2Color()
|
||||
{
|
||||
return !_ControlLine2Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetControlLine2Color()
|
||||
{
|
||||
this.ControlLine2Color = Color.Empty;
|
||||
}
|
||||
private double _ControlLine2StartValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets starting value that is used to draw second control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the starting value that is used to draw first second line.")]
|
||||
public double ControlLine2StartValue
|
||||
{
|
||||
get { return _ControlLine2StartValue; }
|
||||
set { _ControlLine2StartValue = value; OnStyleChanged(); }
|
||||
}
|
||||
private double _ControlLine2EndValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets end value that is used to draw second control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the end value that is used to draw second control line.")]
|
||||
public double ControlLine2EndValue
|
||||
{
|
||||
get { return _ControlLine2EndValue; }
|
||||
set { _ControlLine2EndValue = value; OnStyleChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
546
PROMS/DotNetBar Source Code/MicroCharts/MicroChart.cs
Normal file
546
PROMS/DotNetBar Source Code/MicroCharts/MicroChart.cs
Normal file
@@ -0,0 +1,546 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.MicroCharts;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Micro-Chart Control.
|
||||
/// </summary>
|
||||
[ToolboxBitmap(typeof(MicroChart), "MicroCharts.MicroChart.ico"), ToolboxItem(true), DefaultEvent("Click"), Designer("DevComponents.DotNetBar.Design.MicroChartDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
|
||||
public class MicroChart : BaseItemControl, ICommandSource
|
||||
{
|
||||
#region Events
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
private MicroChartItem _MicroChart = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MicroChart class.
|
||||
/// </summary>
|
||||
public MicroChart()
|
||||
{
|
||||
this.SetStyle(ControlStyles.Selectable, false);
|
||||
_MicroChart = new MicroChartItem();
|
||||
_MicroChart.TextVisible = false;
|
||||
_MicroChart.MouseOverDataPointChanged += new EventHandler(MicroChartMouseOverDataPointChanged);
|
||||
this.HostItem = _MicroChart;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
this.RecalcLayout();
|
||||
base.OnHandleCreated(e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Forces the button to perform internal layout.
|
||||
/// </summary>
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
if (_MicroChart == null) return;
|
||||
Rectangle bounds = this.ClientRectangle;
|
||||
bounds.Inflate(-4, -4);
|
||||
if (bounds.Width < 4) bounds.Width = 4;
|
||||
if (bounds.Height < 4) bounds.Height = 4;
|
||||
_MicroChart.Bounds = bounds;
|
||||
_MicroChart.ChartHeight = bounds.Height;
|
||||
_MicroChart.ChartWidth = bounds.Width;
|
||||
|
||||
base.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override Size DefaultSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Size(96, 24);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether mouse over tooltip for data point is enabled. Default value is true.
|
||||
/// </summary>
|
||||
[Category("Behavior"), DefaultValue(true), Description("Indicates whether mouse over tooltip for data point is enabled")]
|
||||
public bool MouseOverDataPointTooltipEnabled
|
||||
{
|
||||
get { return _MicroChart.MouseOverDataPointTooltipEnabled; }
|
||||
set
|
||||
{
|
||||
_MicroChart.MouseOverDataPointTooltipEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of data point (DataPoints collection) that mouse is over or returns -1 if mouse is not over any data-point.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public int MouseOverDataPointIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.MouseOverDataPointIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private void MicroChartMouseOverDataPointChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnMouseOverDataPointChanged(e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when MouseOverDataPointIndex property changes due to user moving the mouse and pointing it to different data point on chart.
|
||||
/// </summary>
|
||||
public event EventHandler MouseOverDataPointChanged;
|
||||
/// <summary>
|
||||
/// Raises MouseOverDataPointChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnMouseOverDataPointChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = MouseOverDataPointChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tooltips for each data-point assigned through DataPoints property. If not set control will automatically
|
||||
/// show tooltip based on the data-point value.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<string> DataPointTooltips
|
||||
{
|
||||
get { return _MicroChart.DataPointTooltips; }
|
||||
set
|
||||
{
|
||||
_MicroChart.DataPointTooltips = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the chart data points. Note that if you are adding or removing points directly from this collection you must call
|
||||
/// Refresh() method on the control to refresh the display.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<double> DataPoints
|
||||
{
|
||||
get { return _MicroChart.DataPoints; }
|
||||
set
|
||||
{
|
||||
if (value != _MicroChart.DataPoints)
|
||||
{
|
||||
List<double> oldValue = _MicroChart.DataPoints;
|
||||
_MicroChart.DataPoints = value;
|
||||
OnDataPointsChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDataPointsChanged(List<double> oldValue, List<double> newValue)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format string for the value when it is displayed as tool-tip for data point.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("Indicates format string for the value when it is displayed as tool-tip for data point.")]
|
||||
public string TooltipValueFormatString
|
||||
{
|
||||
get { return _MicroChart.TooltipValueFormatString; }
|
||||
set
|
||||
{
|
||||
_MicroChart.TooltipValueFormatString = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether chart is tracking mouse movement to show data-point and its value on tooltip. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Indicates whether chart is tracking mouse movement to show data-point and its value on tooltip.")]
|
||||
public bool TrackChartPoints
|
||||
{
|
||||
get { return _MicroChart.TrackChartPoints; }
|
||||
set
|
||||
{
|
||||
_MicroChart.TrackChartPoints = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether transition animation between same chart with different data-points is enabled. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Indicates whether transition animation between same chart with different data-points is enabled.")]
|
||||
public bool AnimationEnabled
|
||||
{
|
||||
get { return _MicroChart.AnimationEnabled; }
|
||||
set
|
||||
{
|
||||
_MicroChart.AnimationEnabled = value;
|
||||
}
|
||||
}
|
||||
internal bool IsAnimationEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.DesignMode || NativeFunctions.IsTerminalSession())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether button like mouse over tracking is enabled for whole control. When enabled control looks like a button when mouse is over it. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Behavior"), Description("Indicates whether button like mouse over tracking is enabled for whole control. When enabled control looks like a button when mouse is over it.")]
|
||||
public bool MouseOverEnabled
|
||||
{
|
||||
get { return _MicroChart.MouseOverEnabled; }
|
||||
set
|
||||
{
|
||||
_MicroChart.MouseOverEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalidates the chart display and requests the re-paint.
|
||||
/// </summary>
|
||||
/// <param name="animateTransition">Indicates whether to animate transition to new chart</param>
|
||||
public void InvalidateChart(bool animateTransition)
|
||||
{
|
||||
_MicroChart.InvalidateChart(animateTransition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Line micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Line micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public LineMicroChartStyle LineChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.LineChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Plot micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Plot micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public PlotMicroChartStyle PlotChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.PlotChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Column micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Column micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public BarMicroChartStyle ColumnChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.ColumnChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Bar micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Bar micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public BarMicroChartStyle BarChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.BarChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Win-Lose micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Win-Lose micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public BarMicroChartStyle WinLoseChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.WinLoseChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Pie micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Pie micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public PieMicroChartStyle PieChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.PieChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of Area micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of Area micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public AreaMicroChartStyle AreaChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.AreaChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the style used to customize appearance of 100% micro-chart.
|
||||
/// </summary>
|
||||
[Category("Style"), Description("Identifies style used to customize appearance of 100% micro-chart."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public HundredPctMicroChartStyle HundredPctChartStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MicroChart.HundredPctChartStyle;
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets the width of the chart part of the control.
|
||||
///// </summary>
|
||||
//[DefaultValue(54), Category("Appearance"), Description("Indicates width of the chart part of the control.")]
|
||||
//public int ChartWidth
|
||||
//{
|
||||
// get { return _MicroChart.ChartWidth; }
|
||||
// set
|
||||
// {
|
||||
// _MicroChart.ChartWidth = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets the height of the chart part of the control.
|
||||
///// </summary>
|
||||
//[DefaultValue(15), Category("Appearance"), Description("Indicates height of the chart part of the control.")]
|
||||
//public int ChartHeight
|
||||
//{
|
||||
// get { return _MicroChart.ChartHeight; }
|
||||
// set
|
||||
// {
|
||||
// _MicroChart.ChartHeight = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the chart rendered.
|
||||
/// </summary>
|
||||
[DefaultValue(eMicroChartType.Line), Category("Appearance"), Description("Indicates type of the chart rendered.")]
|
||||
public eMicroChartType ChartType
|
||||
{
|
||||
get { return _MicroChart.ChartType; }
|
||||
set
|
||||
{
|
||||
_MicroChart.ChartType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value for data points. By default maximum data point is calculated based on that data displayed by the chart, but when
|
||||
/// two charts need to be scaled the same setting maximum and minimum values for them will ensure that scales are visually the same.
|
||||
/// </summary>
|
||||
[DefaultValue(double.NaN), Category("Behavior"), Description("Indicates maximum value for data points. By default maximum data point is calculated based on that data displayed by the chart, but when two charts need to be scaled the same setting maximum and minimum values for them will ensure that scales are visually the same.")]
|
||||
public double DataMaxValue
|
||||
{
|
||||
get { return _MicroChart.DataMaxValue; }
|
||||
set
|
||||
{
|
||||
_MicroChart.DataMaxValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value for data points. By default minimum data point is calculated based on that data displayed by the chart, but when
|
||||
/// two charts need to be scaled the same setting maximum and minimum values for them will ensure that scales are visually the same.
|
||||
/// </summary>
|
||||
[DefaultValue(double.NaN), Category("Behavior"), Description("Indicates minimum value for data points. By default minimum data point is calculated based on that data displayed by the chart, but when two charts need to be scaled the same setting maximum and minimum values for them will ensure that scales are visually the same.")]
|
||||
public double DataMinValue
|
||||
{
|
||||
get { return _MicroChart.DataMinValue; }
|
||||
set
|
||||
{
|
||||
_MicroChart.DataMinValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
|
||||
///// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
|
||||
///// </summary>
|
||||
//[DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for items Text property.")]
|
||||
//public bool EnableMarkup
|
||||
//{
|
||||
// get { return _MicroChart.EnableMarkup; }
|
||||
// set
|
||||
// {
|
||||
// _MicroChart.EnableMarkup = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets text-position in relation to the chart.
|
||||
///// </summary>
|
||||
//[DefaultValue(eMicroChartTextPosition.Left), Category("Appearance"), Description("Indicates text-position in relation to the chart.")]
|
||||
//public eMicroChartTextPosition TextPosition
|
||||
//{
|
||||
// get { return _MicroChart.TextPosition; }
|
||||
// set
|
||||
// {
|
||||
// _MicroChart.TextPosition = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets whether caption/label set using Text property is visible.
|
||||
///// </summary>
|
||||
//[DefaultValue(true), Category("Appearance"), Description("Indicates whether caption/label set using Text property is visible.")]
|
||||
//public bool TextVisible
|
||||
//{
|
||||
// get { return _MicroChart.TextVisible; }
|
||||
// set
|
||||
// {
|
||||
// _MicroChart.TextVisible = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets text padding.
|
||||
///// </summary>
|
||||
//[Browsable(true), Category("Appearance"), Description("Gets or sets text padding."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
//public Padding TextPadding
|
||||
//{
|
||||
// get { return _MicroChart.TextPadding; }
|
||||
//}
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public bool ShouldSerializeTextPadding()
|
||||
//{
|
||||
// return _MicroChart.ShouldSerializeTextPadding();
|
||||
//}
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public void ResetTextPadding()
|
||||
//{
|
||||
// _MicroChart.ResetTextPadding();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
///// Gets or sets the text color.
|
||||
///// </summary>
|
||||
//[Category("Appearance"), Description("Indicates text color.")]
|
||||
//public Color TextColor
|
||||
//{
|
||||
// get { return _MicroChart.TextColor; }
|
||||
// set { _MicroChart.TextColor = value; }
|
||||
//}
|
||||
///// <summary>
|
||||
///// Gets whether property should be serialized.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public bool ShouldSerializeTextColor()
|
||||
//{
|
||||
// return _MicroChart.ShouldSerializeTextColor();
|
||||
//}
|
||||
///// <summary>
|
||||
///// Resets property to its default value.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public void ResetTextColor()
|
||||
//{
|
||||
// _MicroChart.ResetTextColor();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region ICommandSource Members
|
||||
/// <summary>
|
||||
/// Gets whether command is executed when control is clicked.
|
||||
/// </summary>
|
||||
protected virtual bool ExecuteCommandOnClick
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected virtual void ExecuteCommand()
|
||||
{
|
||||
if (_Command == null) return;
|
||||
CommandManager.ExecuteCommand(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command assigned to the item. Default value is null.
|
||||
/// <remarks>Note that if this property is set to null Enabled property will be set to false automatically to disable the item.</remarks>
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
|
||||
public Command Command
|
||||
{
|
||||
get { return (Command)((ICommandSource)this).Command; }
|
||||
set
|
||||
{
|
||||
((ICommandSource)this).Command = value;
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _Command = null;
|
||||
//[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
ICommand ICommandSource.Command
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Command;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool changed = false;
|
||||
if (_Command != value)
|
||||
changed = true;
|
||||
|
||||
if (_Command != null)
|
||||
CommandManager.UnRegisterCommandSource(this, _Command);
|
||||
_Command = value;
|
||||
if (value != null)
|
||||
CommandManager.RegisterCommand(this, value);
|
||||
if (changed)
|
||||
OnCommandChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when Command property value changes.
|
||||
/// </summary>
|
||||
protected virtual void OnCommandChanged()
|
||||
{
|
||||
}
|
||||
|
||||
private object _CommandParameter = null;
|
||||
/// <summary>
|
||||
/// Gets or sets user defined data value that can be passed to the command when it is executed.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
|
||||
public object CommandParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommandParameter;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CommandParameter = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/MicroCharts/MicroChart.ico
Normal file
BIN
PROMS/DotNetBar Source Code/MicroCharts/MicroChart.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 894 B |
135
PROMS/DotNetBar Source Code/MicroCharts/MicroChartBase.cs
Normal file
135
PROMS/DotNetBar Source Code/MicroCharts/MicroChartBase.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base class each micro-chart implements
|
||||
/// </summary>
|
||||
internal abstract class MicroChartBase
|
||||
{
|
||||
internal const int PointRadius = 3;
|
||||
/// <summary>
|
||||
/// Creates the chart image.
|
||||
/// </summary>
|
||||
/// <param name="info">Rendering information.</param>
|
||||
/// <returns>Image of the chart.</returns>
|
||||
public abstract void CreateChart(MicroChartRenderInfo info);
|
||||
|
||||
protected virtual Point[] GetChartPointBounds(Point p)
|
||||
{
|
||||
return new Point[] { new Point(p.X, p.Y - PointRadius), new Point(p.X - PointRadius, p.Y), new Point(p.X, p.Y + PointRadius), new Point(p.X + PointRadius, p.Y), new Point(p.X, p.Y - PointRadius) };
|
||||
}
|
||||
}
|
||||
|
||||
internal struct TrendInfo
|
||||
{
|
||||
public double Slope;
|
||||
public double Intercept;
|
||||
public double Start;
|
||||
public double End;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the TrendInfo structure.
|
||||
/// </summary>
|
||||
/// <param name="slope"></param>
|
||||
/// <param name="intercept"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
public TrendInfo(double slope, double intercept, double start, double end)
|
||||
{
|
||||
Slope = slope;
|
||||
Intercept = intercept;
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the TrendInfo structure.
|
||||
/// </summary>
|
||||
static TrendInfo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
internal class MicroChartRenderInfo
|
||||
{
|
||||
public List<double> DataPoints;
|
||||
public MicroChartHotPoint[] MicroChartHotPoints;
|
||||
public Graphics Graphics;
|
||||
public int ChartWidth;
|
||||
public int ChartHeight;
|
||||
|
||||
public double DataPointMaxValue;
|
||||
public double DataPointMinValue;
|
||||
public double Sum;
|
||||
|
||||
public TrendInfo TrendInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MicroChartRenderInfo structure.
|
||||
/// </summary>
|
||||
/// <param name="dataPoints"></param>
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="chartWidth"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
public MicroChartRenderInfo(List<double> dataPoints, Graphics graphics, int chartWidth, int chartHeight, double dataMax, double dataMin)
|
||||
{
|
||||
DataPoints = dataPoints;
|
||||
Graphics = graphics;
|
||||
ChartWidth = chartWidth;
|
||||
ChartHeight = chartHeight;
|
||||
|
||||
MicroChartHotPoints = null;
|
||||
DataPointMaxValue = dataMax;
|
||||
DataPointMinValue = dataMin;
|
||||
Sum = 0;
|
||||
TrendInfo = new TrendInfo();
|
||||
|
||||
UpdateChartStats();
|
||||
}
|
||||
|
||||
private void UpdateChartStats()
|
||||
{
|
||||
if (DataPoints == null || DataPoints.Count == 0) return;
|
||||
double min = DataPoints[0], max = DataPoints[0];
|
||||
|
||||
// For trending
|
||||
double xxSum = 0, xySum = 0, xAxisValuesSum = 0, yAxisValuesSum = 0;
|
||||
Sum = Math.Abs(DataPoints[0]);
|
||||
|
||||
for (int i = 1; i < DataPoints.Count; i++)
|
||||
{
|
||||
double value = DataPoints[i];
|
||||
if (value < min) min = value;
|
||||
if (value > max) max = value;
|
||||
Sum += Math.Abs(value);
|
||||
xySum += value * (i + 1);
|
||||
xxSum = value * value;
|
||||
yAxisValuesSum += value;
|
||||
xAxisValuesSum += i + 1;
|
||||
}
|
||||
|
||||
|
||||
double slope = 0, intercept = 0, start = 0, end = 0;
|
||||
try
|
||||
{
|
||||
slope = ((DataPoints.Count * xySum) - (xAxisValuesSum * yAxisValuesSum)) /
|
||||
((DataPoints.Count * xxSum) - (xAxisValuesSum * xAxisValuesSum));
|
||||
}
|
||||
catch (DivideByZeroException) { }
|
||||
intercept = (yAxisValuesSum - (slope * xAxisValuesSum)) / DataPoints.Count;
|
||||
start = Math.Max(0, (slope * DataPoints[0]) + intercept);
|
||||
end = (slope * DataPoints[DataPoints.Count - 1]) + intercept;
|
||||
this.TrendInfo = new TrendInfo(slope, intercept, start, end);
|
||||
|
||||
if(double.IsNaN(DataPointMaxValue))
|
||||
DataPointMaxValue = max;
|
||||
if(double.IsNaN(DataPointMinValue))
|
||||
DataPointMinValue = min;
|
||||
}
|
||||
}
|
||||
}
|
1654
PROMS/DotNetBar Source Code/MicroCharts/MicroChartItem.cs
Normal file
1654
PROMS/DotNetBar Source Code/MicroCharts/MicroChartItem.cs
Normal file
File diff suppressed because it is too large
Load Diff
165
PROMS/DotNetBar Source Code/MicroCharts/PieMicroChart.cs
Normal file
165
PROMS/DotNetBar Source Code/MicroCharts/PieMicroChart.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class PieMicroChart : MicroChartBase
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
int chartWidth = Math.Min(info.ChartHeight, info.ChartWidth) - 1;
|
||||
int x = (info.ChartWidth - chartWidth) / 2;
|
||||
int y = (info.ChartHeight - chartWidth) / 2;
|
||||
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * 15) / 360));
|
||||
|
||||
PieMicroChartStyle style = this.Style;
|
||||
Graphics graphics = info.Graphics;
|
||||
double sum = info.Sum;
|
||||
|
||||
if (dataStep > 1)
|
||||
{
|
||||
sum = 0;
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
sum += Math.Abs(info.DataPoints[i]);
|
||||
}
|
||||
|
||||
float angle = 0;
|
||||
|
||||
int colorsCount = _Style.SliceColors.Count;
|
||||
int sliceColor = 0;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int hotPointIndex = 0;
|
||||
|
||||
using (Pen pen = new Pen(_Style.SliceOutlineColor, 1))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = Math.Abs(info.DataPoints[i]);
|
||||
float sweepAngle = (float)Math.Max(1, Math.Round((float)(360 * (value / sum))));
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(_Style.SliceColors[sliceColor]))
|
||||
graphics.FillPie(brush, x, y, chartWidth, chartWidth, angle, sweepAngle);
|
||||
graphics.DrawPie(pen, x, y, chartWidth, chartWidth, angle, sweepAngle);
|
||||
|
||||
Rectangle hotPointBounds = new Rectangle(
|
||||
x + (int)(chartWidth / 2 + chartWidth / 3 * Math.Cos((angle + sweepAngle / 2) * Math.PI / 180)),
|
||||
y + (int)(chartWidth / 2 + chartWidth / 3 * Math.Sin((angle + sweepAngle / 2) * Math.PI / 180)),
|
||||
1, 1);
|
||||
hotPointBounds.Inflate(4, 4);
|
||||
microHotPoints[hotPointIndex] = new MicroChartHotPoint(hotPointBounds, _Style.SliceColors[sliceColor], value, angle, sweepAngle, i);
|
||||
hotPointIndex++;
|
||||
|
||||
angle += sweepAngle;
|
||||
sliceColor++;
|
||||
if (sliceColor >= colorsCount)
|
||||
sliceColor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
}
|
||||
|
||||
private PieMicroChartStyle _Style;
|
||||
public virtual PieMicroChartStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set { _Style = value; }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Defines the style for pie chart.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class PieMicroChartStyle
|
||||
{
|
||||
private List<Color> _SliceColors = new List<Color>();
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PieMicroChartStyle class.
|
||||
/// </summary>
|
||||
public PieMicroChartStyle()
|
||||
{
|
||||
_SliceColors.AddRange(new Color[]{ColorScheme.GetColor(0xC00000), ColorScheme.GetColor(0xFF0000),
|
||||
ColorScheme.GetColor(0xFFC000), ColorScheme.GetColor(0xFFFF00), ColorScheme.GetColor(0x92D050),
|
||||
ColorScheme.GetColor(0x00B050), ColorScheme.GetColor(0x00B0F0), ColorScheme.GetColor(0x0070C0),
|
||||
ColorScheme.GetColor(0x002060), ColorScheme.GetColor(0x7030A0), ColorScheme.GetColor(0xEEECE1),
|
||||
ColorScheme.GetColor(0x1F497D), ColorScheme.GetColor(0x4F81BD), ColorScheme.GetColor(0xC0504D),
|
||||
ColorScheme.GetColor(0x9BBB59), ColorScheme.GetColor(0x8064A2), ColorScheme.GetColor(0x4BACC6),
|
||||
ColorScheme.GetColor(0xF79646), ColorScheme.GetColor(0xF2F2F2), ColorScheme.GetColor(0xDDD9C3),
|
||||
ColorScheme.GetColor(0xC6D9F0), ColorScheme.GetColor(0xF2DCDB), ColorScheme.GetColor(0xEBF1DD),
|
||||
ColorScheme.GetColor(0xE5E0EC), ColorScheme.GetColor(0xDBEEF3), ColorScheme.GetColor(0xFDEADA),
|
||||
ColorScheme.GetColor(0xD8D8D8), ColorScheme.GetColor(0xC4BD97), ColorScheme.GetColor(0x8DB3E2),
|
||||
ColorScheme.GetColor(0xE5B9B7), ColorScheme.GetColor(0xD7E3BC), ColorScheme.GetColor(0xCCC1D9),
|
||||
ColorScheme.GetColor(0xB7DDE8), ColorScheme.GetColor(0xFBD5B5), ColorScheme.GetColor(0xBFBFBF),
|
||||
ColorScheme.GetColor(0x938953), ColorScheme.GetColor(0x548DD4), ColorScheme.GetColor(0x95B3D7),
|
||||
ColorScheme.GetColor(0xD99694), ColorScheme.GetColor(0xC3D69B), ColorScheme.GetColor(0xB2A1C7),
|
||||
ColorScheme.GetColor(0x92CDDC), ColorScheme.GetColor(0xFAC08F), ColorScheme.GetColor(0xA5A5A5),
|
||||
ColorScheme.GetColor(0x494429), ColorScheme.GetColor(0x17365D), ColorScheme.GetColor(0x366092),
|
||||
ColorScheme.GetColor(0x953734), ColorScheme.GetColor(0x76923C), ColorScheme.GetColor(0x5F497A),
|
||||
ColorScheme.GetColor(0x31859B), ColorScheme.GetColor(0xE36C09)
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pre-defined slice colors for the pie chart.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<Color> SliceColors
|
||||
{
|
||||
get { return _SliceColors; }
|
||||
}
|
||||
|
||||
private Color _SliceOutlineColor = ColorScheme.GetColor(0xE2E4E7);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the slice outline.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of slice outline.")]
|
||||
public Color SliceOutlineColor
|
||||
{
|
||||
get { return _SliceOutlineColor; }
|
||||
set { _SliceOutlineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeSliceOutlineColor()
|
||||
{
|
||||
return _SliceOutlineColor != ColorScheme.GetColor(0xE2E4E7);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSliceOutlineColor()
|
||||
{
|
||||
this.SliceOutlineColor = ColorScheme.GetColor(0xE2E4E7);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
592
PROMS/DotNetBar Source Code/MicroCharts/PlotMicroChart.cs
Normal file
592
PROMS/DotNetBar Source Code/MicroCharts/PlotMicroChart.cs
Normal file
@@ -0,0 +1,592 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class PlotMicroChart : MicroChartBase
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int pointRadius = Dpi.Width(PointRadius);
|
||||
int chartHeight = info.ChartHeight - pointRadius * 2;
|
||||
int chartWidth = info.ChartWidth - pointRadius*2;
|
||||
|
||||
int drawStep = Math.Max(4, (chartWidth / (Math.Max(1, info.DataPoints.Count - 1))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
int x = pointRadius;
|
||||
double dataPointMinValue = info.DataPointMinValue;
|
||||
double dataPointMaxValue = info.DataPointMaxValue;
|
||||
|
||||
if (_Style.DrawZeroLine && dataPointMinValue > _Style.ZeroLineValue)
|
||||
dataPointMinValue = _Style.ZeroLineValue;
|
||||
if (_Style.DrawControlLine1)
|
||||
{
|
||||
if (dataPointMinValue > _Style.ControlLine1StartValue)
|
||||
dataPointMinValue = _Style.ControlLine1StartValue;
|
||||
if (dataPointMinValue > _Style.ControlLine1EndValue)
|
||||
dataPointMinValue = _Style.ControlLine1EndValue;
|
||||
if (dataPointMaxValue < _Style.ControlLine1StartValue)
|
||||
dataPointMaxValue = _Style.ControlLine1StartValue;
|
||||
if (dataPointMaxValue < _Style.ControlLine1EndValue)
|
||||
dataPointMaxValue = _Style.ControlLine1EndValue;
|
||||
}
|
||||
if (_Style.DrawControlLine2)
|
||||
{
|
||||
if (dataPointMinValue > _Style.ControlLine2StartValue)
|
||||
dataPointMinValue = _Style.ControlLine2StartValue;
|
||||
if (dataPointMinValue > _Style.ControlLine2EndValue)
|
||||
dataPointMinValue = _Style.ControlLine2EndValue;
|
||||
if (dataPointMaxValue < _Style.ControlLine2StartValue)
|
||||
dataPointMaxValue = _Style.ControlLine2StartValue;
|
||||
if (dataPointMaxValue < _Style.ControlLine2EndValue)
|
||||
dataPointMaxValue = _Style.ControlLine2EndValue;
|
||||
}
|
||||
|
||||
double range = dataPointMaxValue - dataPointMinValue;
|
||||
if (range == 0) range = 1;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
Point[] chartPoints = new Point[totalPoints];
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int index = 0;
|
||||
|
||||
if (_Style.DrawAverageLine && !_Style.AverageLineColor.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_Style.AverageLineColor, Dpi.Width1))
|
||||
graphics.DrawLine(pen, 0, chartHeight / 2, chartWidth, chartHeight / 2);
|
||||
}
|
||||
|
||||
//if (_Style.DrawTrendLine && !_Style.TrendLineColor.IsEmpty)
|
||||
//{
|
||||
// using (Pen pen = new Pen(_Style.TrendLineColor))
|
||||
// graphics.DrawLine(pen, 0, (int)(chartHeight * (1 - (info.TrendInfo.Start - dataPointMinValue) / range)),
|
||||
// chartWidth, (int)(chartHeight * (1 - (info.TrendInfo.End - dataPointMinValue) / range)));
|
||||
//}
|
||||
|
||||
if (_Style.DrawZeroLine && !_Style.ZeroLineColor.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_Style.ZeroLineColor, Dpi.Width1))
|
||||
{
|
||||
int y = Math.Min((int)(chartHeight * (1 - (_Style.ZeroLineValue - dataPointMinValue) / range)) + pointRadius, chartHeight - 1);
|
||||
if (y < 0) y = 0;
|
||||
graphics.DrawLine(pen, 0, y, chartWidth, y);
|
||||
}
|
||||
}
|
||||
if (_Style.DrawControlLine1 && !_Style.ControlLine1Color.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_Style.ControlLine1Color, Dpi.Width1))
|
||||
{
|
||||
int y1 = Math.Min((int)(chartHeight * (1 - (_Style.ControlLine1StartValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y1 < 0) y1 = 0;
|
||||
int y2 = Math.Min((int)(chartHeight * (1 - (_Style.ControlLine1EndValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y2 < 0) y2 = 0;
|
||||
graphics.DrawLine(pen, 0, y1, chartWidth, y2);
|
||||
}
|
||||
}
|
||||
if (_Style.DrawControlLine2 && !_Style.ControlLine2Color.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(_Style.ControlLine2Color, Dpi.Width1))
|
||||
{
|
||||
int y1 = Math.Min((int)(chartHeight * (1 - (_Style.ControlLine2StartValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y1 < 0) y1 = 0;
|
||||
int y2 = Math.Min((int)(chartHeight * (1 - (_Style.ControlLine2EndValue - dataPointMinValue) / range)) + pointRadius, (chartHeight + pointRadius) - 1);
|
||||
if (y2 < 0) y2 = 0;
|
||||
graphics.DrawLine(pen, 0, y1, chartWidth, y2);
|
||||
}
|
||||
}
|
||||
|
||||
Point lowPoint = Point.Empty, highPoint = Point.Empty;
|
||||
|
||||
using (Brush plotBrush = new SolidBrush(_Style.PlotColor))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
Point p = new Point(x, Math.Min((int)(chartHeight * (1 - (value - dataPointMinValue) / range)), chartHeight - 1) + pointRadius);
|
||||
|
||||
if (lowPoint.IsEmpty && value == info.DataPointMinValue)
|
||||
lowPoint = p;
|
||||
else if (/*highPoint.IsEmpty &&*/ value == info.DataPointMaxValue)
|
||||
highPoint = p;
|
||||
|
||||
graphics.FillEllipse(plotBrush, new Rectangle(p.X - Dpi.Width1, p.Y - Dpi.Height1, Dpi.Width3, Dpi.Height3));
|
||||
|
||||
chartPoints[index] = p;
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(p, info), new Rectangle(x, 0, drawStep, chartHeight), _Style.PlotColor, value, index);
|
||||
index++;
|
||||
x += drawStep;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lowPoint.IsEmpty && !_Style.LowPointColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_Style.LowPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(lowPoint));
|
||||
}
|
||||
|
||||
if (!highPoint.IsEmpty && !_Style.HighPointColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_Style.HighPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(highPoint));
|
||||
}
|
||||
|
||||
if (!_Style.FirstPointColor.IsEmpty && chartPoints.Length > 0)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_Style.FirstPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[0]));
|
||||
}
|
||||
|
||||
if (!_Style.LastPointColor.IsEmpty && chartPoints.Length > 1)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(_Style.LastPointColor))
|
||||
graphics.FillPolygon(brush, GetChartPointBounds(chartPoints[chartPoints.Length - 1]));
|
||||
}
|
||||
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
|
||||
}
|
||||
private static int HotPointOffset
|
||||
{
|
||||
get { return Dpi.Width4; }
|
||||
}
|
||||
private Rectangle GetHotPointBounds(Point hotPoint, MicroChartRenderInfo info)
|
||||
{
|
||||
//Rectangle bounds = new Rectangle(Math.Min(info.ChartWidth - HotPointOffset * 2, Math.Max(-1, hotPoint.X - HotPointOffset)),
|
||||
// Math.Min(info.ChartHeight - HotPointOffset * 2, Math.Max(-1, hotPoint.Y - HotPointOffset)),
|
||||
// HotPointOffset * 2,
|
||||
// HotPointOffset * 2);
|
||||
Rectangle bounds = new Rectangle(hotPoint.X - HotPointOffset,
|
||||
hotPoint.Y - HotPointOffset,
|
||||
HotPointOffset * 2,
|
||||
HotPointOffset * 2);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private PlotMicroChartStyle _Style;
|
||||
public PlotMicroChartStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set { _Style = value; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the style for the plot micro chart.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class PlotMicroChartStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when style appearance changes.
|
||||
/// </summary>
|
||||
public event EventHandler StyleChanged;
|
||||
/// <summary>
|
||||
/// Raises StyleChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnStyleChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = StyleChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
OnStyleChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
private Color _PlotColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the chart line.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of chart line .")]
|
||||
public Color PlotColor
|
||||
{
|
||||
get { return _PlotColor; }
|
||||
set { _PlotColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializePlotColor()
|
||||
{
|
||||
return _PlotColor != Color.Black;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetPlotColor()
|
||||
{
|
||||
this.PlotColor = Color.Black;
|
||||
}
|
||||
|
||||
private bool _DrawAverageLine = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether average line is drawn.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
public bool DrawAverageLine
|
||||
{
|
||||
get { return _DrawAverageLine; }
|
||||
set
|
||||
{
|
||||
_DrawAverageLine = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _AverageLineColor = ColorScheme.GetColor(0xFAC08F);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color AverageLineColor
|
||||
{
|
||||
get { return _AverageLineColor; }
|
||||
set { _AverageLineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeAverageLineColor()
|
||||
{
|
||||
return _AverageLineColor != ColorScheme.GetColor(0xFAC08F);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetAverageLineColor()
|
||||
{
|
||||
this.AverageLineColor = ColorScheme.GetColor(0xFAC08F);
|
||||
}
|
||||
|
||||
//private bool _DrawTrendLine = false;
|
||||
//[DefaultValue(false), Category("Appearance")]
|
||||
//public bool DrawTrendLine
|
||||
//{
|
||||
// get { return _DrawTrendLine; }
|
||||
// set
|
||||
// {
|
||||
// _DrawTrendLine = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private Color _TrendLineColor = ColorScheme.GetColor(0xBFBFBF);
|
||||
///// <summary>
|
||||
///// Gets or sets the color of the trend line.
|
||||
///// </summary>
|
||||
//[Category("Columns"), Description("Indicates color of trend line.")]
|
||||
//public Color TrendLineColor
|
||||
//{
|
||||
// get { return _TrendLineColor; }
|
||||
// set { _TrendLineColor = value; }
|
||||
//}
|
||||
///// <summary>
|
||||
///// Gets whether property should be serialized.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public bool ShouldSerializeTrendLineColor()
|
||||
//{
|
||||
// return !_TrendLineColor.IsEmpty;
|
||||
//}
|
||||
///// <summary>
|
||||
///// Resets property to its default value.
|
||||
///// </summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//public void ResetTrendLineColor()
|
||||
//{
|
||||
// this.TrendLineColor = Color.Empty;
|
||||
//}
|
||||
|
||||
private bool _DrawZeroLine = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether zero-line is drawn on chart.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance"), Description("Gets or sets whether zero-line is drawn on chart.")]
|
||||
public bool DrawZeroLine
|
||||
{
|
||||
get { return _DrawZeroLine; }
|
||||
set
|
||||
{
|
||||
_DrawZeroLine = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private double _ZeroLineValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the zero line, i.e. where zero line is drawn. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Category("Appearance"), Description("Indicates value of the zero line, i.e. where zero line is drawn.")]
|
||||
public double ZeroLineValue
|
||||
{
|
||||
get { return _ZeroLineValue; }
|
||||
set
|
||||
{
|
||||
_ZeroLineValue = value;
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _ZeroLineColor = Color.Red;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color ZeroLineColor
|
||||
{
|
||||
get { return _ZeroLineColor; }
|
||||
set { _ZeroLineColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeZeroLineColor()
|
||||
{
|
||||
return _ZeroLineColor != Color.Red;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetZeroLineColor()
|
||||
{
|
||||
this.ZeroLineColor = Color.Red;
|
||||
}
|
||||
|
||||
private Color _HighPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the high point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of high point dot on chart..")]
|
||||
public Color HighPointColor
|
||||
{
|
||||
get { return _HighPointColor; }
|
||||
set { _HighPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeHighPointColor()
|
||||
{
|
||||
return !_HighPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHighPointColor()
|
||||
{
|
||||
this.HighPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LowPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the low point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of low point dot on chart.")]
|
||||
public Color LowPointColor
|
||||
{
|
||||
get { return _LowPointColor; }
|
||||
set { _LowPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLowPointColor()
|
||||
{
|
||||
return !_LowPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLowPointColor()
|
||||
{
|
||||
this.LowPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _FirstPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the first point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of first point dot on chart..")]
|
||||
public Color FirstPointColor
|
||||
{
|
||||
get { return _FirstPointColor; }
|
||||
set { _FirstPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeFirstPointColor()
|
||||
{
|
||||
return !_FirstPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetFirstPointColor()
|
||||
{
|
||||
this.FirstPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _LastPointColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the last point dot on chart.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of last point dot on chart.")]
|
||||
public Color LastPointColor
|
||||
{
|
||||
get { return _LastPointColor; }
|
||||
set { _LastPointColor = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLastPointColor()
|
||||
{
|
||||
return !_LastPointColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLastPointColor()
|
||||
{
|
||||
this.LastPointColor = Color.Empty;
|
||||
}
|
||||
|
||||
private bool _DrawControlLine1 = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control line is drawn. Default value is false. Control lines can be used to display for example low and high control bounds for the chart.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Description("Indicates whether control line is drawn. Control lines can be used to display for example low and high control bounds for the chart")]
|
||||
public bool DrawControlLine1
|
||||
{
|
||||
get { return _DrawControlLine1; }
|
||||
set { _DrawControlLine1 = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
private Color _ControlLine1Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the first control line.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of.")]
|
||||
public Color ControlLine1Color
|
||||
{
|
||||
get { return _ControlLine1Color; }
|
||||
set { _ControlLine1Color = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeControlLine1Color()
|
||||
{
|
||||
return !_ControlLine1Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetControlLine1Color()
|
||||
{
|
||||
this.ControlLine1Color = Color.Empty;
|
||||
}
|
||||
private double _ControlLine1StartValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets starting value that is used to draw first control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the starting value that is used to draw first control line.")]
|
||||
public double ControlLine1StartValue
|
||||
{
|
||||
get { return _ControlLine1StartValue; }
|
||||
set { _ControlLine1StartValue = value; OnStyleChanged(); }
|
||||
}
|
||||
private double _ControlLine1EndValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets end value that is used to draw first control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the end value that is used to draw first control line.")]
|
||||
public double ControlLine1EndValue
|
||||
{
|
||||
get { return _ControlLine1EndValue; }
|
||||
set { _ControlLine1EndValue = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private bool _DrawControlLine2 = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control line is drawn. Default value is false. Control lines can be used to display for example low and high control bounds for the chart.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Description("Indicates whether control line is drawn. Control lines can be used to display for example low and high control bounds for the chart")]
|
||||
public bool DrawControlLine2
|
||||
{
|
||||
get { return _DrawControlLine2; }
|
||||
set { _DrawControlLine2 = value; OnStyleChanged(); }
|
||||
}
|
||||
|
||||
private Color _ControlLine2Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the second control line.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of second control line.")]
|
||||
public Color ControlLine2Color
|
||||
{
|
||||
get { return _ControlLine2Color; }
|
||||
set { _ControlLine2Color = value; OnStyleChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeControlLine2Color()
|
||||
{
|
||||
return !_ControlLine2Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetControlLine2Color()
|
||||
{
|
||||
this.ControlLine2Color = Color.Empty;
|
||||
}
|
||||
private double _ControlLine2StartValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets starting value that is used to draw second control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the starting value that is used to draw first second line.")]
|
||||
public double ControlLine2StartValue
|
||||
{
|
||||
get { return _ControlLine2StartValue; }
|
||||
set { _ControlLine2StartValue = value; OnStyleChanged(); }
|
||||
}
|
||||
private double _ControlLine2EndValue = 0d;
|
||||
/// <summary>
|
||||
/// Gets or sets end value that is used to draw second control line.
|
||||
/// </summary>
|
||||
[DefaultValue(0d), Description("Indicates the end value that is used to draw second control line.")]
|
||||
public double ControlLine2EndValue
|
||||
{
|
||||
get { return _ControlLine2EndValue; }
|
||||
set { _ControlLine2EndValue = value; OnStyleChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
77
PROMS/DotNetBar Source Code/MicroCharts/WinLoseMicroChart.cs
Normal file
77
PROMS/DotNetBar Source Code/MicroCharts/WinLoseMicroChart.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.MicroCharts
|
||||
{
|
||||
internal class WinLoseMicroChart : BarBaseMicroChart
|
||||
{
|
||||
public override void CreateChart(MicroChartRenderInfo info)
|
||||
{
|
||||
Graphics graphics = info.Graphics;
|
||||
|
||||
int chartHeight = info.ChartHeight;
|
||||
int chartWidth = info.ChartWidth;
|
||||
|
||||
BarMicroChartStyle style = this.Style;
|
||||
int drawStep = Math.Max(style.MinBarSize, (chartWidth / (Math.Max(1, info.DataPoints.Count - 1))));
|
||||
int dataStep = Math.Max(1, ((info.DataPoints.Count * drawStep) / chartWidth));
|
||||
int x = 0;
|
||||
|
||||
double zeroValue = style.ZeroLineValue;
|
||||
|
||||
int totalPoints = (int)Math.Ceiling((double)info.DataPoints.Count / dataStep);
|
||||
MicroChartHotPoint[] microHotPoints = new MicroChartHotPoint[totalPoints];
|
||||
int index = 0;
|
||||
int zeroY = chartHeight / 2;
|
||||
|
||||
System.Drawing.Drawing2D.SmoothingMode smoothingMode = graphics.SmoothingMode;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
|
||||
|
||||
using (SolidBrush positiveBarBrush = new SolidBrush(style.PositiveBarColor))
|
||||
{
|
||||
using (SolidBrush negativeBarBrush = new SolidBrush(style.NegativeBarColor))
|
||||
{
|
||||
for (int i = 0; i < info.DataPoints.Count; i += dataStep)
|
||||
{
|
||||
double value = info.DataPoints[i];
|
||||
if (value > style.ZeroLineValue)
|
||||
{
|
||||
Rectangle barBounds = new Rectangle(x, 0, drawStep, Math.Max(1, zeroY));
|
||||
|
||||
if (value == info.DataPointMaxValue && !style.HighPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.HighPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(positiveBarBrush, barBounds);
|
||||
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, true), new Rectangle(barBounds.X, 0, barBounds.Width, chartHeight), style.PositiveBarColor, value, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle barBounds = new Rectangle(x, zeroY, drawStep, Math.Max(1, chartHeight - zeroY));
|
||||
|
||||
if (value == info.DataPointMinValue && !style.LowPointBarColor.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(style.LowPointBarColor))
|
||||
graphics.FillRectangle(brush, barBounds);
|
||||
}
|
||||
else
|
||||
graphics.FillRectangle(negativeBarBrush, barBounds);
|
||||
|
||||
microHotPoints[index] = new MicroChartHotPoint(GetHotPointBounds(barBounds, false), new Rectangle(barBounds.X, 0, barBounds.Width, chartHeight), style.NegativeBarColor, value, index);
|
||||
}
|
||||
|
||||
index++;
|
||||
x += drawStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
graphics.SmoothingMode = smoothingMode;
|
||||
info.MicroChartHotPoints = microHotPoints;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user