Skip to content

Commit

Permalink
Merge pull request #700 from beto-rodriguez/dev
Browse files Browse the repository at this point in the history
beta.513
  • Loading branch information
beto-rodriguez committed Oct 20, 2022
2 parents 61c6113 + 74aa5d5 commit 79c289d
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/LiveChartsCore/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ internal virtual void InvokePointerDown(LvcPoint point, bool isSecondaryAction)

// fire the visual elements event.
// ToDo: VisualElements should be of type VisualElement<T>
var iterableVisualElements = VisualElements.Cast<VisualElement<TDrawingContext>>().Where(x => x.IsHitBy(point));
var iterableVisualElements = VisualElements.Cast<VisualElement<TDrawingContext>>().SelectMany(x => x.IsHitBy(point));
View.OnVisualElementPointerDown(iterableVisualElements, point);
}

Expand Down
2 changes: 1 addition & 1 deletion src/LiveChartsCore/LiveChartsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<AssemblyName>LiveChartsCore</AssemblyName>
<RootNamespace>LiveChartsCore</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for .Net, this is the core package probably you need another package also unless you are building your own backed.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
10 changes: 6 additions & 4 deletions src/LiveChartsCore/VisualElements/VisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using LiveChartsCore.Drawing;
Expand Down Expand Up @@ -184,14 +185,15 @@ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName
/// then it is the index Scaler.</param>
protected internal abstract void OnInvalidated(Chart<TDrawingContext> chart, Scaler? primaryScaler, Scaler? secondaryScaler);

internal virtual bool IsHitBy(LvcPoint point)
internal virtual IEnumerable<VisualElement<TDrawingContext>> IsHitBy(LvcPoint point)
{
var location = GetActualLocation();
var size = GetActualSize();

return
point.X >= location.X && point.X <= location.X + size.Width &&
point.Y >= location.Y && point.Y <= location.Y + size.Height;
// it returns an enumerable because there are more complex types where a visual can contain more than one element
if (point.X >= location.X && point.X <= location.X + size.Width &&
point.Y >= location.Y && point.Y <= location.Y + size.Height)
yield return this;
}

internal virtual void AlignToTopLeftCorner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netcoreapp2.0;netstandard2.0;net462;</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.Avalonia</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.Avalonia</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for AvaloniaUI.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WPF</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WPF</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WPF.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,16 @@ private void OnMouseWheel(object? sender, MouseEventArgs e)
var c = (CartesianChart<SkiaSharpDrawingContext>)core;
var p = e.Location;
c.Zoom(new LvcPoint(p.X, p.Y), e.Delta > 0 ? ZoomDirection.ZoomIn : ZoomDirection.ZoomOut);
Capture = true;
}

private void OnMouseDown(object? sender, MouseEventArgs e)
{
base.OnMouseDown(e);
if (ModifierKeys > 0) return;
core?.InvokePointerDown(new LvcPoint(e.Location.X, e.Location.Y), e.Button == MouseButtons.Right);
}

private void OnMouseUp(object? sender, MouseEventArgs e)
{
base.OnMouseUp(e);
core?.InvokePointerUp(new LvcPoint(e.Location.X, e.Location.Y), e.Button == MouseButtons.Right);
}
}
13 changes: 10 additions & 3 deletions src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/DefaultLegend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,26 @@ private void DrawAndMesure(IEnumerable<IChartSeries<SkiaSharpDrawingContext>> se
Width = (int)s.CanvasSchedule.Width,
Height = (int)s.CanvasSchedule.Height
});

var dh = (int)((s.CanvasSchedule.Height - size.Height) * 0.5f);
if (dh < 0) dh = 0;

p.Controls.Add(new Label
{
Text = s.Name,
Font = chart.LegendFont,
ForeColor = chart.LegendTextColor,
Location = new Point(6 + (int)s.CanvasSchedule.Width + 6, 0),
Location = new Point(6 + (int)s.CanvasSchedule.Width + 6, dh),
AutoSize = true
});

var thisW = size.Width + 36 + (int)s.CanvasSchedule.Width;
p.Width = (int)thisW + 6;
p.Height = (int)size.Height + 6;
h += size.Height + 6;

var mh = (int)(s.CanvasSchedule.Height > size.Height ? s.CanvasSchedule.Height : size.Height) + 6;

p.Height = mh;
h += mh;
w = thisW > w ? thisW : w;
}
h += 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,21 @@ private SizeF DrawAndMesure(IEnumerable<ChartPoint> tooltipPoints, Chart chart)
Width = (int)drawableSeries.CanvasSchedule.Width,
Height = (int)drawableSeries.CanvasSchedule.Height
});

var dh = (int)((drawableSeries.CanvasSchedule.Height - size.Height) * 0.5f);
if (dh < 0) dh = 0;

container.Controls.Add(new Label
{
Text = text,
Font = chart.TooltipFont,
ForeColor = chart.TooltipTextColor,
Location = new Point(6 + (int)drawableSeries.CanvasSchedule.Width + 6, (int)h + 6),
Location = new Point(6 + (int)drawableSeries.CanvasSchedule.Width + 6, (int)h + 6 + dh),
AutoSize = true
});

var thisW = size.Width + 18 + (int)drawableSeries.CanvasSchedule.Width;
h += size.Height + 6;
h += (int)(drawableSeries.CanvasSchedule.Height > size.Height ? drawableSeries.CanvasSchedule.Height : size.Height) + 6;
w = thisW > w ? thisW : w;
}

Expand All @@ -126,7 +130,7 @@ private SizeF DrawAndMesure(IEnumerable<ChartPoint> tooltipPoints, Chart chart)
container.Height = (int)h;

ResumeLayout();
return new SizeF(container.Width + 2* BorderThickness, container.Height + 2* BorderThickness);
return new SizeF(container.Width + 2 * BorderThickness, container.Height + 2* BorderThickness);
}

void IChartTooltip<SkiaSharpDrawingContext>.Hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WinForms</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WindowsForms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.XamarinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.XamarinForms</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for XamarinForms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Drawing SelectColor(SKColor color, float? strokeWidth = null, bool? isFil
}

/// <summary>
/// Sets the
/// Sets the clip rectangle of the selected paint.
/// </summary>
/// <returns></returns>
public Drawing SetClip(LvcRectangle? clipRectangle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<AssemblyName>LiveChartsCore.SkiaSharpView</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for .Net, this package contains the SkiaSharp backend.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Blazor.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.Eto</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.Eto</RootNamespace>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Eto.Forms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>

<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Maui.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>LiveChartsCore.SkiaSharpView.Maui</id>
<version>2.0.0-beta.512</version>
<version>2.0.0-beta.513</version>
<title>LiveChartsCore.SkiaSharpView.Maui</title>
<authors>BetoRodriguez</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand All @@ -17,23 +17,23 @@
<dependencies>
<group targetFramework="net6.0">
<dependency id="SkiaSharp.Views.Maui.Controls.Compatibility" version="2.88.3" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
<group targetFramework="net6.0-ios13.6">
<dependency id="SkiaSharp.Views.Maui.Controls.Compatibility" version="2.88.3" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
<group targetFramework="net6.0-maccatalyst13.5">
<dependency id="SkiaSharp.Views.Maui.Controls.Compatibility" version="2.88.3" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
<group targetFramework="net6.0-android30.0">
<dependency id="SkiaSharp.Views.Maui.Controls.Compatibility" version="2.88.3" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
<group targetFramework="net6.0-windows10.0.18362">
<dependency id="SkiaSharp.Views.Maui.Controls.Compatibility" version="2.88.3" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
</dependencies>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Uno.WinUI.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Uno.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>

<Version>2.0.0-beta.512</Version>
<Version>2.0.0-beta.513</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WinUI 3.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>LiveChartsCore.SkiaSharpView.WinUI</id>
<version>2.0.0-beta.512</version>
<version>2.0.0-beta.513</version>
<title>LiveChartsCore.SkiaSharpView.WinUI</title>
<authors>BetoRodriguez</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand All @@ -20,8 +20,8 @@
<!--not necessary in net5+-->
<!--<dependency id="Newtonsoft.Json" version="[13.0.1]" />-->
<dependency id="SkiaSharp.Views.WinUI" version="2.88.3" />
<dependency id="LiveChartsCore" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.512" />
<dependency id="LiveChartsCore" version="2.0.0-beta.513" />
<dependency id="LiveChartsCore.SkiaSharpView" version="2.0.0-beta.513" />
</group>
</dependencies>
</metadata>
Expand Down

0 comments on commit 79c289d

Please sign in to comment.