Update MicroCharts so completely builds

This commit is contained in:
Bret Johnson 2020-08-24 21:35:44 -04:00
Родитель 5f750b3015
Коммит 3e389f6f5a
11 изменённых файлов: 137 добавлений и 210 удалений

Просмотреть файл

@ -3,15 +3,13 @@
namespace Microcharts
{
using SkiaSharp;
using Microsoft.StandardUI;
/// <summary>
/// A data entry for a chart.
/// </summary>
public class ChartEntry
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.ChartEntry"/> class.
/// </summary>
@ -21,10 +19,6 @@ namespace Microcharts
this.Value = value;
}
#endregion
#region Properties
/// <summary>
/// Gets the value.
/// </summary>
@ -47,14 +41,12 @@ namespace Microcharts
/// Gets or sets the color of the fill.
/// </summary>
/// <value>The color of the fill.</value>
public SKColor Color { get; set; } = SKColors.Black;
public Color Color { get; set; } = Colors.Black;
/// <summary>
/// Gets or sets the color of the text (for the caption label).
/// </summary>
/// <value>The color of the text.</value>
public SKColor TextColor { get; set; } = SKColors.Gray;
#endregion
public Color TextColor { get; set; } = Colors.Gray;
}
}

Просмотреть файл

@ -7,7 +7,7 @@ using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using Microsoft.StandardUI.Media;
using Microsoft.StandardUI.Shapes;
using static Microsoft.StandardUI.FactoryExtensions;
using static Microsoft.StandardUI.FactoryStatics;
using SkiaSharp;
namespace Microcharts
@ -19,8 +19,6 @@ namespace Microcharts
/// </summary>
public class BarChart : PointChart
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.BarChart"/> class.
/// </summary>
@ -29,27 +27,19 @@ namespace Microcharts
PointSize = 0;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the bar background area alpha.
/// </summary>
/// <value>The bar area alpha.</value>
public byte BarAreaAlpha { get; set; } = 32;
#endregion
#region Methods
/// <summary>
/// Draws the content of the chart onto the specified canvas.
/// </summary>
/// <param name="canvas">The output canvas.</param>
/// <param name="width">The width of the chart.</param>
/// <param name="height">The height of the chart.</param>
public override void DrawContent(SKCanvas canvas, int width, int height)
public override void DrawContent(ICanvas canvas, int width, int height)
{
if (Entries != null)
{
@ -62,7 +52,7 @@ namespace Microcharts
var headerHeight = CalculateFooterHeaderHeight(valueLabelSizes, ValueLabelOrientation);
var itemSize = CalculateItemSize(width, height, footerHeight, headerHeight);
var origin = CalculateYOrigin(itemSize.Height, headerHeight);
var origin = CalculateYOrigin((float) itemSize.Height, headerHeight);
var points = CalculatePoints(itemSize, origin, headerHeight);
DrawBarAreas(canvas, points, itemSize, headerHeight);
@ -81,7 +71,7 @@ namespace Microcharts
/// <param name="itemSize">The item size.</param>
/// <param name="origin">The origin.</param>
/// <param name="headerHeight">The Header height.</param>
protected void DrawBars(ICanvas canvas, Point[] points, Size itemSize, float origin, float headerHeight)
protected void DrawBars(ICanvas canvas, Point[] points, Size itemSize, double origin, double headerHeight)
{
const float MinBarHeight = 4;
if (points.Length > 0)
@ -91,27 +81,19 @@ namespace Microcharts
var entry = Entries.ElementAt(i);
var point = points[i];
using (var paint = new SKPaint
var x = point.X - (itemSize.Width / 2);
var y = Math.Min(origin, point.Y);
var height = Math.Max(MinBarHeight, Math.Abs(origin - point.Y));
if (height < MinBarHeight)
{
Style = SKPaintStyle.Fill,
Color = entry.Color,
})
{
var x = point.X - (itemSize.Width / 2);
var y = Math.Min(origin, point.Y);
var height = Math.Max(MinBarHeight, Math.Abs(origin - point.Y));
if (height < MinBarHeight)
height = MinBarHeight;
if (y + height > Margin + itemSize.Height)
{
height = MinBarHeight;
if (y + height > Margin + itemSize.Height)
{
y = headerHeight + itemSize.Height - height;
}
y = headerHeight + itemSize.Height - height;
}
var rect = SKRect.Create(x, y, itemSize.Width, height);
canvas.DrawRect(rect, paint);
}
canvas.Add(x, y, Rectangle() .Width(itemSize.Width) .Height(height) .Fill(SolidColorBrush().Color(entry.Color)));
}
}
}
@ -123,7 +105,7 @@ namespace Microcharts
/// <param name="points">The entry points.</param>
/// <param name="itemSize">The item size.</param>
/// <param name="headerHeight">The header height.</param>
protected void DrawBarAreas(ICanvas canvas, Point[] points, Size itemSize, float headerHeight)
protected void DrawBarAreas(ICanvas canvas, Point[] points, Size itemSize, double headerHeight)
{
if (points.Length > 0 && PointAreaAlpha > 0)
{
@ -132,28 +114,18 @@ namespace Microcharts
var entry = Entries.ElementAt(i);
var point = points[i];
using (var paint = new SKPaint
{
Style = SKPaintStyle.Fill,
Color = entry.Color.WithAlpha((byte)(this.BarAreaAlpha * this.AnimationProgress)),
})
{
var max = entry.Value > 0 ? headerHeight : headerHeight + itemSize.Height;
var height = Math.Abs(max - point.Y);
var y = Math.Min(max, point.Y);
canvas.DrawRect(SKRect.Create(point.X - (itemSize.Width / 2), y, itemSize.Width, height), paint);
var color = entry.Color.WithA((byte)(this.BarAreaAlpha * this.AnimationProgress));
var brush = SolidColorBrush();
brush.Color = color;
var rect = Rectangle();
rect.Width = itemSize.Width;
rect.Height = height;
var max = entry.Value > 0 ? headerHeight : headerHeight + itemSize.Height;
var height = Math.Abs(max - point.Y);
var y = Math.Min(max, point.Y);
canvas.Children.Add(rect);
}
canvas.Add(point.X - (itemSize.Width / 2), y, Rectangle().Width(itemSize.Width).Height(height).Fill(brush));
}
}
}
#endregion
}
}

Просмотреть файл

@ -9,41 +9,30 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using SkiaSharp;
using static Microsoft.StandardUI.FactoryStatics;
namespace Microcharts
{
/// <summary>
/// A chart.
/// </summary>
public abstract class Chart : INotifyPropertyChanged
public abstract class Chart : StandardUIUserControl, INotifyPropertyChanged
{
#region Fields
private IEnumerable<ChartEntry> entries;
private float animationProgress, margin = 20, labelTextSize = 16;
private SKColor backgroundColor = SKColors.White;
private SKColor labelColor = SKColors.Gray;
private float animationProgress;
private double margin = 20, labelTextSize = 16;
private Color backgroundColor = Colors.White;
private Color labelColor = Colors.Gray;
private SKTypeface typeface;
private float? internalMinValue, internalMaxValue;
private double? internalMinValue, internalMaxValue;
private bool isAnimated = true, isAnimating = false;
private TimeSpan animationDuration = TimeSpan.FromSeconds(1.5f);
private Task invalidationPlanification;
private CancellationTokenSource animationCancellation;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.Chart"/> class.
/// </summary>
@ -52,10 +41,6 @@ namespace Microcharts
PropertyChanged += OnPropertyChanged;
}
#endregion
#region Events
/// <summary>
/// Occurs when property changed.
/// </summary>
@ -66,8 +51,6 @@ namespace Microcharts
/// </summary>
public event EventHandler Invalidated;
#endregion
#region Properties
/// <summary>
@ -124,7 +107,7 @@ namespace Microcharts
/// Gets or sets the global margin.
/// </summary>
/// <value>The margin.</value>
public float Margin
public double Margin
{
get => margin;
set => Set(ref margin, value);
@ -148,7 +131,7 @@ namespace Microcharts
/// Gets or sets the text size of the labels.
/// </summary>
/// <value>The size of the label text.</value>
public float LabelTextSize
public double LabelTextSize
{
get => labelTextSize;
set => Set(ref labelTextSize, value);
@ -164,7 +147,7 @@ namespace Microcharts
/// Gets or sets the color of the chart background.
/// </summary>
/// <value>The color of the background.</value>
public SKColor BackgroundColor
public Color BackgroundColor
{
get => backgroundColor;
set => Set(ref backgroundColor, value);
@ -174,7 +157,7 @@ namespace Microcharts
/// Gets or sets the color of the labels.
/// </summary>
/// <value>The color of the labels.</value>
public SKColor LabelColor
public Color LabelColor
{
get => labelColor;
set => Set(ref labelColor, value);
@ -195,7 +178,7 @@ namespace Microcharts
/// minimal entry value.
/// </summary>
/// <value>The minimum value.</value>
public float MinValue
public double MinValue
{
get
{
@ -220,7 +203,7 @@ namespace Microcharts
/// maximum entry value.
/// </summary>
/// <value>The minimum value.</value>
public float MaxValue
public double MaxValue
{
get
{
@ -249,7 +232,7 @@ namespace Microcharts
/// Gets or sets the internal minimum value (that can be null).
/// </summary>
/// <value>The internal minimum value.</value>
protected float? InternalMinValue
protected double? InternalMinValue
{
get => internalMinValue;
set
@ -265,7 +248,7 @@ namespace Microcharts
/// Gets or sets the internal max value (that can be null).
/// </summary>
/// <value>The internal max value.</value>
protected float? InternalMaxValue
protected double? InternalMaxValue
{
get => internalMaxValue;
set
@ -287,15 +270,23 @@ namespace Microcharts
#region Methods
public void Build()
{
ICanvas canvas = Canvas() .Width(Width) .Height(Height);
Draw(canvas, (int) Width, (int) Height);
Content = canvas;
}
/// <summary>
/// Draw the graph onto the specified canvas.
/// </summary>
/// <param name="canvas">The canvas.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
public void Draw(SKCanvas canvas, int width, int height)
public void Draw(ICanvas canvas, int width, int height)
{
canvas.Clear(BackgroundColor);
//canvas.Clear(BackgroundColor);
DrawableChartArea = new SKRect(0, 0, width, height);
@ -308,7 +299,7 @@ namespace Microcharts
/// <param name="canvas">The canvas.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
public abstract void DrawContent(SKCanvas canvas, int width, int height);
public abstract void DrawContent(ICanvas canvas, int width, int height);
/// <summary>
/// Draws caption elements on the right or left side of the chart.
@ -319,8 +310,9 @@ namespace Microcharts
/// <param name="entries">The entries.</param>
/// <param name="isLeft">If set to <c>true</c> is left.</param>
/// <param name="isGraphCentered">Should the chart in the center always?</param>
protected void DrawCaptionElements(SKCanvas canvas, int width, int height, List<ChartEntry> entries, bool isLeft, bool isGraphCentered)
protected void DrawCaptionElements(ICanvas canvas, int width, int height, List<ChartEntry> entries, bool isLeft, bool isGraphCentered)
{
#if LATER
var totalMargin = 2 * Margin;
var availableHeight = height - (2 * totalMargin);
var x = isLeft ? Margin : (width - Margin - LabelTextSize);
@ -342,9 +334,9 @@ namespace Microcharts
{
var captionMargin = LabelTextSize * 0.60f;
var captionX = isLeft ? Margin : width - Margin - LabelTextSize;
var valueColor = entry.Color.WithAlpha((byte)(entry.Color.Alpha * AnimationProgress));
var lblColor = entry.TextColor.WithAlpha((byte)(entry.TextColor.Alpha * AnimationProgress));
var rect = SKRect.Create(captionX, y, LabelTextSize, LabelTextSize);
var valueColor = entry.Color.WithA((byte)(entry.Color.A * AnimationProgress));
var lblColor = entry.TextColor.WithA((byte)(entry.TextColor.A * AnimationProgress));
var rect = new Rect(captionX, y, LabelTextSize, LabelTextSize);
using (var paint = new SKPaint
{
@ -396,6 +388,7 @@ namespace Microcharts
}
}
}
#endif
}
/// <summary>
@ -444,9 +437,6 @@ namespace Microcharts
}
}
#region Weak event handlers
/// <summary>
/// Adds a weak event handler to observe invalidate changes.
/// </summary>
@ -461,8 +451,6 @@ namespace Microcharts
return weakHandler;
}
#endregion
/// <summary>
/// Animates the view.
/// </summary>
@ -565,8 +553,6 @@ namespace Microcharts
}
}
#region INotifyPropertyChanged
/// <summary>
/// Raises the property change.
/// </summary>
@ -596,8 +582,6 @@ namespace Microcharts
return false;
}
#endregion
#endregion
#endregion
}
}

Просмотреть файл

@ -8,6 +8,7 @@ using SkiaSharp;
namespace Microcharts
{
#if LATER
/// <summary>
/// ![chart](../images/Donut.png)
///
@ -15,7 +16,7 @@ namespace Microcharts
/// </summary>
public class DonutChart : Chart
{
#region Properties
#region Properties
/// <summary>
/// Gets or sets the radius of the hole in the center of the chart.
@ -33,9 +34,9 @@ namespace Microcharts
/// </summary>
public GraphPosition GraphPosition { get; set; } = GraphPosition.AutoFill;
#endregion
#endregion
#region Methods
#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
{
@ -134,6 +135,7 @@ namespace Microcharts
DrawCaptionElements(canvas, width, height, leftValues, true, isGraphCentered);
}
#endregion
#endregion
}
#endif
}

Просмотреть файл

@ -1,7 +1,11 @@
// Copyright (c) Aloïs DENIEL. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#if LATER
using System.Linq;
using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using SkiaSharp;
namespace Microcharts
@ -13,8 +17,6 @@ namespace Microcharts
/// </summary>
public class LineChart : PointChart
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.LineChart"/> class.
/// </summary>
@ -23,10 +25,6 @@ namespace Microcharts
this.PointSize = 10;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the size of the line.
/// </summary>
@ -51,11 +49,7 @@ namespace Microcharts
/// <value>The state of the fadeout gradient.</value>
public bool EnableYFadeOutGradient { get; set; } = false;
#endregion
#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
public override void DrawContent(ICanvas canvas, int width, int height)
{
if (this.Entries != null)
{
@ -79,7 +73,7 @@ namespace Microcharts
}
}
protected void DrawLine(SKCanvas canvas, SKPoint[] points, SKSize itemSize)
protected void DrawLine(ICanvas canvas, Point[] points, Size itemSize)
{
if (points.Length > 1 && this.LineMode != LineMode.None)
{
@ -121,7 +115,7 @@ namespace Microcharts
}
}
protected void DrawArea(SKCanvas canvas, SKPoint[] points, SKSize itemSize, float origin)
protected void DrawArea(ICanvas canvas, Point[] points, Size itemSize, double origin)
{
if (this.LineAreaAlpha > 0 && points.Length > 1)
{
@ -178,7 +172,7 @@ namespace Microcharts
return (point, currentControl, nextPoint, nextControl);
}
private SKShader CreateXGradient(SKPoint[] points, byte alpha = 255)
private SKShader CreateXGradient(Point[] points, byte alpha = 255)
{
var startX = points.First().X;
var endX = points.Last().X;
@ -187,12 +181,12 @@ namespace Microcharts
return SKShader.CreateLinearGradient(
new SKPoint(startX, 0),
new SKPoint(endX, 0),
this.Entries.Select(x => x.Color.WithAlpha(alpha)).ToArray(),
this.Entries.Select(x => x.Color.WithA(alpha)).ToArray(),
null,
SKShaderTileMode.Clamp);
}
private SKShader CreateYGradient(SKPoint[] points, byte alpha = 255)
private SKShader CreateYGradient(Point[] points, byte alpha = 255)
{
var startY = points.Max(i => i.Y);
var endY = 0;
@ -204,7 +198,7 @@ namespace Microcharts
null,
SKShaderTileMode.Clamp);
}
#endregion
}
}
#endif

Просмотреть файл

@ -3,6 +3,7 @@
namespace Microcharts
{
#if LATER
/// <summary>
/// ![chart](../images/Donut.png)
///
@ -10,7 +11,7 @@ namespace Microcharts
/// </summary>
public class PieChart : DonutChart
{
#region Constructors
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.PieChart"/> class.
@ -20,6 +21,7 @@ namespace Microcharts
this.HoleRadius = 0;
}
#endregion
#endregion
}
#endif
}

Просмотреть файл

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using SkiaSharp;
using SkiaSharp.HarfBuzz;
@ -17,8 +19,6 @@ namespace Microcharts
/// </summary>
public class PointChart : Chart
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="T:Microcharts.PointChart"/> class.
/// </summary>
@ -28,16 +28,8 @@ namespace Microcharts
ValueLabelOrientation = Orientation.Default;
}
#endregion
#region Fields
private Orientation labelOrientation, valueLabelOrientation;
#endregion
#region Properties
/// <summary>
/// Gets or sets the size of the point.
/// </summary>
@ -76,13 +68,9 @@ namespace Microcharts
set => valueLabelOrientation = (value == Orientation.Default) ? Orientation.Vertical : value;
}
private float ValueRange => MaxValue - MinValue;
private double ValueRange => MaxValue - MinValue;
#endregion
#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
public override void DrawContent(ICanvas canvas, int width, int height)
{
if (Entries != null)
{
@ -105,7 +93,7 @@ namespace Microcharts
}
}
protected float CalculateYOrigin(float itemHeight, float headerHeight)
protected double CalculateYOrigin(double itemHeight, double headerHeight)
{
if (MaxValue <= 0)
{
@ -120,17 +108,17 @@ namespace Microcharts
return headerHeight + ((MaxValue / ValueRange) * itemHeight);
}
protected SKSize CalculateItemSize(int width, int height, float footerHeight, float headerHeight)
protected Size CalculateItemSize(int width, int height, double footerHeight, double headerHeight)
{
var total = Entries.Count();
var w = (width - ((total + 1) * Margin)) / total;
var h = height - Margin - footerHeight - headerHeight;
return new SKSize(w, h);
return new Size(w, h);
}
protected SKPoint[] CalculatePoints(SKSize itemSize, float origin, float headerHeight)
protected Point[] CalculatePoints(Size itemSize, double origin, double headerHeight)
{
var result = new List<SKPoint>();
var result = new List<Point>();
for (int i = 0; i < Entries.Count(); i++)
{
@ -139,31 +127,31 @@ namespace Microcharts
var x = Margin + (itemSize.Width / 2) + (i * (itemSize.Width + Margin));
var y = headerHeight + ((1 - AnimationProgress) * (origin - headerHeight) + (((MaxValue - value) / ValueRange) * itemSize.Height) * AnimationProgress);
var point = new SKPoint(x, y);
var point = new Point(x, y);
result.Add(point);
}
return result.ToArray();
}
protected void DrawHeader(SKCanvas canvas, string[] labels, SKRect[] labelSizes, SKPoint[] points, SKSize itemSize, int height, float headerHeight)
protected void DrawHeader(ICanvas canvas, string[] labels, Rect[] labelSizes, Point[] points, Size itemSize, int height, double headerHeight)
{
DrawLabels(canvas,
labels,
points.Select(p => new SKPoint(p.X, headerHeight - Margin)).ToArray(),
points.Select(p => new Point(p.X, headerHeight - Margin)).ToArray(),
labelSizes,
Entries.Select(x => x.Color.WithAlpha((byte)(255 * AnimationProgress))).ToArray(),
Entries.Select(x => x.Color.WithA((byte)(255 * AnimationProgress))).ToArray(),
ValueLabelOrientation,
true,
itemSize,
height);
}
protected void DrawFooter(SKCanvas canvas, string[] labels, SKRect[] labelSizes, SKPoint[] points, SKSize itemSize, int height, float footerHeight)
protected void DrawFooter(ICanvas canvas, string[] labels, Rect[] labelSizes, Point[] points, Size itemSize, int height, double footerHeight)
{
DrawLabels(canvas,
labels,
points.Select(p => new SKPoint(p.X, height - footerHeight + Margin)).ToArray(),
points.Select(p => new Point(p.X, height - footerHeight + Margin)).ToArray(),
labelSizes,
Entries.Select(x => LabelColor).ToArray(),
LabelOrientation,
@ -172,7 +160,7 @@ namespace Microcharts
height);
}
protected void DrawPoints(SKCanvas canvas, SKPoint[] points)
protected void DrawPoints(ICanvas canvas, Point[] points)
{
if (points.Length > 0 && PointMode != PointMode.None)
{
@ -185,8 +173,9 @@ namespace Microcharts
}
}
protected void DrawPointAreas(SKCanvas canvas, SKPoint[] points, float origin)
protected void DrawPointAreas(ICanvas canvas, Point[] points, double origin)
{
#if LATER
if (points.Length > 0 && PointAreaAlpha > 0)
{
for (int i = 0; i < points.Length; i++)
@ -195,11 +184,11 @@ namespace Microcharts
var point = points[i];
var y = Math.Min(origin, point.Y);
using (var shader = SKShader.CreateLinearGradient(new SKPoint(0, origin), new SKPoint(0, point.Y), new[] { entry.Color.WithAlpha(PointAreaAlpha), entry.Color.WithAlpha((byte)(PointAreaAlpha / 3)) }, null, SKShaderTileMode.Clamp))
using (var shader = SKShader.CreateLinearGradient(new SKPoint(0, origin), new SKPoint(0, point.Y), new[] { entry.Color.WithA(PointAreaAlpha), entry.Color.WithA((byte)(PointAreaAlpha / 3)) }, null, SKShaderTileMode.Clamp))
using (var paint = new SKPaint
{
Style = SKPaintStyle.Fill,
Color = entry.Color.WithAlpha(PointAreaAlpha),
Color = entry.Color.WithA(PointAreaAlpha),
})
{
paint.Shader = shader;
@ -208,6 +197,7 @@ namespace Microcharts
}
}
}
#endif
}
/// <summary>
@ -222,8 +212,9 @@ namespace Microcharts
/// <param name="isTop"></param>
/// <param name="itemSize"></param>
/// <param name="height"></param>
protected void DrawLabels(SKCanvas canvas,string[] texts, SKPoint[] points, SKRect[] sizes, SKColor[] colors, Orientation orientation, bool isTop, SKSize itemSize, float height)
protected void DrawLabels(ICanvas canvas,string[] texts, Point[] points, Rect[] sizes, Color[] colors, Orientation orientation, bool isTop, Size itemSize, float height)
{
#if LATER
if (points.Length > 0)
{
var maxWidth = sizes.Max(x => x.Width);
@ -300,6 +291,7 @@ namespace Microcharts
}
}
}
#endif
}
/// <summary>
@ -307,7 +299,7 @@ namespace Microcharts
/// </summary>
/// <returns>The footer height.</returns>
/// <param name="valueLabelSizes">Value label sizes.</param>
protected float CalculateFooterHeaderHeight(SKRect[] valueLabelSizes, Orientation orientation)
protected double CalculateFooterHeaderHeight(Rect[] valueLabelSizes, Orientation orientation)
{
var result = Margin;
@ -334,8 +326,9 @@ namespace Microcharts
/// Measures the value labels.
/// </summary>
/// <returns>The value labels.</returns>
protected SKRect[] MeasureLabels(string[] labels)
protected Rect[] MeasureLabels(string[] labels)
{
#if LATER
using (var paint = new SKPaint())
{
paint.TextSize = LabelTextSize;
@ -351,8 +344,8 @@ namespace Microcharts
return bounds;
}).ToArray();
}
#endif
return labels.Select(text => new Rect(0, 0, 50, 50)).ToArray();
}
#endregion
}
}

Просмотреть файл

@ -7,6 +7,7 @@ using SkiaSharp;
namespace Microcharts
{
#if LATER
/// <summary>
/// ![chart](../images/Radar.png)
///
@ -14,13 +15,13 @@ namespace Microcharts
/// </summary>
public class RadarChart : Chart
{
#region Constants
#region Constants
private const float Epsilon = 0.01f;
#endregion
#endregion
#region Properties
#region Properties
/// <summary>
/// Gets or sets the size of the line.
@ -58,9 +59,9 @@ namespace Microcharts
private float ValueRange => this.AbsoluteMaximum - this.AbsoluteMinimum;
#endregion
#endregion
#region Methods
#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
{
@ -207,6 +208,7 @@ namespace Microcharts
}
}
#endregion
#endregion
}
#endif
}

Просмотреть файл

@ -7,6 +7,7 @@ using SkiaSharp;
namespace Microcharts
{
#if LATER
/// <summary>
/// ![chart](../images/RadialGauge.png)
///
@ -14,7 +15,7 @@ namespace Microcharts
/// </summary>
public class RadialGaugeChart : Chart
{
#region Properties
#region Properties
/// <summary>
/// Gets or sets the size of each gauge. If negative, then its will be calculated from the available space.
@ -40,9 +41,9 @@ namespace Microcharts
private float ValueRange => AbsoluteMaximum - AbsoluteMinimum;
#endregion
#endregion
#region Methods
#region Methods
public void DrawGaugeArea(SKCanvas canvas, ChartEntry entry, float radius, int cx, int cy, float strokeWidth)
{
@ -112,6 +113,7 @@ namespace Microcharts
DrawCaptionElements(canvas, width, height, leftValues, true, false);
}
#endregion
#endregion
}
#endif
}

Просмотреть файл

@ -1,8 +1,13 @@
// Copyright (c) Aloïs DENIEL. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using Microsoft.StandardUI.Media;
using Microsoft.StandardUI.Shapes;
using SkiaSharp;
using SkiaSharp.HarfBuzz;
using static Microsoft.StandardUI.FactoryStatics;
namespace Microcharts
{
@ -101,27 +106,16 @@ namespace Microcharts
/// <param name="color">The fill color.</param>
/// <param name="size">The point size.</param>
/// <param name="mode">The point mode.</param>
public static void DrawPoint(this SKCanvas canvas, SKPoint point, SKColor color, float size, PointMode mode)
public static void DrawPoint(this ICanvas canvas, Point point, Color color, float size, PointMode mode)
{
using (var paint = new SKPaint
{
Style = SKPaintStyle.Fill,
IsAntialias = true,
Color = color,
})
{
switch (mode)
{
case PointMode.Square:
canvas.DrawRect(SKRect.Create(point.X - (size / 2), point.Y - (size / 2), size, size), paint);
break;
IShape shape;
if (mode == PointMode.Square)
shape = Rectangle();
else if (mode == PointMode.Circle)
shape = Ellipse();
else return;
case PointMode.Circle:
paint.IsAntialias = true;
canvas.DrawCircle(point.X, point.Y, size / 2, paint);
break;
}
}
canvas.Add(point.X - (size / 2), point.Y - (size / 2), shape.Width(size).Height(size).Fill(SolidColorBrush().Color(color)));
}
/// <summary>

Просмотреть файл

@ -8,18 +8,10 @@ namespace Microcharts
internal static class RadialHelpers
{
#region Constants
public const float PI = (float)Math.PI;
private const float UprightAngle = PI / 2f;
private const float TotalAngle = 2f * PI;
#endregion
#region Sectors
public static SKPoint GetCirclePoint(float r, float angle)
{
return new SKPoint(r * (float)Math.Cos(angle), r * (float)Math.Sin(angle));
@ -82,7 +74,5 @@ namespace Microcharts
return path;
}
#endregion
}
}