Closed vadimffe closed 1 year ago
Just discovered some possible fixes can be implemented in future releases. This particular example is about circles in legend displayed next to chart items. Value can be passed from CustomLegend
class. However this would require additional parameters to AsDrawnControl
method as follows.
using LiveChartsCore.Drawing;
using LiveChartsCore.Kernel.Drawing;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.VisualElements;
namespace LiveChartsCore.SkiaSharpView.VisualElements
{
/// <summary>
/// Defines the visual elements extensions class.
/// </summary>
public static class VisualElementsExtensions
{
/// <summary>
/// Creates a relative panel control from a given sketch.
/// </summary>
public static RelativePanel<SkiaSharpDrawingContext> AsDrawnControl(
this Sketch<SkiaSharpDrawingContext> sketch, float width = float.NaN, float height = float.NaN, int baseZIndex = 10050)
{
var relativePanel = new RelativePanel<SkiaSharpDrawingContext>();
if (!float.IsNaN(width) && !float.IsNaN(height))
{
relativePanel.Size = new LvcSize(width, height);
}
foreach (var schedule in sketch.PaintSchedules)
{
foreach (var g in schedule.Geometries)
{
var sizedGeometry = (ISizedGeometry<SkiaSharpDrawingContext>)g;
var vgv = new VariableGeometryVisual(sizedGeometry);
if (!float.IsNaN(width))
{
vgv.Width = width == float.NaN ? sizedGeometry.Width : width;
}
if (!float.IsNaN(height))
{
vgv.Height = height == float.NaN ? sizedGeometry.Height : height;
}
schedule.PaintTask.ZIndex = schedule.PaintTask.ZIndex + 1 + baseZIndex;
if (schedule.PaintTask.IsFill) vgv.Fill = schedule.PaintTask;
if (schedule.PaintTask.IsStroke) vgv.Stroke = schedule.PaintTask;
_ = relativePanel.Children.Add(vgv);
}
}
return relativePanel;
}
}
}
Then width and heigh can be either increased or passed directly as values. In case on increasing, for example:
if (!float.IsNaN(width))
{
vgv.Width = sizedGeometry.Width * width;
}
if (!float.IsNaN(height))
{
vgv.Height = sizedGeometry.Height * height;
}
Then spacing between circles and labels should be also increased. Same for legend and tooltip
This is now fixed with the referenced commit and will be included in the next version of the library. thanks for the report.
Describe the bug 2.0.0-beta.701 does not take screen resolution and scaling in account for tooltips and legends. Setting font size to constant value does not work on different screen size and scaling. For example setting
TooltipTextSize="14"
on 3000x2000 and screen scale 200% looks too small, while same setup on 1920x1080 and screen scale 125% looks fine.Desktop (please complete the following information):