diff --git a/.editorconfig b/.editorconfig index 32b10a3eb..e38472d65 100644 --- a/.editorconfig +++ b/.editorconfig @@ -111,7 +111,7 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent csharp_prefer_simple_default_expression = true:suggestion # Expression-bodied members -csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_methods = when_on_single_line:warning csharp_style_expression_bodied_constructors = false csharp_style_expression_bodied_operators = true:silent csharp_style_expression_bodied_properties = true:silent diff --git a/.github/workflows/compile-all-views.yml b/.github/workflows/compile-all-views.yml index e3b238bfa..aa883600b 100644 --- a/.github/workflows/compile-all-views.yml +++ b/.github/workflows/compile-all-views.yml @@ -21,9 +21,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 1e823bcb4..c374437a6 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -21,14 +21,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - - name: Install MAUI workload - run: dotnet workload install maui - - name: Run unit tests run: dotnet test ./tests/LiveChartsCore.UnitTesting diff --git a/docs/LiveChartsCore.SkiaSharpView.Avalonia.xml b/docs/LiveChartsCore.SkiaSharpView.Avalonia.xml deleted file mode 100644 index ab66db036..000000000 --- a/docs/LiveChartsCore.SkiaSharpView.Avalonia.xml +++ /dev/null @@ -1,1135 +0,0 @@ - - - - LiveChartsCore.SkiaSharpView.Avalonia - - - - - - - - The core - - - - - The legend - - - - - The tooltip - - - - - Initializes a new instance of the class. - - Default colors are not valid - - - - The draw margin property - - - - - The series property - - - - - The x axes property - - - - - The y axes property - - - - - The zoom mode property - - - - - The zooming speed property - - - - - The animations speed property - - - - - The easing function property - - - - - The tool tip template property - - - - - The tool tip position property - - - - - The tool tip finding strategy property - - - - - The tool tip font family property - - - - - The tool tip font size property - - - - - The tool tip font weight property - - - - - The tool tip font style property - - - - - The tool tip text brush property - - - - - The tool tip background property - - - - - The legend position property - - - - - The legend orientation property - - - - - The legend template property - - - - - The legend font family property - - - - - The legend font size property - - - - - The legend font weight property - - - - - The legend font style property - - - - - The legend text brush property - - - - - The legend background property - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the tool tip data template. - - - The tool tip template. - - - - - Gets or sets the tool tip default font family. - - - The tool tip font family. - - - - - Gets or sets the default size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the tool tip default font weight. - - - The tool tip font weight. - - - - - Gets or sets the tool tip default font style. - - - The tool tip font style. - - - - - Gets or sets the tool tip default text brush. - - - The tool tip text brush. - - - - - Gets or sets the tool tip default background. - - - The tool tip background. - - - - - - - - - - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the legend default font family. - - - The legend font family. - - - - - Gets or sets the size of the legend default font. - - - The size of the legend font. - - - - - Gets or sets the legend default font weight. - - - The legend font weight. - - - - - Gets or sets the legend default font style. - - - The legend font style. - - - - - Gets or sets the legend default text brush. - - - The legend text brush. - - - - - Gets or sets the legend default background. - - - The legend background. - - - - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - - - - Defines a default legend for a chart. - - - - - Initializes a new instance of the class. - - default template not found - - - - The orientation property - - - - - The dock property - - - - - Gets or sets the custom template. - - - The custom template. - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the text brush. - - - The text brush. - - - - - Gets or sets the orientation. - - - The orientation. - - - - - Gets or sets the dock. - - - The dock. - - - - - Builds the content. - - - - - Defines a default tool tip for a chart control. - - - - - Initializes a new instance of the class. - - default template not found - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the points. - - - The points. - - - - - Gets or sets the tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the tool tip font weight. - - - The tool tip font weight. - - - - - Gets or sets the tool tip font style. - - - The tool tip font style. - - - - - Gets or sets the tool tip text brush. - - - The tool tip text brush. - - - - - Gets or sets the tooltip background. - - - The tooltip background. - - - - - Builds the content. - - - - - - Defines a chart only for the avalonia ui framework - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the tool tip font weight. - - - The tool tip font weight. - - - - - Gets or sets the tool tip font style. - - - The tool tip font style. - - - - - Gets or sets the tool tip text brush. - - - The tool tip text brush. - - - - - Gets or sets the tool tip background. - - - The tool tip background. - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the legend font family. - - - The legend font family. - - - - - Gets or sets the size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the legend font weight. - - - The legend font weight. - - - - - Gets or sets the legend font style. - - - The legend font style. - - - - - Gets or sets the legend text brush. - - - The legend text brush. - - - - - Gets or sets the legend background. - - - The legend background. - - - - - The legend binding context. - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the font weight. - - - The font weight. - - - - - Gets or sets the font style. - - - The font style. - - - - - Gets or sets the text brush. - - - The text brush. - - - - - Gets or sets the background. - - - The background. - - - - - The motion canvas control for avalonia, . - - - - - Initializes a new instance of the class. - - - - - The paint tasks property - - - - - The back color property - - - - - Gets or sets the paint tasks. - - - The paint tasks. - - - - - Gets or sets the frames per second. - - - The frames per second. - - - - - Gets or sets the color of the back. - - - The color of the back. - - - - - Gets the canvas core. - - - The canvas core. - - - - - - - - - - - - - - The core - - - - - The legend - - - - - The tooltip - - - - - Initializes a new instance of the class. - - Default colors are not valid - - - - The draw margin property - - - - - The series property - - - - - The initial rotation property - - - - - The maximum angle property - - - - - The total property - - - - - The animations speed property - - - - - The easing function property - - - - - The tool tip template property - - - - - The tool tip position property - - - - - The tool tip finding strategy property - - - - - The tool tip font family property - - - - - The tool tip font size property - - - - - The tool tip font weight property - - - - - The tool tip font style property - - - - - The tool tip text brush property - - - - - The tool tip background property - - - - - The legend position property - - - - - The legend orientation property - - - - - The legend template property - - - - - The legend font family property - - - - - The legend font size property - - - - - The legend font weight property - - - - - The legend font style property - - - - - The legend text brush property - - - - - The legend background property - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the tool data tip template. - - - The tool tip template. - - - - - Gets or sets the tool tip default font family. - - - The tool tip font family. - - - - - Gets or sets the default size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the default tool tip font weight. - - - The tool tip font weight. - - - - - Gets or sets the default tool tip font style. - - - The tool tip font style. - - - - - Gets or sets the default tool tip text brush. - - - The tool tip text brush. - - - - - Gets or sets the default tool tip background. - - - The tool tip background. - - - - - - - - - - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the default legend font family. - - - The legend font family. - - - - - Gets or sets the default size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the default legend font weight. - - - The legend font weight. - - - - - Gets or sets the default legend font style. - - - The legend font style. - - - - - Gets or sets the default legend text brush. - - - The legend text brush. - - - - - Gets or sets the default legend background. - - - The legend background. - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - - - - Defines the tool tip binding context. - - - - - Gets or sets the points. - - - The points. - - - - - Gets or sets the tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the tool tip font weight. - - - The tool tip font weight. - - - - - Gets or sets the tool tip font style. - - - The tool tip font style. - - - - - Gets or sets the tool tip text brush. - - - The tool tip text brush. - - - - - Gets or sets the tool tip background. - - - The tool tip background. - - - - diff --git a/docs/LiveChartsCore.SkiaSharpView.WPF.xml b/docs/LiveChartsCore.SkiaSharpView.WPF.xml deleted file mode 100644 index 9657c6eb7..000000000 --- a/docs/LiveChartsCore.SkiaSharpView.WPF.xml +++ /dev/null @@ -1,730 +0,0 @@ - - - - LiveChartsCore.SkiaSharpView.WPF - - - - - - - - Initializes a new instance of the class. - - - - - The series property - - - - - The x axes property - - - - - The y axes property - - - - - The zoom mode property - - - - - The zooming speed property - - - - - - - - - - - - - - - - - - - - - - - Initializes the core. - - canvas not found - - - - - - - The core - - - - - The canvas - - - - - The legend - - - - - The tool tip - - - - - Initializes a new instance of the class. - - Default colors are not valid - - - - The draw margin property - - - - - The animations speed property - - - - - The easing function property - - - - - The legend position property - - - - - The legend orientation property - - - - - The tool tip position property - - - - - The tool tip finding strategy property - - - - - The tool tip background property - - - - - The tool tip font family property - - - - - The tool tip text color property - - - - - The tool tip font size property - - - - - The tool tip font weight property - - - - - The tool tip font stretch property - - - - - The tool tip font style property - - - - - The tool tip template property - - - - - The legend font family property - - - - - The legend text color property - - - - - The legend font size property - - - - - The legend font weight property - - - - - The legend font stretch property - - - - - The legend font style property - - - - - The legend template property - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the default tool tip background. - - - The tool tip background. - - - - - Gets or sets the default tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the default color of the tool tip text. - - - The color of the tool tip text. - - - - - Gets or sets the default size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the default tool tip font weight. - - - The tool tip font weight. - - - - - Gets or sets the default tool tip font stretch. - - - The tool tip font stretch. - - - - - Gets or sets the default tool tip font style. - - - The tool tip font style. - - - - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the default legend font family. - - - The legend font family. - - - - - Gets or sets the default color of the legend text. - - - The color of the legend text. - - - - - Gets or sets the default size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the default legend font weight. - - - The legend font weight. - - - - - Gets or sets the default legend font stretch. - - - The legend font stretch. - - - - - Gets or sets the default legend font style. - - - The legend font style. - - - - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - Called when a dependency property changes. - - The o. - The instance containing the event data. - - - - - Sets the local value of a dependency property, specified by its dependency property identifier. - If the object has not yet finished initializing, does so without changing its value source. - - The identifier of the dependency property to set. - The new local value. - - - - - DefaultLegend - - - - - Initializes a new instance of the class. - - - - - The custom template property - - - - - The series property - - - - - The orientation property - - - - - The dock property - - - - - The text color property - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the custom template. - - - The custom template. - - - - - Gets or sets the orientation. - - - The orientation. - - - - - Gets or sets the dock. - - - The dock. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - InitializeComponent - - - - - - DefaultTooltip - - - - - Initializes a new instance of the class. - - - - - The template property - - - - - The points property - - - - - The background property - - - - - The font family property - - - - - The font size property - - - - - The font weight property - - - - - The font style property - - - - - The font stretch property - - - - - The text color property - - - - - Gets or sets the animations speed. - - - The animations speed. - - - - - Gets or sets the easing function. - - - The easing function. - - - - - Gets or sets the template. - - - The template. - - - - - Gets or sets the background. - - - The background. - - - - - Gets or sets the points. - - - The points. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the font weight. - - - The font weight. - - - - - Gets or sets the font style. - - - The font style. - - - - - Gets or sets the font stretch. - - - The font stretch. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - InitializeComponent - - - - - Defines the motion canvas control for WPF, . - - - - - - The skia element - - - - - Initializes a new instance of the class. - - - - - The paint tasks property - - - - - Gets or sets the paint tasks. - - - The paint tasks. - - - - - Gets or sets the frames per second. - - - The frames per second. - - - - - Gets the canvas core. - - - The canvas core. - - - - - - - - - - - - - - Initializes a new instance of the class. - - - - - The series property - - - - - The initial rotation property - - - - - The maximum angle property - - - - - The total property - - - - - - - - - - - - - - - - - Initializes the core. - - canvas not found - - - diff --git a/docs/LiveChartsCore.SkiaSharpView.WinForms.xml b/docs/LiveChartsCore.SkiaSharpView.WinForms.xml deleted file mode 100644 index e92254489..000000000 --- a/docs/LiveChartsCore.SkiaSharpView.WinForms.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - LiveChartsCore.SkiaSharpView.WinForms - - - - - - - - Initializes a new instance of the class. - - The default tool tip control. - The default legend control. - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - - - - - - The core - - - - - The legend - - - - - The tooltip - - - - - The motion canvas - - - - - Initializes a new instance of the class. - - The default tool tip control. - The default legend. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the default legend font. - - - The legend font. - - - - - Gets or sets the default color of the legend back. - - - The color of the legend back. - - - - - - - - - - - - - - Gets or sets the default tool tip font. - - - The tool tip font. - - - - - Gets or sets the color of the default tool tip back. - - - The color of the tool tip back. - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - Called when a property changes. - - - - - - Raises the event. - - The instance containing the event data. - - - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the orientation. - - - The orientation. - - - - - Required designer variable. - - - - - Clean up any resources being used. - - true if managed resources should be disposed; otherwise, false. - - - - Required method for Designer support - do not modify - the contents of this method with the code editor. - - - - - - - - Initializes a new instance of the class. - - - - - Disposes the specified disposing. - - if set to true [disposing]. - - - - - Gets the create parameters. - - - The create parameters. - - - - - Required designer variable. - - - - - Required method for Designer support - do not modify - the contents of this method with the code editor. - - - - - The motion canvas control for windows forms, . - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the paint tasks. - - - The paint tasks. - - - - - Gets or sets the frames per second. - - - The frames per second. - - - - - Gets the canvas core. - - - The canvas core. - - - - - Required designer variable. - - - - - Clean up any resources being used. - - true if managed resources should be disposed; otherwise, false. - - - - Required method for Designer support - do not modify - the contents of this method with the code editor. - - - - - - - - Initializes a new instance of the class. - - The default tool tip control. - The default legend. - - - - - - - - - - - - - - - - Initializes the core. - - - - diff --git a/docs/LiveChartsCore.SkiaSharpView.Xamarin.Forms.xml b/docs/LiveChartsCore.SkiaSharpView.Xamarin.Forms.xml deleted file mode 100644 index 30a8bbf32..000000000 --- a/docs/LiveChartsCore.SkiaSharpView.Xamarin.Forms.xml +++ /dev/null @@ -1,1146 +0,0 @@ - - - - LiveChartsCore.SkiaSharpView.XamarinForms - - - - - - - - The core - - - - - Initializes a new instance of the class. - - Default colors are not valid - - - - The series property - - - - - The x axes property - - - - - The y axes property - - - - - The draw margin property - - - - - The zoom mode property - - - - - The zooming speed property - - - - - The animations speed property - - - - - The easing function property - - - - - The legend position property - - - - - The legend orientation property - - - - - The legend template property - - - - - The legend font family property - - - - - The legend font size property - - - - - The legend text color property - - - - - The legend background property - - - - - The legend font attributes property - - - - - The tool tip position property - - - - - The too ltip finding strategy property - - - - - The tool tip template property - - - - - The tool tip font family property - - - - - The tool tip font size property - - - - - The tool tip text color property - - - - - The tool tip background property - - - - - The tool tip font attributes property - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the default legend font family. - - - The legend font family. - - - - - Gets or sets the default size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the default color of the legend text. - - - The color of the legend text. - - - - - Gets or sets the default color of the legend background. - - - The color of the legend background. - - - - - Gets or sets the default legend font attributes. - - - The legend font attributes. - - - - - - - - - - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the default tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the default size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the default color of the tool tip text. - - - The color of the tool tip text. - - - - - Gets or sets the default color of the tool tip background. - - - The color of the tool tip background. - - - - - Gets or sets the default tool tip font attributes. - - - The tool tip font attributes. - - - - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - Called when a bindable property changed. - - The o. - The old value. - The new value. - - - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - Gets or sets the font attributes. - - - The font attributes. - - - - - Gets or sets the orientation. - - - The orientation. - - - - - Builds the content. - - - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the points. - - - The points. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - Gets or sets the font attributes. - - - The font attributes. - - - - - Builds the content. - - - - - - A converter value helper - - - - - Implement this method to convert to by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - To be added. - - - - - Implement this method to convert back from by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - - To be added. - - - - - A chart for Xamarin. - - - - - Gets the layout grid. - - - The layout grid. - - - - - Gets the canvas. - - - The canvas. - - - - - Gets the legend. - - - The legend. - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the color of the tool tip text. - - - The color of the tool tip text. - - - - - Gets or sets the color of the tool tip background. - - - The color of the tool tip background. - - - - - Gets or sets the tool tip font attributes. - - - The tool tip font attributes. - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the legend font family. - - - The legend font family. - - - - - Gets or sets the size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the color of the legend text. - - - The color of the legend text. - - - - - Gets or sets the color of the legend background. - - - The color of the legend background. - - - - - Gets or sets the legend font attributes. - - - The legend font attributes. - - - - - Defines the legend binding context. - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - Gets or sets the font attributes. - - - The font attributes. - - - - - Gets or sets the orientation. - - - The orientation. - - - - - The motion canvas control fro Xamarin, . - - - - - Initializes a new instance of the class. - - - - - The paint tasks property - - - - - Gets the sk canvas view. - - - The sk canvas view. - - - - - Gets or sets the frames per second. - - - The frames per second. - - - - - Gets or sets the paint tasks. - - - The paint tasks. - - - - - Gets the canvas core. - - - The canvas core. - - - - - Invalidates this instance. - - - - - - A converter value helper - - - - - Implement this method to convert to by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - To be added. - - - - - Implement this method to convert back from by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - - To be added. - - - - - - - - The core - - - - - Initializes a new instance of the class. - - Default colors are not valid - - - - The series property - - - - - The initial rotation property - - - - - The maximum angle property - - - - - The total property - - - - - The draw margin property - - - - - The animations speed property - - - - - The easing function property - - - - - The legend position property - - - - - The legend orientation property - - - - - The legend template property - - - - - The legend font family property - - - - - The legend font size property - - - - - The legend text color property - - - - - The legend background property - - - - - The legend font attributes property - - - - - The tool tip position property; - - - - - The tool tip finding strategy property - - - - - The tool tip template property - - - - - The tool tip font family property - - - - - The tool tip font size property - - - - - The tool tip text color property - - - - - The tool tip background property - - - - - The tool tip font attributes property - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the legend template. - - - The legend template. - - - - - Gets or sets the legend font family. - - - The legend font family. - - - - - Gets or sets the size of the legend font. - - - The size of the legend font. - - - - - Gets or sets the color of the legend text. - - - The color of the legend text. - - - - - Gets or sets the color of the legend background. - - - The color of the legend background. - - - - - Gets or sets the legend font attributes. - - - The legend font attributes. - - - - - - - - - - - - - - Gets or sets the tool tip template. - - - The tool tip template. - - - - - Gets or sets the tool tip font family. - - - The tool tip font family. - - - - - Gets or sets the size of the tool tip font. - - - The size of the tool tip font. - - - - - Gets or sets the color of the tool tip text. - - - The color of the tool tip text. - - - - - Gets or sets the color of the tool tip background. - - - The color of the tool tip background. - - - - - Gets or sets the tool tip font attributes. - - - The tool tip font attributes. - - - - - - - - - - - - - - - - - - - - Initializes the core. - - - - - - Called when a bindable property changes. - - The o. - The old value. - The new value. - - - - - Defines the tool tip binding context. - - - - - Gets or sets the points. - - - The points. - - - - - Gets or sets the font family. - - - The font family. - - - - - Gets or sets the size of the font. - - - The size of the font. - - - - - Gets or sets the color of the text. - - - The color of the text. - - - - - Gets or sets the font attributes. - - - The font attributes. - - - - - A converter value helper - - - - - Implement this method to convert to by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - To be added. - - - - - Implement this method to convert back from by using and . - - The value to convert. - The type to which to convert the value. - A parameter to use during the conversion. - The culture to use during the conversion. - - To be added. - - - - To be added. - - - - diff --git a/docs/LiveChartsCore.SkiaSharpView.xml b/docs/LiveChartsCore.SkiaSharpView.xml deleted file mode 100644 index cdcbd5717..000000000 --- a/docs/LiveChartsCore.SkiaSharpView.xml +++ /dev/null @@ -1,1599 +0,0 @@ - - - - LiveChartsCore.SkiaSharpView - - - - - - - - Initializes a new instance of the class. - - - - - Defines a column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines an avalonia-skiasharp drawing context. - - - - - - Initializes a new instance of the class. - - The motion canvas. - The information. - The surface. - The canvas. - - - - Gets or sets the color of the back. - - - The color of the back. - - - - - Clears the canvas. - - - - - - - - - - - Defines a circle geometry. - - - - - - Initializes a new instance of the class. - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The opacity property - - - - - The x - - - - - The y - - - - - The rotation - - - - - The has custom transform - - - - - Initializes a new instance of the class. - - - - - - - - - - - Gets or sets the matrix transform. - - - The transform. - - - - - - - - - - - - - - Draws the geometry in the user interface. - - The context. - - - - Called when the geometry is drawn. - - The context. - The paint. - - - - Measures the geometry. - - The drawable task. - the size of the geometry. - - - - Called before the draw. - - - - - Called after the draw. - - - - - Called when the geometry is measured. - - The paint task. - the size of the geometry - - - - Gets the actual transform. - - - - - - Gets the position of the geometry from the top left corner of the view. - - The context. - The paint. - the position. - - - - Gets the highlitable geometry. - - - - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the vertical align. - - - The vertical align. - - - - - Gets or sets the horizontal align. - - - The horizontal align. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - Defines an oval geometry. - - - - - - Initializes a new instance of the class. - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - Defines a rectangle geometry. - - - - - - Initializes a new instance of the class. - - - - - - - - Defines a rounded rectangle geometry. - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the rx, the rounding in the x axis. - - - The rx. - - - - - Gets or sets the ry, the rounding in the axis. - - - The ry. - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - The width - - - - - The height - - - - - The match dimensions - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - Defines a square geometry. - - - - - - Initializes a new instance of the class. - - - - - - - - Defines a geometry that is built using from a svg path. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The SVG path. - - - - Gets or sets the SVG path. - - - The SVG. - - - - - - - - Defines a skia sharp drawing context. - - - - - - Initializes a new instance of the class. - - The motion canvas. - The information. - The surface. - The canvas. - - - - Gets or sets the motion canvas. - - - The motion canvas. - - - - - Gets or sets the information. - - - The information. - - - - - Gets or sets the surface. - - - The surface. - - - - - Gets or sets the canvas. - - - The canvas. - - - - - Gets or sets the paint task. - - - The paint task. - - - - - Gets or sets the paint. - - - The paint. - - - - - Clears the canvas. - - - - - Defines a helper class to build gauges. - - - - - Gets or sets the inner radius, setting this property to null will let the theme decide the value, default is null. - - - The inner radius. - - - - - Gets or sets the offset radius, the separation between each gauge if multiple gauges are nested, - setting this property to null will let the theme decide the value, default is null. - - - The relative inner radius. - - - - - Gets or sets the maximum width of the radial column, setting this property to null will let the theme decide the value, default is null. - - - The maximum width of the radial column. - - - - - Gets or sets the corner radius, setting this property to null will let the theme decide the value, default is null. - - - The corner radius. - - - - - Gets or sets the inner radius, setting this property to null will let the theme decide the value, default is null. - - - The inner radius. - - - - - Gets or sets the background inner radius, setting this property to null will let the theme decide the value, default is null. - - - The background inner radius. - - - - - Gets or sets the background offset radius, the separation between each gauge if multiple gauges are nested, - setting this property to null will let the theme decide the value, default is null. - - - The background relative inner radius. - - - - - Gets or sets the width of the background maximum radial column, setting this property to null will let the theme - decide the value, default is null. - - - The width of the background maximum radial column. - - - - - Gets or sets the background corner radius, setting this property to null will let the theme decide the value, default is null. - - - The background corner radius. - - - - - Gets or sets the background, setting this property to will let the theme decide - the value, default is . - - - The background. - - - - - Gets or sets the size of the labels, setting this property to null will let the theme decide the value, default is null. - - - The size of the labels. - - - - - Gets or sets the labels position, setting this property to null will let the theme decide the value, default is null. - - - The labels position. - - - - - Gets or sets the label formatter. - - - The label formatter. - - - - - Adds the value. - - The value. - The series name. - The series drawable task. - The labels drawable task. - - - - - Adds the value. - - The value. - The series name. - Color of the series. - Color of the labels. - - - - - Adds the value. - - The value. - - - - - Adds the value. - - The value. - The series name. - - - - - Builds the series. - - - - - - Applies the styles the specified series. - - The series. - - - - - Applies the styles to fill series. - - The series. - - - - - Applies the styles to series. - - The series. - - - - - - Defines a line series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a line series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a line series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines the default LiveCharts-SkiaSharp settings - - - - - Gets the default paint task. - - - The default paint. - - - - - Gets the default platform builder. - - - The default platform builder. - - - - - Adds SkiaSharp as the UI provider for LiveCharts. - - The settings. - - - - - Adds the light theme. - - The settings. - the additional styles. - - - - - Adds the light theme. - - The settings. - The additional styles. - - - - - Adds the default resolvers. - - The theme. - - - - - Adds the default resolvers. - - The theme. - - - - - Converts a to a instance. - - The color. - The alpha overrides. - - - - - Creates a new color based on the - - The color. - The opacity from 0 to 255. - - - - - Creates a stroke dash effect. - - - - - - Initializes a new instance of the class. - - - - - - - - A wrapper object for skia sharp path effects. - - - - - - Gets or sets the sk path effect. - - - The sk path effect. - - - - - Creates the path effect. - - The drawing context. - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - - Defines a set of geometries that will be painted using a linear gradient shader. - - - - - - Initializes a new instance of the class. - - The gradient stops. - - The start point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - - - The end point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - - - An array of integers in the range of 0 to 1. - These integers indicate the relative positions of the colors, You can set that argument to null to equally - space the colors, default is null. - - - The shader tile mode, default is . - - - - - Initializes a new instance of the class. - - The gradient stops. - - - - Initializes a new instance of the class. - - The start color. - The end color. - - The start point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - - - The end point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - - - - - Initializes a new instance of the class. - - The start. - The end. - - - - Gets or sets the path effect. - - - The path effect. - - - - - - - - - - - - - - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - - - - The skia paint - - - - - The stroke width transition - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The color. - - - - - - - Gets or sets the style. - - - The style. - - - - - - - - - - - Gets or sets a value indicating whether this instance is antialias. - - - true if this instance is antialias; otherwise, false. - - - - - Gets or sets the color. - - - The color. - - - - - Gets or sets a value indicating whether this instance is paused. - - - true if this instance is paused; otherwise, false. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - Defines a set of geometries that will be painted using a radial gradient shader. - - - - - - Initializes a new instance of the class. - - The gradient stops. - - The center point of the gradient, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end, - default is (0.5, 0.5). - - - The radius, in the range of 0 to 1, where 1 is the minimum of both Width and Height of the chart, default is 0.5. - - - An array of integers in the range of 0 to 1. - These integers indicate the relative positions of the colors, You can set that argument to null to equally - space the colors, default is null. - - - The shader tile mode, default is . - - - - - Initializes a new instance of the class. - - Color of the center. - Color of the outer. - - - - Gets or sets the path effect. - - - The path effect. - - - - - - - - - - - - - - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - Defines a set of geometries that will be painted using a solid color. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The color. - - - - Initializes a new instance of the class. - - The color. - Width of the stroke. - - - - Gets or sets the stroke cap. - - - The stroke cap. - - - - - Gets or sets the stroke join. - - - The stroke join. - - - - - Gets or sets the stroke miter. - - - The stroke miter. - - - - - Gets or sets the path effect. - - - The path effect. - - - - - - - - - - - - - - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - Defines a pie series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Initializes a new instance of the class. - - - - - - - Defines a pie series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Initializes a new instance of the class. - - - - - - - Defines a pie series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - - - Defines a row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - data label of every point. - - - - Defines a row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines a scatter series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a scatter series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a scatter series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines a stacked area series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a stacked area series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a stacked area series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines a stacked column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a stacked column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a stacked column series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - - Defines a stacked row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - - - Defines a stacked row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - - - Defines a stacked row series in the user interface. - - - The type of the points, you can use any type, the library already knows how to handle the most common numeric types, - to use a custom type, you must register the type globally - () - or at the series level - (). - - - The type of the geometry of every point of the series. - - - The type of the data label of every point. - - - - - Initializes a new instance of the class. - - - - diff --git a/docs/LiveChartsCore.xml b/docs/LiveChartsCore.xml deleted file mode 100644 index faf44b1ef..000000000 --- a/docs/LiveChartsCore.xml +++ /dev/null @@ -1,7672 +0,0 @@ - - - - LiveChartsCore - - - - - Defines an Axis in a Cartesian chart. - - The type of the drawing context. - The type of the text geometry. - The type of the line geometry. - - - - - - Get a reference to the charts that are subscribed to this axis. - - - - - Gets a reference to the pending to delete paint tasks. - - - - - The active separators - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Occurs when a property value changes. - - - - - - - - - - - - - - - - - - Called when a property changes. - - Name of the property. - - - - - Softly deletes the separator. - - The chart. - The separator. - The scale. - - - - - Defines a bar series point. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - Initializes a new instance of the class. - - The properties. - - - - - - - - - - - - - - - - - - - Called when the paint context changes. - - - - - Defines a Cartesian chart. - - The type of the drawing context. - - - - - Initializes a new instance of the class. - - The view. - The default platform configuration. - The canvas. - - - - Gets the x axes. - - - The x axes. - - - - - Gets the y axes. - - - The y axes. - - - - - Gets the series. - - - The series. - - - - - Gets the drawable series. - - - The drawable series. - - - - - Gets or sets a value indicating whether this instance is zooming or panning. - - - true if this instance is zooming or panning; otherwise, false. - - - - - Gets the view. - - - The view. - - - - - - - - Finds the points near to the specified location. - - The pointer position. - - - - - Scales the specified point to the UI. - - The point. - Index of the x axis. - Index of the y axis. - - - - - Zooms to the specified pivot. - - The pivot. - The direction. - - - - - Pans with the specified delta. - - The delta. - - - - - Measures this chart. - - - - - - Called when the updated the throttler is unlocked. - - - - - - Defines a Cartesian series. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - - Initializes a new instance of the class. - - The series properties. - - - - - - - - - - Gets or sets the data labels position. - - - The data labels position. - - - - - - - - - - - Deletes the series from the user interface. - - - - - - - Gets the label position. - - The x. - The y. - The width. - The height. - Size of the label. - The position. - The series properties. - if set to true [is greater than pivot]. - - - - - Defines a chart, - - The type of the drawing context. - - - - - The series context - - - - - The canvas - - - - - The update throttler - - - - - The control size - - - - - The view draw margin - - - - - The legend position - - - - - The legend orientation - - - - - The legend - - - - - The tool tip position - - - - - The tool tip finding strategy - - - - - The tool tip - - - - - The animations speed - - - - - The easing function - - - - - The draw margin size - - - - - The draw margin location - - - - - Initializes a new instance of the class. - - The canvas. - The default platform configuration. - - - - - - - - - - - - - Gets the measure work. - - - The measure work. - - - - - Gets or sets the theme identifier. - - - The theme identifier. - - - - - Gets or sets a value indicating whether this it is the first draw of this instance. - - - true if this it is the first draw; otherwise, false. - - - - - Gets the series context. - - - The series context. - - - - - Gets the canvas. - - - The canvas. - - - - - Gets the drawable series. - - - The drawable series. - - - - - Gets the view. - - - The view. - - - - - Gets the size of the control. - - - The size of the control. - - - - - Gets the draw margin location. - - - The draw margin location. - - - - - Gets the size of the draw margin. - - - The size of the draw margin. - - - - - Gets the legend position. - - - The legend position. - - - - - Gets the legend orientation. - - - The legend orientation. - - - - - Gets the legend. - - - The legend. - - - - - Gets the tooltip position. - - - The tooltip position. - - - - - Gets the tooltip finding strategy. - - - The tooltip finding strategy. - - - - - Gets the tooltip. - - - The tooltip. - - - - - Gets the animations speed. - - - The animations speed. - - - - - Gets the easing function. - - - The easing function. - - - - - - - - Measures this chart. - - - - - - Called when the updated the throttler is unlocked. - - - - - - Finds the points near to the specified point. - - The pointer position. - - - - - Sets the draw margin. - - Size of the control. - The margin. - - - - - Invokes the event. - - - - - - Invokes the on update started. - - - - - - Invokes the on update finished. - - - - - - Implementation of a dynamic data collection based on generic Collection<T>, - implementing INotifyCollectionChanged to notify listeners - when items get added, removed or the whole list is refreshed. - - - - - Initializes a new instance of ObservableCollection that is empty and has default initial capacity. - - - - - Initializes a new instance of the ObservableCollection class that contains - elements copied from the specified collection and has sufficient capacity - to accommodate the number of elements copied. - - The collection whose elements are copied to the new list. - - The elements are copied onto the ObservableCollection in the - same order they are read by the enumerator of the collection. - - collection is a null reference - - - - Initializes a new instance of the ObservableCollection class - that contains elements copied from the specified list - - The list whose elements are copied to the new list. - - The elements are copied onto the ObservableCollection in the - same order they are read by the enumerator of the list. - - list is a null reference - - - - ... - - - - - Gets or sets a value indicating whether this collection acts as a , - disallowing duplicate items, based on . - This might indeed consume background performance, but in the other hand, - it will pay off in UI performance as less required UI updates are required. - - - - - Adds the elements of the specified collection to the end of the . - - - The collection whose elements should be added to the end of the . - The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type. - - is null. - - - - Inserts the elements of a collection into the at the specified index. - - The zero-based index at which the new elements should be inserted. - The collection whose elements should be inserted into the list. - The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type. - - is null. - is not in the collection range. - - - - Removes the first occurrence of each item in the specified collection from the . - - The items to remove. - is null. - - - - Iterates over the collection and removes all items that satisfy the specified match. - - The complexity is O(n). - - Returns the number of elements that where - is null. - - - - Iterates over the specified range within the collection and removes all items that satisfy the specified match. - - The complexity is O(n). - The index of where to start performing the search. - The number of items to iterate on. - - Returns the number of elements that where - is out of range. - is out of range. - is null. - - - - Removes a range of elements from the >. - - The zero-based starting index of the range of elements to remove. - The number of elements to remove. - The specified range is exceeding the collection. - - - - Clears the current collection and replaces it with the specified collection, - using . - - The items to fill the collection with, after clearing it. - is null. - - - - Removes the specified range and inserts the specified collection in its position, leaving equal items in equal positions intact. - - The index of where to start the replacement. - The number of items to be replaced. - The collection to insert in that location. - is out of range. - is out of range. - is null. - - - - Called by base class Collection<T> when the list is being cleared; - raises a CollectionChanged event to any listeners. - - - - - - - - - - - Raise CollectionChanged event to any listeners. - Properties/methods modifying this ObservableCollection will raise - a collection changed event through this virtual method. - - - When overriding this method, either call its base implementation - - - - - - - - - - - Helper to raise Count property and the Indexer property. - - - - - /// Helper to raise a PropertyChanged event for the Indexer property - /// - - - - Helper to raise CollectionChanged event to any listeners - - - - - Helper to raise CollectionChanged event with action == Reset to any listeners - - - - - Helper to raise event for clustered action and clear cluster. - - The index of the item following the replacement block. - - - - - - To be kept outside , since otherwise, a new instance will be created for each generic type used. - - - - - Defines a column series. - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - Defines a date time point for the Cartesian coordinate system that implements . - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The date time. - The value. - - - - Gets or sets the date time. - - - The date time. - - - - - Gets or sets the value. - - - The value. - - - - - Occurs when a property value changes. - - - - - - Called when a property changed. - - Name of the property. - - - - Defines a date time point for the Cartesian coordinate system that implements . - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The date time. - The value. - - - - Gets or sets the date time. - - - The date time. - - - - - Gets or sets the value. - - - The value. - - - - - Occurs when a property value changes. - - - - - - Called when a property changed. - - Name of the property. - - - - Defines a point for the Cartesian coordinate system that implements . - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The x coordinate. - The y coordinate. - - - - Gets or sets the x coordinate. - - - The x. - - - - - Gets or sets the y coordinate. - - - The y. - - - - - Occurs when a property value changes. - - - - - - Called when a property changed. - - Name of the property. - - - - Defines a point for he Cartesian coordinate system that implements . - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The x coordinate. - The y coordinate. - - - - Gets or sets the x coordinate. - - - The x. - - - - - Gets or sets the y coordinate. - - - The y. - - - - - Occurs when a property value changes. - - - - - - Called when a property changes. - - Name of the property. - - - - Defines an object that notifies when the value property changes. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The value. - - - - Gets or sets the value. - - - The value. - - - - - Occurs when a property value changes. - - - - - - Called when am property changed. - - Name of the property. - - - - Defines an object that notifies when the value property changes. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The value. - - - - Gets or sets the value. - - - The value. - - - - - Occurs when a property value changes. - - - - - - Called when a property changes. - - Name of the property. - - - - Defines a point with a weighted coordinate. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The x. - The y. - The weight. - - - - Gets or sets the x. - - - The x. - - - - - Gets or sets the y. - - - The y. - - - - - Gets or sets the weight. - - - The weight. - - - - - Occurs when a property value changes. - - - - - - Called when a property changed. - - Name of the property. - - - - Defines a point with a weighted coordinate. - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The x. - The y. - The weight. - - - - Gets or sets the x. - - - The x. - - - - - Gets or sets the y. - - - The y. - - - - - Gets or sets the weight. - - - The weight. - - - - - Occurs when a property value changes. - - - - - - Called when a property changed. - - Name of the property. - - - - Defines a data series that has at least a to draw the data in the user interface. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - The paint context. - - - - - The pending to delete tasks. - - - - - Initializes a new instance of the class. - - The properties. - - - - Gets or sets the stroke. - - - The stroke. - - - - - Gets or sets the fill. - - - The fill. - - - - - Gets or sets the data labels drawable task. - - - The data labels drawable task. - - - - - Gets or sets the size of the data labels. - - - The size of the data labels. - - - - - Gets or sets the data labels padding. - - - The data labels padding. - - - - - Gets the default paint context. - - - The default paint context. - - - - - Gets or sets the size of the legend shape. - - - The size of the legend shape. - - - - - Releases unmanaged and - optionally - managed resources. - - - - - - Called when the paint context changed. - - - - - - Initializes the series. - - - Default colors are not valid - - - - Defines the drawing alignment. - - - - - Aligns to the start - - - - - Aligns to the end - - - - - Aligns to the middle - - - - - - - - The transition properties - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - Invalidates this animatable. - - - - - - - - - - - - - - - Registers a motion property. - - - The transition. - - - - - Sets the current time. - - The time. - - - - - Gets the current time. - - - - - - Defines the padding measure helped class,. - - - - - The default padding. - - - - - Gets or sets the left. - - - The left. - - - - - Gets or sets the right. - - - The right. - - - - - Gets or sets the top. - - - The top. - - - - - Gets or sets the bottom. - - - The bottom. - - - - - The Transition builder class helps to build transitions using fluent syntax. - - - - - Initializes a new instance of the class. - - The target. - The properties. - - - - Sets the animation. - - The animation. - The transition - - - - Sets the animation. - - The animation builder. - The transition - - - - Sets the current transitions. - - The transition - - - - Defines an animation. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The easing function. - The duration. - - - - Initializes a new instance of the class. - - The easing function. - The duration. - The repeat times. - - - - Initializes a new instance of the class. - - The easing function. - The duration. - The repeat times. - - - - Initializes a new instance of the class. - - The animation. - - - - Gets or sets the easing function. - - - - - Gets or sets the duration of the transition in Milliseconds. - - - - - Gets or sets how many times the animation needs to repeat before it is completed, - use int.MaxValue to repeat it indefinitely number of times. - - - - - Sets the easing function. - - The easing. - The animation instance - - - - Sets the duration. - - The duration. - The animation instance - - - - Sets the duration. - - The duration. - The animation instance - - - - Sets the repeats times. - - The times. - The animation instance - - - - Sets he repeats times indefinitely number of times. - - The animation instance - - - - Defines an axis visual separator. - - The type of the drawing context. - - - - Gets or sets the value. - - - The value. - - - - - Gets or sets the text. - - - The text. - - - - - Gets or sets the line. - - - The line. - - - - - Defines a context that is able to draw 2D shapes in the user interface. - - - - - Clears the canvas. - - - - - Defines an object that can is able to animate its properties. - - - - - Gets or sets a value indicating whether this instance is completed. - - - true if this instance is completed; otherwise, false. - - - - - Gets or sets the current time. - - - The current time. - - - - - Gets or sets a value indicating whether the element is removed when all the transitions complete. - - - true if remove on completed; otherwise, false. - - - - - Sets the properties transitions. - - The animation. - Name of the property. - - - - Removes a property transition. - - Name of the property. - - - - Removes all the current transitions. - - - - - Completes all transitions. - - - - - Completes the transitions. - - Name of the property. - - - - Gets the transition property. - - Name of the property. - - - - - Defiens an animable bezier segment. - - - - - - Gets or sets the x0. - - - The x0. - - - - - Gets or sets the y0. - - - The y0. - - - - - Gets or sets the x1. - - - The x1. - - - - - Gets or sets the y1. - - - The y1. - - - - - Gets or sets the x2. - - - The x2. - - - - - Gets or sets the y2. - - - The y2. - - - - - Defiens a bezier segment. - - The type of the path context. - - - - - - Defines a doughnut geometry. - - The type of the drawing context. - - - - - Gets or sets the center x. - - - The center x. - - - - - Gets or sets the center y. - - - The center y. - - - - - Gets or sets the width. - - - The width. - - - - - Gets or sets the height. - - - The height. - - - - - Gets or sets the start angle. - - - The start angle. - - - - - Gets or sets the sweep angle. - - - The sweep angle. - - - - - Gets or sets the push out. - - - The push out. - - - - - Gets or sets the inner radius. - - - The inner radius. - - - - - Gets or sets the corner radius. - - - The corner radius. - - - - - Gets or sets a value indicating whether the direction of the corner radius is inverted. - - - true if the direction is inverted; otherwise, false. - - - - - Defines a douggnut visual chart point. - - The type of the drawing context. - - - - - - Defines a drawable object, an object that can be represented in the user interface. - - The type of the drawing context. - - - - - Draws the instance in the user interface with for the specified context. - - The context. - - - - Defines a set of geometries that will be drawn according to this instance specifications. - - The type of the drawing context. - - - - Gets or sets a value indicating whether this instance is stroke. - - - true if this instance is stroke; otherwise, false. - - - - - Gets or sets a value indicating whether this instance is fill. - - - true if this instance is fill; otherwise, false. - - - - - Gets or sets the index of the z. - - - The index of the z. - - - - - Gets or sets the stroke thickness. - - - The stroke thickness. - - - - - Gets or sets a value indicating whether this instance is paused. - - - true if this instance is paused; otherwise, false. - - - - - Gets or sets the clip rectangle. - - - The canvas. - The clip rectangle. - - - - - Gets or sets the clip rectangle. - - The canvas. - - The clip rectangle. - - - - - Initializes the task. - - The context. - - - - Gets the geometries. - - - The canvas. - - - - Sets the geometries. - - The canvas. - The geometries. - - - - Adds the geometry to paint task. - - The canvas. - The geometry. - - - - Removes the geometry from pain task. - - The canvas. - The geometry. - - - - Removes all geometry from paint task. - - The canvas. - - - - Sets the opacity according to the given geometry. - - The context. - The geometry. - - - - Resets the opacity. - - The context. - The geometry. - - - - Clones the task. - - - - - - Defines a geometry in the user interface. - - The type of the drawing context. - - - - - Gets or sets the opacity. - - - The opacity. - - - - - Gets or sets the rotation. - - - The rotation. - - - - - Gets or sets the x. - - - The x. - - - - - Gets or sets the y. - - - The y. - - - - - Measures the specified drawable task. - - The drawable task. - - - - - Defines a label geometry in the user interface. - - The type of the drawing context. - - - - - Gets or sets the padding. - - - The padding. - - - - - Gets or sets the vertical align. - - - The vertical align. - - - - - Gets or sets the horizontal align. - - - The horizontal align. - - - - - Gets or sets the text. - - - The text. - - - - - Gets or sets the size of the text. - - - The size of the text. - - - - - Defines a line bezier segment chart point. - - The type of the drawing context. - - - - - Gets the geometry. - - - The geometry. - - - - - Gets the bezier. - - - The bezier. - - - - - Defines a line geometry in the user interface. - - The type of the drawing context. - - - - - Gets or sets the x1. - - - The x1. - - - - - Gets or sets the y1. - - - The y1. - - - - - Defines a line path segment. - - The type of the path. - - - - - Gets or sets the x. - - - The x. - - - - - Gets or sets the y. - - - The y. - - - - - Defines the move to path comamnd. - - The type of the path. - - - - - Gets or sets the x. - - - The x. - - - - - Gets or sets the y. - - - The y. - - - - - Defines a path command. - - The type of the path context. - - - - - Executes the command in the path. - - The path. - The current time. - The path geometry. - - - - Defines a path geometry in the user interface. - - The type of the drawing context. - The type of the path arguments. - - - - - Gets or sets a value indicating whether the path is closed. - - - true if this instance is closed; otherwise, false. - - - - - Adds a path command. - - The command. - - - - Determines whether the specified command is contained in the current path. - - The command. - - true if the specified command contains command; otherwise, false. - - - - - Removes a given command. - - The command. - - - - Clears the commands. - - - - - Defines a rounded rectangle visual chart point. - - The type of the drawing context. - - - - - Gets or sets the rx, the radius used in the x axis to round the corners of each column in pixels. - - - The rx. - - - - - Gets or sets the ry, the radius used in the y axis to round the corners of each column in pixels. - - - The ry. - - - - - Defines a sized geometry in the user interface. - - The type of the drawing context. - - - - - Gets or sets the width. - - - The width. - - - - - Gets or sets the height. - - - The height. - - - - - Defines a sized visual chart point. - - The type of the drawing context. - - - - - - Defines an object that contains a to highlight when the point requires so. - - - - - Gets the main . - - - - - Defines a line bezier visual point. - - The type of the drawing context. - The type of the visual. - The type of the bezier segment. - The type of the path arguments. - - - - - Gets the geometry. - - - The geometry. - - - - - Gets the bezier. - - - The bezier. - - - - - Gets the main . - - - - - Defines a canvas that is able to animate the shapes inside it. - - The type of the drawing context. - - - - Initializes a new instance of the class. - - - - - Occurs when the visual is invalidated. - - - - - Occurs when all the visuals in the canvas are valid. - - - - - Returns true if the visual is valid. - - - true if this instance is valid; otherwise, false. - - - - - Gets the synchronize object. - - - The synchronize. - - - - - Draws the frame. - - The context. - - - - - Gets the drawables count. - - - The drawables count. - - - - - Invalidates this instance. - - - - - - Adds a drawable task. - - The task. - - - - - Sets the paint tasks. - - The tasks. - - - - - Removes the paint task. - - The task. - - - - - Counts the geometries. - - - - - - A set of predefined easing functions. - - - - - Gets the back in. - - - The back in. - - - - - Gets the back out. - - - The back out. - - - - - Gets the back in out. - - - The back in out. - - - - - Gets the bounce in. - - - The bounce in. - - - - - Gets the bounce out. - - - The bounce out. - - - - - Gets the bounce in out. - - - The bounce in out. - - - - - Gets the circle in. - - - The circle in. - - - - - Gets the circle out. - - - The circle out. - - - - - Gets the circle in out. - - - The circle in out. - - - - - Gets the cubic in. - - - The cubic in. - - - - - Gets the cubic out. - - - The cubic out. - - - - - Gets the cubic in out. - - - The cubic in out. - - - - - Gets the ease. - - - The ease. - - - - - Gets the ease in. - - - The ease in. - - - - - Gets the ease out. - - - The ease out. - - - - - Gets the ease in out. - - - The ease in out. - - - - - Gets the elastic in. - - - The elastic in. - - - - - Gets the elastic out. - - - The elastic out. - - - - - Gets the elastic in out. - - - The elastic in out. - - - - - Gets the exponential in. - - - The exponential in. - - - - - Gets the exponential out. - - - The exponential out. - - - - - Gets the exponential in out. - - - The exponential in out. - - - - - Gets the lineal. - - - The lineal. - - - - - Gets the polinominal in. - - - The polinominal in. - - - - - Gets the polinominal out. - - - The polinominal out. - - - - - Gets the polinominal in out. - - - The polinominal in out. - - - - - Gets the quadratic in. - - - The quadratic in. - - - - - Gets the quadratic out. - - - The quadratic out. - - - - - Gets the quadratic in out. - - - The quadratic in out. - - - - - Gets the sin in. - - - The sin in. - - - - - Gets the sin out. - - - The sin out. - - - - - Gets the sin in out. - - - The sin in out. - - - - - Gets the build custom back in. - - - The build custom back in. - - - - - Gets the build custom back out. - - - The build custom back out. - - - - - Gets the build custom back in out. - - - The build custom back in out. - - - - - Gets the build custom elastic in. - - - The build custom elastic in. - - - - - Gets the build custom elastic out. - - - The build custom elastic out. - - - - - Gets the build custom elastic in out. - - - The build custom elastic in out. - - - - - Gets the build custom polinominal in. - - - The build custom polinominal in. - - - - - Gets the build custom polinominal out. - - - The build custom polinominal out. - - - - - Gets the build custom polinominal in out. - - - The build custom polinominal in out. - - - - - Gets the build cubic bezier. - - - The build cubic bezier. - - - - - Defines the BackEasingFunction - - - - - The in easing - - The t. - The s. - - - - - the out easing - - The t. - The s. - - - - - the in out easing - - The t. - The s. - - - - - Defines the BounceEasingFunction - - - - - the in easing. - - The t. - - - - - the out easing. - - The t. - - - - - the in out easing. - - The t. - - - - - Defines the CircleEasingFunction - - - - - the ease in. - - The t. - - - - - the ease out. - - The t. - - - - - the ease in out - - The t. - - - - - Defines the CubicBezierEasingFunction. - - - - - Builds a bezier easing function. - - The m x1. - The m y1. - The m x2. - The m y2. - - Bezier x values must be in [0, 1] range - - - - Defines the CubicEasingFunction - - - - - The ease in. - - The t. - - - - - The ease out. - - The t. - - - - - The ease in out. - - The t. - - - - - A helper class to build delayed animations. - - - - - Initializes a new instance of the class. - - The base function. - The point. - The per point delay. - - - - Gets the function. - - - The function. - - - - - Gets the speed. - - - The speed. - - - - - Defines the ElasticEasingFunction. - - - - - The ease in. - - The t. - a. - The p. - - - - - The ease out. - - The t. - a. - The p. - - - - - The ease in out. - - The t. - a. - The p. - - - - - Defines the ExponentialEasingFunction. - - - - - The ease in. - - The t. - - - - - The ease out. - - The t. - - - - - The ease in out. - - The t. - - - - - Defines the PolinominalEasingFunction. - - - - - The ease in. - - The t. - The e. - - - - - The ease out. - - The t. - The e. - - - - - The ease in out. - - The t. - The e. - - - - - Defines a chart series. - - - - - Gets or sets a series unique identifier, the library handles this id automatically. - - - - - Gets or sets the state where the visual is moved to when the mouse moves over a . - - - - - Gets the properties of the series. - - - - - Gets or sets the name of the series, the name is normally used by or - , the default value is set automatically by the library. - - - - - Gets or sets the values. - - - The values. - - - - - Gets or sets a value indicating whether this instance is visible. - - - true if this instance is visible; otherwise, false. - - - - - Gets or sets the data padding, both coordinates (X and Y) from 0 to 1, where 0 is nothing and 1 is the axis tick - (the separation between every label). - - - The data padding. - - - - - Gets or sets the z index position. - - - The index of the z. - - - - - Gets or sets the value where the direction of the axis changes, by default is 0. - - - - - Gets or sets the animations speed, if this property is null, the - property will be used. - - - The animations speed. - - - - - Gets or sets the easing function to animate the series, if this property is null, the - property will be used. - - - The easing function. - - - - - Gets or sets the tool tip label formatter, this function will build the label when a point in this series - is shown inside a tool tip. - - - The tool tip label formatter. - - - - - Gets or sets the data label formatter, this function will build the label when a point in this series - is shown as data label. - - - The data label formatter. - - - - - Occurs before the series is disposed. - - - - - Gets a array with the points used to generate the plot. - - the chart - - - - - Gets the instances which contain the , according - to the chart's property. - - the chart - the pointer position - - - - - Marks a given point as a given state. - - - - - - - Removes a given point from the given state. - - - - - - - Clears the visuals in the cache and re-starts animations. - - - - - Deletes the series from the user interface. - - - - - Defines a series. - - The type of the model. - - - - - Gets or sets the mapping. - - - The mapping. - - - - - Gets or sets the values. - - - The values. - - - - - An object that is able to throttle an action. - - - - - Initializes a new instance of the class. - - The target action to throttle. - The throttling time. - - - - Schedules a call to the target action. - - - - - - Forces the call to the target action, this call is not throttled. - - - - - - Defines the area helper class. - - The type of the drawing context. - The type of the geometry path. - The type of the line segment. - The type of the move to. - The type of the path context. - - - - Gets or sets the path. - - - The path. - - - - - Gets or sets the start point. - - - The start point. - - - - - Gets or sets the start segment. - - - The start segment. - - - - - Gets or sets the end segment. - - - The end segment. - - - - - Gets or sets a value indicating whether this instance is initialized. - - - true if this instance is initialized; otherwise, false. - - - - - Initializes the helper with the specified transition setter. - - The transition setter. - The default animation. - - - - - Defines the bezier data class. - - - - - Initializes a new instance of the class. - - The chart point. - - - - Gets or sets the target point. - - - The target point. - - - - - Gets or sets the x0. - - - The x0. - - - - - Gets or sets the y0. - - - The y0. - - - - - Gets or sets the x1. - - - The x1. - - - - - Gets or sets the y1. - - - The y1. - - - - - Gets or sets the x2. - - - The x2. - - - - - Gets or sets the y2. - - - The y2. - - - - - Gets or sets the original data. - - - The original data. - - - - - Gets or sets a value indicating whether this instance is first. - - - true if this instance is first; otherwise, false. - - - - - Gets or sets a value indicating whether this instance is last. - - - true if this instance is last; otherwise, false. - - - - - Defines a method that will handle an event in a chart. - - The type of the drawing context. - The chart. - - - - Defines a point in a chart. - - - - - Initializes a new instance of the class. - - The chart. - The series. - - - - Gets or sets a value indicating whether this instance is null. - - - true if this instance is null; otherwise, false. - - - - - Gets or sets the primary value. - - - The primary value. - - - - - Gets or sets the secondary value. - - - The secondary value. - - - - - Gets or sets the tertiary value. - - - The tertiary value. - - - - - Gets the point as tooltip string. - - - As tooltip string. - - - - - Gets the point as data label. - - - As tooltip string. - - - - - Gets the context. - - - The context. - - - - - Defines the environment of a point in a chart. - - - - - Initializes a new instance of the class. - - The chart. - The series. - - - - Gets the chart. - - - The chart. - - - - - Gets the series. - - - The series. - - - - - Gets the position of the point the collection that was used when the point was drawn. - - - - - Gets the DataSource. - - - - - Gets the visual. - - - The visual. - - - - - Gets the label. - - - The label. - - - - - Gets or sets the area that triggers the ToolTip. - - - - - Defines the chart update parameter. - - - - - Gets or sets a value indicating whether this instance is automatic update. - - - true if this instance is automatic update; otherwise, false. - - - - - Gets or sets a value indicating whether this is throttling. - - - true if throttling; otherwise, false. - - - - - A helper class that tracks both, and - events. - - - - - - The check i notify property changed - - - - - Initializes a new instance of the class. - - The on collection changed handler. - The on item property changed handler. - if true, it will force the check to verify if the type {T} implements INotifyPropertyChanged. - - - - Initializes the listeners. - - The instance. - - - - - Disposes the listeners. - - The instance. - - - - - Defines the data factory class. - - The type of the drawing context. - - - - - Gets the provider. - - The type of the model. - - - - - Defines a data provider. - - - - - - - Initializes a new instance of the class. - - - - - Fetches the the points for the specified series. - - The series. - The chart. - - - - - Disposes a given point. - - The point. - - - - - Gets the Cartesian bounds. - - The chart. - The series. - The x. - The y. - - - - - Gets the pie bounds. - - The chart. - The series. - - Unexpected null stacker - - - - Clears the visuals in the cache. - - - - - - Defines a default paint task. - - The type of the drawing context. - - - - - Gets or sets a value indicating whether this instance is stroke. - - - true if this instance is stroke; otherwise, false. - - - - - Gets or sets a value indicating whether this instance is fill. - - - true if this instance is fill; otherwise, false. - - - - - Gets or sets the index of the z. - - - The index of the z. - - - - - Gets or sets the stroke thickness. - - - The stroke thickness. - - - - - Gets or sets a value indicating whether this instance is completed. - - - true if this instance is completed; otherwise, false. - - - - - Gets or sets the current time. - - - The current time. - - - - - Gets or sets a value indicating whether the element is removed when all the transitions complete. - - - true if remove on completed; otherwise, false. - - - - - Gets or sets a value indicating whether this instance is paused. - - - true if this instance is paused; otherwise, false. - - - - - Adds the geometry to paint task. - - The canvas. - The geometry. - - - - Clones the task. - - - - - - Completes the transitions. - - Name of the property. - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - Gets the geometries. - - The canvas. - The . - - - - - Gets the transition property. - - Name of the property. - - - - - Initializes the task. - - The context. - - - - Removes the geometry from pain task. - - The canvas. - The geometry. - - - - Removes all geometry from paint task. - - The canvas. - - - - Removes a property transition. - - Name of the property. - - - - Sets the geometries. - - The canvas. - The geometries. - - - - Sets the properties transitions. - - The animation. - Name of the property. - - - - - Completes all transitions. - - - - - - Removes all the current transitions. - - - - - - - - - - - - - - - - - - LiveCharts kerner extensions. - - - - - Returns the left, top coordinate of the tooltip based on the found points, the position and the tooltip size. - - - - - - - - - Returns the left, top coordinate of the tooltip based on the found points, the position and the tooltip size. - - The found points. - The position. - Size of the tooltip. - - - - - Gets the tick. - - The type of the drawing context. - The axis. - Size of the control. - - - - - Gets the tick. - - The type of the drawing context. - The axis. - Size of the control. - The bounds. - - - - - Creates a transition builder for the specified properties. - - The animatable. - The properties. - - At least one property is required when calling {nameof(TransitionateProperties)} - - - - Determines whether is bar series. - - The series. - - true if [is bar series] [the specified series]; otherwise, false. - - - - - Determines whether is column series. - - The series. - - true if [is column series] [the specified series]; otherwise, false. - - - - - Determines whether is row series. - - The series. - - true if [is row series] [the specified series]; otherwise, false. - - - - - Determines whether is stacked series. - - The series. - - true if [is stacked series] [the specified series]; otherwise, false. - - - - - Determines whether is vertical series. - - The series. - - true if [is vertical series] [the specified series]; otherwise, false. - - - - - Determines whether is horizontal series. - - The series. - - true if [is horizontal series] [the specified series]; otherwise, false. - - - - - Adds a point to the specified state. - - The chart point. - The state. - - - - Removes a point from the specified state. - - The chart point. - The state. - - - - Adds a point to the hover state. - - The chart point. - - - - Removes a point from the hover state. - - The chart point. - - - - Defines a hover area. - - - - - Determines whether the area is trigger by the specified point in the user interface. - - The point. - The strategy. - - true if [is trigger by] [the specified point]; otherwise, false. - - - - - Suggests the tooltip placement. - - The context. - - - - Defines an Axis in a Cartesian chart. - - - - - Gets the previous data bounds. - - - The previous data bounds. - - - - - Gets the previous data bounds. - - - The previous data bounds. - - - - - Gets the data bounds, the min and max values in the axis. - - - The data bounds. - - - - - Gets the data visible bounds, the min and max visible values in the axis. - - - The data bounds. - - - - - Gets the orientation. - - - The orientation. - - - - - Gets or sets the padding. - - - The padding. - - - - - Gets or sets the xo, a reference used internally to calculate the axis position. - - - The xo. - - - - - Gets or sets the yo, a reference used internally to calculate the axis position.. - - - The yo. - - - - - Gets or sets the labeler, a function that receives a number and return the label content as string. - - - The labeler. - - - - - Gets or sets the minimum step, the step defines the interval between every separator in the axis, - LiveCharts will calculate it automatically based on the chart data and the chart size size, if the calculated step is less than the - then will be used as the axis step, default is 0. - - - The step. - - - - - Gets or sets the unit with, it means the width of every point (if the series requires it) in the chart values scale, this value - should normally be 1, unless you are plotting in a custom scale, default is 1. - - - The unit with. - - - - - Gets or sets the minimum value visible in the axis, any point less than this value will be hidden, - set it to null to use a value based on the smaller value in the chart. - - - The minimum value. - - - - - Gets or sets the maximum value visible in the axis, any point greater than this value will be hidden, - set it null to use a value based on the greater value in the chart. - - - The maximum value. - - - - - Gets or sets the previous maximum limit. - - - The previous maximum limit. - - - - - Gets or sets the previous minimum limit. - - - The previous minimum limit. - - - - - Gets or sets a value indicating whether this instance is visible. - - - true if this instance is visible; otherwise, false. - - - - - Gets or sets a value indicating whether the axis is inverted based on the Cartesian coordinate system. - - - true if this instance is inverted; otherwise, false. - - - - - Gets or sets the axis position. - - - The position. - - - - - Gets or sets the labels rotation. - - - The labels rotation. - - - - - Gets or sets the size of the text. - - - The size of the text. - - - - - Gets or sets the labels, if labels are not null, then the axis label will be pulled from the labels collection, - the label is mapped to the chart based on the position of the label and the position of the point, both integers, - if the axis requires a label outside the bounds of the labels IList then the index will be returned as the label. - Default value is null. - - - The labels. - - - - - Gets or sets the animations speed, if this property is null, the - property will be used. - - - The animations speed. - - - - - Gets or sets the easing function to animate the series, if this property is null, the - property will be used. - - - The easing function. - - - - - Gets or sets a value indicating whether the separator lines are visible. - - - - - Initializes the axis for the specified orientation. - - The orientation. - - - - Defines an Axis in a Cartesian chart. - - The type of the drawing context. - - - - - Gets or sets the text brush. - - - The text brush. - - - - - Gets or sets the separators brush. - - - The separators brush. - - - - - Measures the axis. - - The chart. - - - - Gets the size of the possible. - - The chart. - - - - - Gets the deleting tasks. - - - The deleting tasks. - - - - - Defines a bar series point. - - The type of the drawing context. - - - - - Gets or sets the rx, the radius used in the x axis to round the corners of each column in pixels. - - - The rx. - - - - - Gets or sets the ry, the radius used in the y axis to round the corners of each column in pixels. - - - The ry. - - - - - Gets or sets the padding for each group of bars that share the same secondary coordinate. - - - The bar group padding. - - - - - Gets or sets the maximum width of the bar. - - - The maximum width of the bar. - - - - - Gets or sets a value indicating whether the bar position respects the other bars that share - the same . - - - - - Defines a Cartesian chart view, this view is able to host one or many series in a Cartesian coordinate system. - - The type of the drawing context. - - - - - Gets the core. - - - The core. - - - - - Gets or sets the x axes. - - - The x axes. - - - - - Gets or sets the y axes. - - - The y axes. - - - - - Gets or sets the series to plot in the user interface. - - - The series. - - - - - Gets or sets the zoom mode. - - - The zoom mode. - - - - - Gets or sets the zooming speed from 0 to 1, where 0 is the fastest and 1 the slowest. - - - The zooming speed. - - - - - Scales the UI point. - - The point. - Index of the x axis. - Index of the y axis. - - - - - Defines a Cartesian series. - - The type of the drawing context. - - - - - Gets or sets the axis index where the series is scaled in the X plane, the index must exist - in the collection. - - - The index of the axis. - - - - - Gets or sets the axis index where the series is scaled in the Y plane, the index must exist - in the collection. - - - The index of the axis. - - - - - Gets or sets the data labels position. - - - The data labels position. - - - - - Gets the series bounds. - - The chart. - The x. - The y. - the series bounds - - - - Measures the series and schedules the draw in specified chart. - - The chart. - The x axis. - The y axis. - - - - Defines a chart. - - - - - Gets or sets the measure work. - - - The measure work. - - - - - Gets the chart view. - - - The view. - - - - - Gets the canvas. - - - The canvas. - - - - - Gets the legend position. - - - The legend position. - - - - - Gets the legend orientation. - - - The legend orientation. - - - - - Gets the toolTip position. - - - The toolTip position. - - - - - Gets the toolTip finding strategy. - - - The toolTip finding strategy. - - - - - Updates the chart in the user interface. - - - - - Defines a chart legend. - - The type of the drawing context. - - - - Draws the legend for the specified chart. - - The chart. - - - - Defines a tool tip. - - The type of the drawing context. - - - - Shows the tool tip in the specified chart. - - The found points. - The chart. - - - - Hides this tool tip instance. - - - - - Defines a chart view - - - - - Gets the core. - - - The core. - - - - - Sets the back color of the control. - - - The color of the back. - - - - - Gets the size of the control. - - - The size of the control. - - - - - Gets or sets the draw margin, if this property is null, the library will calculate a margin, this margin is the distance - between the view bounds and the drawable area. - - - The draw margin. - - - - - Gets or sets the animations speed. - - - The animations speed. - - - - - Gets or sets the easing function, the library already provides many easing functions in the - LiveCharts.EasingFunction static class. - - - The easing function. - - - - - Gets or sets the legend position. - - - The legend position. - - - - - Gets or sets the legend orientation. - - - The legend orientation. - - - - - Gets or sets the tooltip position. - - - The tooltip position. - - - - - Gets or sets the tooltip finding strategy. - - - The tooltip finding strategy. - - - - - Defines a chart view. - - The type of the drawing context. - - - - Occurs before the chart is measured, this is the first step before the chart updates. - - - - - Occurs when the chart started an update, just when the drawing loop started. - - - - - Occurs when a chart update finished, just when the drawing loop finished. - - - - - Gets or sets a value indicating whether the automatic updates are enabled. - - - true if automatic update are enabled; otherwise, false. - - - - - Gets the core canvas. - - - The core canvas. - - - - - Gets the legend. - - - The legend. - - - - - Gets the tooltip. - - - The tooltip. - - - - - Gets or sets the point states. - - - The point states. - - - - - Shows the tool tip based on the given points. - - The points. - - - - Hides the tool tip. - - - - - Defines adata factory provider. - - The type of the drawing context. - - - - Gets the provider. - - The type of the model. - - - - - Defines a series a chart series that has a visual representation in the user interface. - - The type of the drawing context. - - - - - Gets or sets the stroke drawable task. - - - The stroke. - - - - - Gets or sets the fill drawable task. - - - The fill. - - - - - Gets or sets the data labels drawable task. - - - - - Gets or sets the size of the data labels. - - - The size of the data labels. - - - - - Gets or sets the data labels padding. - - - The data labels padding. - - - - - Gets the default paint context, normally handled internally to display tooltips and legends. - - - The default paint context. - - - - - Gets the stack group, normally used internally to handled the stacked series. - - - - - - Gets the deleting tasks. - - - The deleting tasks. - - - - - Defines a gauge builder - - - - - Gets or sets the inner radius. - - - The inner radius. - - - - - Gets or sets the offset radius, the separation between each gauge if multiple gauges are nested. - - - The relative inner radius. - - - - - Gets or sets the maximum width of the radial column. - - - The maximum width of the radial column. - - - - - Gets or sets the corner radius. - - - The corner radius. - - - - - Gets or sets the radial align. - - - The radial align. - - - - - Gets or sets the background inner radius. - - - The background inner radius. - - - - - Gets or sets the background offset radius, the separation between each gauge if multiple gauges are nested. - - - The background relative inner radius. - - - - - Gets or sets the width of the background maximum radial column. - - - The width of the background maximum radial column. - - - - - Gets or sets the background corner radius. - - - The background corner radius. - - - - - Gets or sets the background. - - - The background. - - - - - Gets or sets the size of the labels. - - - The size of the labels. - - - - - Gets or sets the labels position. - - - The labels position. - - - - - Gets or sets the label formatter. - - - The label formatter. - - - - - Defines a line series plot. - - The type of the drawing context. - - - - - Gets or sets the size of the geometry. - - - The size of the geometry. - - - - - Gets or sets the line smoothness, where 0 is a straight line, and 1 the most curved line, default is 0.65 - - - The line smoothness. - - - - - Gets or sets a value indicating whether the line should split every null point, - enabling it has a performance impact, default is true. - - - - - Gets or sets the geometry fill. - - - The shapes fill. - - - - - Gets or sets the geometry stroke. - - - The shapes stroke. - - - - - Defines a pie chart. - - The type of the drawing context. - - - - - Gets the core. - - - The core. - - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the initial rotation in degrees, this angle specifies where the first pie slice will be drawn, then the remaining - slices will stack according to its corresponding position. - - - The initial rotation. - - - - - Gets or sets the maximum angle in degrees, default is 360. - - - The maximum angle. - - - - - Gets or sets the total, it is the maximum value a pie slice can represent, when this property is null, the property - will be calculated automatically based on the series data. Default value is null. - - - The total stacked. - - - - - Defines a pie series. - - The type of the drawing context. - - - - - Gets or sets the push out, it is the distance in pixels between the center of the control and the pie slice. - - - The push out. - - - - - Gets or sets the inner radius of the slice in pixels. - - - The inner radius. - - - - - Gets or sets the maximum outer, the value goes from 0 to 1, where 1 is the full available radius and 0 is none. - - - The maximum outer radius. - - - - - Gets or sets the hover push out in pixes, it defines the where the pointer is over the slice. - - - The hover pus hout. - - - - - Gets or sets the corner radius for every pie slice in the series. - - - The corner radius. - - - - - Gets or sets a value indicating whether the direction of the corner radius is inverted. - - - true if the direction is inverted; otherwise, false. - - - - - Gets or sets the maximum width of the radial column, if the width of the radial column slice exceeds this dimension the radial - column width will be capped to the value of this property, default value is double.MaxValue. - - - The maximum width of the radial column. - - - - - Gets or sets the data labels position. - - - The data labels position. - - - - - Gets or sets the radial align, this property determines the alignment of the pie slice only when the width of the column - exceeds . - - - The radial align. - - - - - Gets or sets the relative inner radius, it is the extra inner radius for every stacked slice. - - - The inner padding. - - - - - Gets or sets the relative outer radius, it is the decrement in the outer radius for every stacked slice. - - - The inner padding. - - - - - Gets or sets a value indicating whether this instance is a fill series, a fill series is a dummy series that will create a 360 degrees - pie slice, this series is normally used to set a background for pie charts, specially useful o create gauges. - - - true if this instance is fill series; otherwise, false. - - - - - Gets the series bounds. - - The chart. - - - - - Measures the series and schedules the draw in specified chart. - - The chart. - - - - Defines a scatter series. - - The type of the drawing context. - - - - - Gets or sets the size of the geometry. - - - The size of the geometry. - - - - - Gets or sets the minimum size of the geometry. - - - The minimum size of the geometry. - - - - - Defines a stacked bar series. - - The type of the drawing context. - - - - - Gets or sets the rx, the radius used in the x axis to round the corners of each column, it goes from 0 to 1. - - - The rx. - - - - - Gets or sets the ry, the radius used in the y axis to round the corners of each column, it goes from 0 to 1. - - - The ry. - - - - - Gets or sets the maximum width of the bar. - - - The maximum width of the bar. - - - - - Gets or sets the stack group. - - - The stack group. - - - - - LiveCharts global settings - - - - - Gets or sets the default easing function. - - - The default easing function. - - - - - Gets or sets the default animations speed. - - - The default animations speed. - - - - - Gets or sets the default zoom speed. - - - The default zoom speed. - - - - - Gets or sets the default zoom mode. - - - The default zoom mode. - - - - - Gets or sets the default legend position. - - - The default legend position. - - - - - Gets or sets the default legend orientation. - - - The default legend orientation. - - - - - Gets or sets the default tooltip position. - - - The default tooltip position. - - - - - Gets or sets the default tooltip finding strategy. - - - The default tooltip finding strategy. - - - - - Gets the theme identifier. - - - The theme identifier. - - - - - Gets the axis provider. - - - The axis provider. - - - - - Adds or replaces a mapping for a given type, the mapper defines how a type is mapped to a instance, - then the will be drawn as a point in our chart. - - The type of the model. - The mapper. - - - - - Sets the default animations speed. - - The animations speed. - the current settings - - - - Withes the default easing function. - - The easing function. - the current settings - - - - Withes the default zoom speed. - - The speed. - the current settings - - - - Withes the default zoom mode. - - The zoom mode. - the current settings - - - - Removes a map from the settings. - - The type of the model. - - - - - Adds the default styles. - - The type of the drawing context. - The builder. - - - - - Gets the styles builder. - - The type of the drawing context. - - $"The type {nameof(TDrawingContext)} is not registered. - - - - Enables LiveCharts to be able to plot short, int, long, float, double, decimal, short?, int?, long?, float?, double?, decimal?, - , , , , - and . - - - - - - The named labeler helper class. - - - - - Initializes a new instance of the class. - - The labels. - - - - Functions the specified value. - - The value. - - - - - Defines the paint context. - - The type of the drawing context. - - - - Gets or sets the width. - - - The width. - - - - - Gets or sets the height. - - - The height. - - - - - Gets or sets the paint tasks schedule. - - - The paint tasks schedule. - - - - - Defines a schedule to be drawn by an instance. - - The type of the drawing context. - - - - Initializes a new instance of the class. - - The task. - The geometries. - - - - Initializes a new instance of the class. - - The task. - The geometries. - - - - Gets or sets the drawable task. - - - The drawable task. - - - - - Gets or sets the geometries. - - - The geometries. - - - - - Defines the points states dictionary class. - - The type of the drawing context. - - - - Gets or sets the stroke and fill for the specified state name. - - - The stroke and fill. - - Name of the state. - - $"A null instance is not valid at this point, to delete a key please use the {nameof(DeleteState)}() method. - - - - Gets the chart. - - - The chart. - - - - - Gets the states. - - - - - - Add the visual state for the given key. - - The key. - The fill. - The stroke. - - - - - Deletes the state. - - Name of the state. - - - - - Removes the state. - - The state. - - - - - Defines a rectangle hover area. - - - - - - Gets or sets the x location. - - - The x. - - - - - Gets or sets the y location. - - - The y. - - - - - Gets or sets the width. - - - The width. - - - - - Gets or sets the height. - - - The height. - - - - - Sets the area dimensions. - - The x. - The y. - The width. - The height. - - - - - - - - - - - Defines a semicircle hover area. - - - - - - Gets or sets the center x. - - - The center x coordinate. - - - - - Gets or sets the center y. - - - The center y coordinate. - - - - - Gets or sets the start angle in degrees. - - - - - Gets or sets the and angle in degrees. - - - - - Gets or sets the radius. - - - The radius. - - - - - Sets the area dimensions. - - The center x. - The center y. - The start angle. - The end angle. - The radius. - - - - - - - - - - - Defines a series context. - - The type of the drawing context. - - - - Initializes a new instance of the class. - - The series. - - - - Gets the column position. - - The series. - - - - - Gets the column series count. - - - - - - Gets the row position. - - The series. - - - - - Gets the row series count. - - - - - - Gets the stacked column position. - - The series. - - - - - Gets the stacked column series count. - - - - - - Gets the stacked row position. - - The series. - - - - - Gets the stacked row series count. - - - - - - Gets the stack position. - - The series. - The stack group. - - - - - Defines the series properties enumeration. - - - - - includes all series - - - - - The Cartesian series - - - - - The bar series - - - - - The line series - - - - - The scatter series - - - - - The pie series - - - - - The stacked series - - - - - The vertical orientation - - - - - The horizontal orientation - - - - - The gauge. - - - - - The gauge fill. - - - - - The sketch - - - - - The solid - - - - - Defines a series style rule. - - The type of the visual. - The type of the drawing context. - - - - Gets or sets the series properties. - - - The series properties. - - - - - Gets or sets the rule. - - - The rule. - - - - - Defines the a stacked value. - - - - - Gets or sets the start. - - - The start. - - - - - Gets or sets the end. - - - The end. - - - - - Gets or sets the total stacked. - - - The total. - - - - - Defines the stacker helper class. - - The type of the drawing context. - - - - Initializes a new instance of the class. - - - - - Gets the maximum length. - - - The maximum length. - - - - - Gets the series stack position. - - The series. - - - - - Stacks the point. - - The point. - The series stack position. - - - - - Gets the stack. - - The point. - The series stack position. - - - - - Defines the stroke and ill drawable class. - - The type of the drawing context. - - - - Initializes a new instance of the class. - - The stroke. - The fill. - - - - Gets the stroke. - - - The stroke. - - - - - Gets the fill. - - - The fill. - - - - - Defines the tooltip placement context class. - - - - - Gets or sets the most top. - - - The most top. - - - - - Gets or sets the most bottom. - - - The most bottom. - - - - - Gets or sets the most right. - - - The most right. - - - - - Gets or sets the most left. - - - The most left. - - - - - Gets or sets the pie x. - - - The pie x. - - - - - Gets or sets the pie y. - - - The pie y. - - - - - Defines the tooltip point class. - - - - - Initializes a new instance of the class. - - The series. - The point. - - - - Gets or sets the series. - - - The series. - - - - - Gets or sets the point. - - - The point. - - - - - Defines a point in a chart with known visual and label types. - - The type of the visual. - The type of the label. - The type of the drawing context. - - - - Initializes a new instance of the class. - - The point. - - - - Gets the chart point. - - - The chart point. - - - - - Gets the visual. - - - The visual. - - - - - Gets the label. - - - The label. - - - - - Defines bounds for both, X and Y axes. - - - - - Initializes a new instance of the class. - - - - - Gets or sets the primary bounds. - - - - - Gets or sets the secondary bounds. - - - - - Gets or sets the tertiary bounds. - - - - - Gets or sets the primary bounds. - - - - - Gets or sets the secondary bounds. - - - - - Gets or sets the tertiary bounds. - - - - - Gets or sets the minimum delta primary. - - - The minimum delta primary. - - - - - Gets or sets the minimum delta secondary. - - - The minimum delta secondary. - - - - - Defines common functions to build labels in a chart. - - - - - Gets the default labeler. - - - The default. - - - - - Gets the seven representative digits labeler. - - - The seven representative digits. - - - - - Gets the currency labeler. - - - The currency. - - - - - Sets the default labeler. - - The labeler. - - - - Formats to currency. - - The value. - The thousands. - The decimals. - The symbol. - - - - - Builds a named labeler. - - The labels. - - - - - Defines the data to plot as a line. - - - - - Initializes a new instance of the class. - - if set to true [is stacked]. - - - - - - - - - - - - - - - - - - - - - - - - - Sets the default path transitions. - - The area helper. - The default animation. - - - - - - - - - - - - - - - - - Releases unmanaged and - optionally - managed resources. - - - - - - LiveCharts global settings. - - - - - Gets a value indicating whether this instance is configured. - - - true if this instance is configured; otherwise, false. - - - - - Gets the current settings. - - - The current settings. - - - - - Gets the bar series hover key. - - - The bar series hover key. - - - - - Gets the line series hover key. - - - The line series hover key. - - - - - Gets the pie series hover key. - - - The pie series hover key. - - - - - Gets the scatter series hover key. - - - The scatter series hover key. - - - - - Gets the stacked bar series hover key. - - - The stacked bar series hover key. - - - - - The disable animations - - - - - Configures LiveCharts. - - The configuration. - - $"{nameof(LiveChartsSettings)} must not be null. - - - - Defines a mapper for the given type. - - The type of the model. - The mapper. - - - - - Defines the axis orientation. - - - - - The unknown orientation. - - - - - The x orientation. - - - - - The y orientation. - - - - - Defines an axis position. - - - - - Places the axis at the bottom for X axes and at the left for Y axes - - - - - Places the axis at the top for X axes and at the right for Y axes - - - - - Defines an axis tick, the distance between every separator. - - - - - Gets or sets the value. - - - The value. - - - - - Gets or sets the magnitude. - - - The magnitude. - - - - - Represents the maximum and minimum values in a set. - - - - - Creates a new instance of the class. - - - - - Gets or sets the maximum value in the data set. - - - - - Gets or sets the minimum value in the data set. - - - - - Gets the delta, the absolute range in the axis. - - - The delta. - - - - - Gets or sets the minimum delta. - - - The minimum delta. - - - - - Compares the current bounds with a given value, - if the given value is greater than the current instance property then the given value is set at property, - if the given value is less than the current instance property then the given value is set at property. - - the value to append - Whether the value affected the current bounds, true if it affected, false if did not. - - - - Defines the data labels position. - - - - - Aligns the label to the end in the axis direction. - - - - - Aligns the label to the start in the axis direction. - - - - - Aligns the label to the middle of the axis. - - - - - Aligns the label to the top. - - - - - Aligns the label to the top. - - - - - Aligns the label to the left. - - - - - Aligns the label to the right. - - - - - Defines the legend orientation. - - - - - The automatic orientation. - - - - - The horizontal orientation. - - - - - The vertical orientation. - - - - - Defines the legend position enumeration. - - - - - The hidden position, hides the legend form the user interface. - - - - - The top position, places the legend at the top of the chart. - - - - - The left position, places the legend at the left of the chart. - - - - - The right position, places the legend at the right of the chart. - - - - - The bottom position, places the legend at the bottom of the chart. - - - - - Defines the margin class. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The left. - The top. - The right. - The bottom. - - - - Gets or sets the left. - - - The left. - - - - - Gets or sets the top. - - - The top. - - - - - Gets or sets the right. - - - The right. - - - - - Gets or sets the bottom. - - - The bottom. - - - - - - - - - - Places the label at the center of the chart. - - - - - Aligns the label to the end in the axis direction. - - - - - Aligns the label to the start in the axis direction. - - - - - Aligns the label to the middle of the axis. - - - - - Defines the radial alignment. - - - - - Aligns the element to the outer radius. - - - - - Aligns the element to the center of the outer and inner radius. - - - - - Aligns the element to the inner radius. - - - - - Defines the scaler class, this class helps to scale from the data scale to the user interface scale and vise versa. - - - - - Initializes a new instance of the class. - - The draw margin location. - Size of the draw margin. - The axis. - Indicates if the scaler should be built based on the previous known data. - The axis is not ready to be scaled. - - - - Converts to pixels. - - The value. - - - - - Converts to chart values. - - The pixels. - - - - - Defines the stack position. - - The type of the drawing context. - - - - Gets or sets the stacker. - - - The stacker. - - - - - Gets or sets the position. - - - The position. - - - - - Stacks the point. - - The point. - - - - - Gets the stack. - - The point. - - - - - Defines the tooltip finding strategy. - - - - - Compares X and Y coordinates. - - - - - Compares X coordinates and ignores Y. - - - - - Compares Y coordinates and ignores X. - - - - - Defines the tool tip position. - - - - - The hidden position, tool tips will be hidden. - - - - - The top position, places the tool tip at the top of the hovered point. - - - - - The bottom position, places the tool tip at the bottom of the hovered point. - - - - - The left position, places the tool tip at the left of the hovered point. - - - - - The right position, places the tool tip at the right of the hovered point. - - - - - The center position, places the tool tip at the center of the hovered point. - - - - - Defines the zooming and panning mode. - - - - - Disables zooming and panning. - - - - - Zooms only in the X axis. - - - - - Zooms only in the Y axis. - - - - - Zooms on both axes. - - - - - Defines the zooming direction. - - - - - The zoom in - - - - - The zoom out - - - - - Defines a float motion property. - - - - - Initializes a new instance of the class. - - Name of the property. - - - - Initializes a new instance of the class. - - Name of the property. - The value. - - - - - - - Defines a motions property. - - - - - Gets or sets a value indicating whether this instance is completed. - - - true if this instance is completed; otherwise, false. - - - - - Gets the name of the property. - - - The name of the property. - - - - - Gets or sets the animation. - - - The animation. - - - - - The object tracks where a property of a is in a time line. - - - - - - From value - - - - - To value - - - - - Initializes a new instance of the class. - - Name of the property. - - - - Gets the value where the transition began. - - - - - Gets the value where the transition finished or will finish. - - - - - Gets or sets the animation to define the transition. - - - - - Gets the property name. - - - - - Gets or sets a value indicating whether this instance is completed. - - - true if this instance is completed; otherwise, false. - - - - - Moves to he specified value. - - The value to move to. - The instance that is moving. - - - - Gets the current movement in the . - - - - - - - Called to get the movement at a specific progress. - - The progress. - - - - - Defines a pie chart. - - The type of the drawing context. - - - - - Initializes a new instance of the class. - - The view. - The default platform configuration. - The canvas. - - - - Gets the series. - - - The series. - - - - - Gets the drawable series. - - - The drawable series. - - - - - Gets the view. - - - The view. - - - - - Gets the value bounds. - - - The value bounds. - - - - - Gets the index bounds. - - - The index bounds. - - - - - Gets the pushout bounds. - - - The pushout bounds. - - - - - Finds the points near to the specified point. - - The pointer position. - - - - - - - - Measures this chart. - - - - - - Called when the updated the throttler is unlocked. - - - - - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gets or sets the data labels position. - - - The data labels position. - - - - - - - - - - - Defines the default behavior when a point is added to a state. - - The visual. - The chart. - - - - Defines the default behavior when a point is removed from a state. - - The visual. - The chart. - - - - Called when the paint context changed. - - - - - GEts the stack group - - - - - - - Sets the default point transitions. - - The chart point. - Unable to initialize the point instance. - - - - Softs the delete point. - - The point. - The primary scale. - The secondary scale. - - - - Gets the label polar position. - - The center x. - The center y. - The radius. - The start angle. - The sweep angle. - Size of the label. - The position. - - - - - Deletes the point from the chart. - - - - - - - Defines the row series - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - Initializes a new instance of the class. - - - - - - - - - - - - - - - - - Defines a scatter series. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - Initializes a new instance of the class. - - - - - Gets or sets the minimum size of the geometry. - - - The minimum size of the geometry. - - - - - Gets or sets the size of the geometry. - - - The size of the geometry. - - - - - - - - - - - - - - - - - - - - Defines a series in a Cartesian chart. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - - - The subscribed to - - - - - The implements icp - - - - - The pivot - - - - - The data provider - - - - - The ever fetched - - - - - Initializes a new instance of the class. - - The properties. - - - - - - - - - - Gets or sets the data set to draw in the chart. - - - - - - - - Gets or sets the mapping that defines how a type is mapped to a instance, - then the will be drawn as a point in the chart. - - - - - - - - - - - Occurs when an instance of is measured. - - - - - Occurs when an instance of is created. - - - - - Occurs when a property changes. - - - - - - - - Gets or sets a delegate that will be called every time a instance - is added to a state. - - - - - Gets or sets a delegate that will be called every time a instance - is removed from a state. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Softs the delete point. - - The point. - The primary scale. - The secondary scale. - - - - - Called when a point was measured. - - The chart point. - - - - Called when a point is created. - - The chart point. - - - - Sets the default point transitions. - - The chart point. - - - - - Called when a point was added to a sate. - - The visual. - The chart. - - - - Called when a point was removed from a state. - - The visual. - The chart. - - - - Defines the default behavior when a point is added to a state. - - The visual. - The chart. - - - - Defines the default behavior when a point is removed from a state. - - The visual. - The chart. - - - - Called when a property changed. - - Name of the property. - - - - - Defines the stacked area series class. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - The type of the path geometry. - The type of the line segment. - The type of the bezier segment. - The type of the move to command. - The type of the path arguments. - - - - - Initializes a new instance of the class. - - - - - Defines the stacked bar series class. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - - The stack group - - - - - Initializes a new instance of the class. - - The series properties. - - - - Gets or sets the stack group. - - - The stack group. - - - - - Gets or sets the maximum width of the bar. - - - The maximum width of the bar. - - - - - - - - - - - Called when the paint context changed. - - - - - Gets the stack group. - - - - - - - Defines the stacked column series class. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - Initializes a new instance of the class. - - - - - Measures this series. - - The chart. - The secondary axis. - The primary axis. - Unexpected null stacker - - - - Gets the bounds. - - The chart. - The secondary axis. - The primary axis. - - - - - Sets the default point transitions. - - The chart point. - Unable to initialize the point instance. - - - - Softs the delete point. - - The point. - The primary scale. - The secondary scale. - - - - Defines a stacked row series. - - The type of the model. - The type of the visual. - The type of the label. - The type of the drawing context. - - - - - Initializes a new instance of the class. - - - - - Measures this series. - - The chart. - The secondary axis. - The primary axis. - Unexpected null stacker - - - - Gets the bounds. - - The chart. - The secondary axis. - The primary axis. - - - - - Sets the default point transitions. - - The chart point. - Unable to initialize the point instance. - - - - Softs the delete point. - - The point. - The primary scale. - The secondary scale. - - - - Defines a set of predefined colors to use. - - - - - Gets the fluent design colors. - - - The fluent design. - - - - - Gets the material design500 colors. - - - The material design500. - - - - - Gets the material design200 colors. - - - The material design200. - - - - - Gets the material design800 colors. - - - The material design800. - - - - - Defines the LiveCharts styler extensions. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects when used as gauges. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects when used as gauges fills. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for tacked objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for vertical objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for horizontal objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for stacked objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for stacked vertical objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for stacked horizontal objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder for objects. - - The type of the drawing context. - The styler. - The predicate. - - - - - Defines a style builder. - - The type of the drawing context. - - - - Gets the current colors. - - - The current colors. - - - - - Gets the style. - - - The style. - - - - - Gets or sets the series default resolver. - - - The series default resolver. - - - - - Gets or sets the axis default resolver. - - - The axis default resolver. - - - - - Uses the colors. - - The colors. - The current theme instance - - - - Creates a new styles builder and configures it using the given predicate. - - The predicate. - The current theme instance - - - - Sets the series defaults resolver. - - The resolver. - - - - - Sets the axis defaults resolver. - - The resolver. - - - - - Gets the objects builder. - - The current theme instance - - - - Resolves the series defaults. - - The colors. - The series. - Forces the apply of the theme. - - - - Resolves the axis defaults. - - The axis. - /// Forces the apply of the theme. - - - - Defines an object that must initialize live charts visual objects, this object defines how things will - be drawn by default, it is highly related to themes. - - - - - Gets or sets the chart builder. - - - The chart builder. - - - - - Gets or sets the axis builder. - - - The axis builder. - - - - - Gets or sets the series builder. - - - The pie series builder. - - - - - Gets or sets the pie series builder. - - - The pie series builder. - - - - - Gets or sets the gauge series builder. - - - The pie series builder. - - - - - Gets or sets the gauge fill series builder. - - - The pie series builder. - - - - - Gets or sets the Cartesian series builder. - - - The pie series builder. - - - - - Gets or sets the line series builder. - - - The pie series builder. - - - - - Gets or sets the stacked line series builder. - - - The pie series builder. - - - - - Gets or sets the bar series builder. - - - The pie series builder. - - - - - Gets or sets the column series builder. - - - The pie series builder. - - - - - Gets or sets the row series builder. - - - The pie series builder. - - - - - Gets or sets the stacked bar series builder. - - - The pie series builder. - - - - - Gets or sets the stacked column series builder. - - - The pie series builder. - - - - - Gets or sets the stacked row series builder. - - - The pie series builder. - - - - - Gets or sets the scatter series builder. - - - The pie series builder. - - - - - Constructs a chart. - - The chart. - - - - Constructs an axis. - - The axis. - - - - Constructs a series. - - The series. - - - diff --git a/docs/_assets/install-chart.gif b/docs/_assets/install-chart.gif new file mode 100644 index 000000000..b1c40113f Binary files /dev/null and b/docs/_assets/install-chart.gif differ diff --git a/docs/_assets/labelsdensity.gif b/docs/_assets/labelsdensity.gif new file mode 100644 index 000000000..60fa0b428 Binary files /dev/null and b/docs/_assets/labelsdensity.gif differ diff --git a/docs/_assets/tooltip-format1.png b/docs/_assets/tooltip-format1.png new file mode 100644 index 000000000..71a139d46 Binary files /dev/null and b/docs/_assets/tooltip-format1.png differ diff --git a/docs/_assets/tooltip-format2.png b/docs/_assets/tooltip-format2.png new file mode 100644 index 000000000..8e1b01a18 Binary files /dev/null and b/docs/_assets/tooltip-format2.png differ diff --git a/docs/_assets/tooltip-format3.png b/docs/_assets/tooltip-format3.png new file mode 100644 index 000000000..9797bfbce Binary files /dev/null and b/docs/_assets/tooltip-format3.png differ diff --git a/docs/_assets/tooltip-format4.png b/docs/_assets/tooltip-format4.png new file mode 100644 index 000000000..9b89c0d85 Binary files /dev/null and b/docs/_assets/tooltip-format4.png differ diff --git a/docs/about/mvvm.md b/docs/about/mvvm.md index ad0a1decb..c7f6bc91a 100644 --- a/docs/about/mvvm.md +++ b/docs/about/mvvm.md @@ -51,9 +51,7 @@ frameworks by the library and to implement `INotifyPropertyChanged` to handle au ## This site uses CommunityToolkit.Mvvm package Probably the less lovely thing about MVVM is how verbose it was, now with source generators, the dotnet foundation is maintaining the -[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/), this is a game changer IMO, it makes MVVM supper easy, -basically you only need to make your view models `partial` classes, then add the `ObservableObject` attribute to the class and -the `ObservableProperty` attribute a field inside your class. +[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/), it makes MVVM easier. To define a series property that notifies the change to the UI, without any MVVM framework a view model would look like: @@ -88,13 +86,13 @@ Too much code to declare a property isn't it? but now we can use the `CommunityT
using LiveChartsCore;
 using CommunityToolkit.Mvvm.ComponentModel;
 
-[ObservableObject]
-public partial class ViewModel
+public partial class ViewModel : ObservableObject
 {
     [ObservableProperty]
     public ISeries[] _series;
 }
-Notice the `ObservableProperty` attribute was added to the *_series* field. By convention and with the magic of source generators the property -`Series` now exists in our class, source generators are adding all this boring and repetitive code for us, this is just a quick guide -to get started with the docs in this site but you can learn more about the toolkit [here](https://www.youtube.com/watch?v=aCxl0z04BN8). +Now we inherited from `ObservableObject` and marked the *_series* field with the `ObservableProperty` attribute; by convention and with +the magic of source generators, the property `Series` now exists in our class, source generators are adding all this boring and repetitive +code for us, this is just a quick guide to get started with the docs in this site but you can learn more about the +toolkit [here](https://www.youtube.com/watch?v=aCxl0z04BN8) or in the [official docs](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/). diff --git a/docs/cartesianChart/axes.md b/docs/cartesianChart/axes.md index ed8ba8895..3da8222ad 100644 --- a/docs/cartesianChart/axes.md +++ b/docs/cartesianChart/axes.md @@ -513,6 +513,36 @@ YAxes = new List<Axis> } }; +## Custom Separators + +The library calculates the separators based on the data and the size of the chart, but we can manually set our own separators, +When the `CustomSeparators` property is not null, the library will not calculate the separators, instead it will use the +collection we passed here. + +
public Axis[] YAxes { get; set; } =
+    {
+        new Axis
+        {
+            // We can specify a custom separator collection
+            // the library will use this separators instead of
+            // calculating them based on the data of the chart
+            CustomSeparators = new double[] { 0, 10, 25, 50, 100 },
+            SeparatorsPaint = new SolidColorPaint(SKColors.Black.WithAlpha(100))
+        }
+    };
+ +![image]({{ assets_url }}/docs/samples/axes/customSeparatorsInterval/result.png) + +## Labels Density + +Separators are calculated automatically when the `CustomSeparators` and `Labels` properties are not set, the library decides +the number of separators and distance between each one, based on the data, the size of the chart, and also based on the +`LabelsDensity` property, this property is a factor that determines the distance between labels; Where 0 is the most dense, +any value greater than 0 will make the labels to be more separated, values less than 0 will make the labels to overlap +(labels rotation could prevent overlapping). Default value is 0.85. + +![image]({{ assets_url }}/docs/_assets/labelsdensity.gif) + ## Inverted property Normally both `X` and `Y` axes scale according to the Cartesian coordinate system you can invert the direction of the axes diff --git a/docs/cartesianChart/columnseries.md b/docs/cartesianChart/columnseries.md index a0788e91b..91419cacc 100644 --- a/docs/cartesianChart/columnseries.md +++ b/docs/cartesianChart/columnseries.md @@ -118,40 +118,25 @@ Finally we could aso set the padding to `0`. { Values = new [] { 4, 4, 7, 2, 8 }, MaxBarWidth = double.MaxValue, - GroupPadding = 0 // mark + Padding = 0 // mark } }; -## GroupPadding property +## Padding property -Defines the distance between every group of columns in the plot, a group of columns is all the column that share the same -secondary value coordinate, in the following image there are 5 groups of columns, the first one the columns that share the -`0` coordinate, the second one shares the `1`, the third group shares the `2` coordinate, the forth group shares the `3` coordinate, -finally the fifth group shares the `4` coordinate. - -:::info -To highlight this feature the following code uses the ColumnSeries class, but it works the same for the StackedColumnSeries -notice the sample above is using the GroupPadding property also. -::: - -![image]({{ assets_url }}/docs/_assets/columngp.png) +Gets or sets the padding for each bar in the series.
Series = new ISeries[]
 {
     new ColumnSeries<int>
     {
         Values = new [] { 4, 4, 7, 2, 8 },
-        GroupPadding = 50 // mark
+        adding = 5 // mark
     },
     new ColumnSeries<int>
     {
         Values = new [] { 2, 3,1, 4, 6 },
-        GroupPadding = 50 // mark
-    },
-    new ColumnSeries<int>
-    {
-        Values = new [] { 6, 3, 6, 9, 4 },
-        GroupPadding = 50 // mark
+        Padding = 5 // mark
     }
 };
diff --git a/docs/cartesianChart/overview.md b/docs/cartesianChart/overview.md index c064f93c0..efbd4b5c0 100644 --- a/docs/cartesianChart/overview.md +++ b/docs/cartesianChart/overview.md @@ -96,63 +96,63 @@ cover the most common scenarios. There are multiple series available in the library, you can add one or mix them all in the same chart, every series has unique properties, any image bellow is a link to an article explaining more about them. - +
series
Line series
- +
series
Column series
- +
series
Scatter series
- +
series
Step line series
- +
series
Heat series
- +
series
Candle sticks series
- +
series
Stacked line series
- +
series
Stacked column series
- +
series
Stacked step line series
diff --git a/docs/cartesianChart/stackedcolumnseries.md b/docs/cartesianChart/stackedcolumnseries.md index 7572e9595..606382ebe 100644 --- a/docs/cartesianChart/stackedcolumnseries.md +++ b/docs/cartesianChart/stackedcolumnseries.md @@ -146,39 +146,25 @@ Finally we could aso set the padding to `0`. { Values = new [] { 4, 4, 7, 2, 8 }, MaxBarWidth = double.MaxValue, - GroupPadding = 0 // mark + Padding = 0 // mark } }; -## GroupPadding property +## Padding property -:::info -this section uses the `ColumnSeries` class, but it works the same for the `StackedColumnSeries`. -::: - -Defines the distance between every group of columns in the plot, a group of columns is all the column that share the same -secondary value coordinate, in the following image there are 5 groups of columns, the first one the columns that share the -`0` coordinate, the second one shares the `1`, the third group shares the `2` coordinate, the forth group shares the `3` coordinate, -finally the fifth group shares the `4` coordinate. - -![image]({{ assets_url }}/docs/_assets/columngp.png) +Gets or sets the padding for each bar in the series.
Series = new ISeries[]
 {
-    new ColumnSeries<int>
+    new StackedColumnSeries<int>
     {
         Values = new [] { 4, 4, 7, 2, 8 },
-        GroupPadding = 50 // mark
+        adding = 5 // mark
     },
-    new ColumnSeries<int>
+    new StackedColumnSeries<int>
     {
         Values = new [] { 2, 3,1, 4, 6 },
-        GroupPadding = 50 // mark
-    },
-    new ColumnSeries<int>
-    {
-        Values = new [] { 6, 3, 6, 9, 4 },
-        GroupPadding = 50 // mark
+        Padding = 5 // mark
     }
 };
diff --git a/docs/cartesianChart/tooltips.md b/docs/cartesianChart/tooltips.md index f50f2c803..05f199b2d 100644 --- a/docs/cartesianChart/tooltips.md +++ b/docs/cartesianChart/tooltips.md @@ -141,67 +141,124 @@ the properly [unit width]({{ website_url }}/docs/{{ platform }}/{{ version }}/Ca cartesianChart1.TooltipFindingStrategy = LiveChartsCore.Measure.TooltipFindingStrategy.CompareOnlyX; {{~ end ~}} -## Tooltip point text +## Tooltip text -You can define the text the tooltip will display for a given point, using the `Series.TooltipLabelFormatter` property, this -property is of type `Func` this means that is is a function, that takes a point as parameter -and returns a string, the point will be injected by LiveCharts in this function to get a string out of it when it +You can define the text the tooltip will display for a given point, using the +`YToolTipLabelFormatter`, `XToolTipLabelFormatter` or `ToolTipLabelFormatter` properties, these +properties are of type `Func` it means that both are a function, that takes a point as parameter +and return a string, the point will be injected by LiveCharts in this function to get a string out of it when it requires to build the text for a point in a tooltip, the injected point will be different as the user moves the pointer over the user interface. -By default the library already defines a default `TooltipLabelFormatter` for every series, all the series have a different -formatter, but generally the default value uses the `Series.Name` and the `ChartPoint.PrimaryValue` properties, the following +By default the library already defines a default formatter for every series, all the series have a different +formatters, but generally the default value uses the `Series.Name` and the `ChartPoint.Coordinate.PrimaryValue` properties, the following code snippet illustrates how to build a custom tooltip formatter. -
new LineSeries<double>
-{
-    Name = "Sales",
-    Values = new ObservableCollection<double> { 200, 558, 458 },
-    // for the following formatter
-    // when the pointer is over the first point (200), the tooltip will display:
-    // Sales: 200
-    TooltipLabelFormatter =
-        (chartPoint) => $"{chartPoint.Context.Series.Name}: {chartPoint.PrimaryValue}"
-},
-
-new ColumnSeries<double>
-{
-    Name = "Sales 2",
-    Values = new ObservableCollection<double> { 250, 350, 240 },
-    // now it will use a currency formatter to display the primary value
-    // result: Sales 2: $200.00
-    TooltipLabelFormatter =
-        (chartPoint) => $"{chartPoint.Context.Series.Name}: {chartPoint.PrimaryValue:C2}"
-},
-
-new StepLineSeries<ObservablePoint>
-{
-    Name = "Average",
-    Values = new ObservableCollection<ObservablePoint>
+Lets take the example of the next series:"
+
+
public ISeries[] Series { get; set; } = [
+    new LineSeries<double>
+    {
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        Fill = null,
+        GeometrySize = 20,
+    },
+    new LineSeries<int, StarGeometry>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        Fill = null,
+        GeometrySize = 20
+    }
+];
+ +By default the tooltip will be: + +![tooltip]({{ assets_url }}/docs/assets/tooltip-format1.png) + +We can add format to the tooltip: + +
public ISeries[] Series { get; set; } = [
+    new LineSeries<double>
     {
-        new ObservablePoint(10, 5),
-        new ObservablePoint(5, 8)
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        Fill = null,
+        GeometrySize = 20,
+        YToolTipLabelFormatter = point => point.Model.ToString("N2") // mark
     },
-    // We can also display both coordinates (X and Y in a cartesian coordinate system)
-    // result: Average: 10, 5
-    TooltipLabelFormatter =
-        (chartPoint) => $"{chartPoint.Context.Series.Name}: {chartPoint.SecondaryValue}, {chartPoint.PrimaryValue}"
-},
+    new LineSeries<int, StarGeometry>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        Fill = null,
+        GeometrySize = 20,
+        YToolTipLabelFormatter = point => point.Model.ToString("N2") // mark
+    }
+];
+ +![tooltip]({{ assets_url }}/docs/assets/tooltip-format2.png) + +We used the Model property of the point, the Model property is just the item in the Values +collection, for example in the next case, the Model property is of type `City`. + +
public ISeries[] Series { get; set; } = [
+    new LineSeries<City>
+    {
+        Values = [new() { Population = 4 }, new() { Population = 2}],
+        YToolTipLabelFormatter = point => point.Model.Population.ToString("N2") // mark
+    }
+];
+
+// ...
 
-new ColumnSeries<ObservablePoint>
+public class City
 {
-    Values = new ObservableCollection<double> { 250, 350, 240 },
-    // or anything...
-    // result: Sales at this moment: $200.00
-    TooltipLabelFormatter =
-        (chartPoint) => $"Sales at this moment: {chartPoint.PrimaryValue:C2}"
+    public double Population { get; set; }
 }
+We can also show a label for the `X` coordinate, the default tooltip uses the X label as the header in the tooltip. + +
new LineSeries<double>
+{
+    Values = [2, 1, 3, 5, 3, 4, 6],
+    Fill = null,
+    GeometrySize = 20,
+    XToolTipLabelFormatter = point => point.Index.ToString(), // mark
+    YToolTipLabelFormatter = point => point.Model.ToString("C2")
+};
+ +![tooltip]({{ assets_url }}/docs/assets/tooltip-format3.png) + +When the series is "Stacked" (`PieSeries`, `StackedColumn` or `StackedRow`) we can find information about the stacked data +in the `StackedValue` property, for example: + + +
public ISeries[] Series { get; set; } = [
+    new StackedColumnSeries<double>
+    {
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        YToolTipLabelFormatter =
+            point => $"{point.Model} / {point.StackedValue!.Total} ({point.StackedValue.Share:P2})"
+    },
+    new StackedColumnSeries<int>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        YToolTipLabelFormatter =
+            point => $"{point.Model} / {point.StackedValue!.Total} ({point.StackedValue.Share:P2})"
+    }
+];
+ +Will result in: + +![tooltip]({{ assets_url }}/docs/assets/tooltip-format4.png) + +:::tip +The PieSeries class uses the `ToolTipLabelFormatter` property to configure the text inside the tooltip. +::: + # Customize default tooltips You can quickly change the position, the font, the text size or the background color: -## View +#### View {{~ if xaml ~}} {{~ render_params_file_as_code this "~/../samples/$PlatformSamplesFolder/Axes/NamedLabels/$PlatformViewFile" ~}} @@ -219,7 +276,7 @@ You can quickly change the position, the font, the text size or the background c {{~ render_params_file_as_code this "~/../samples/BlazorSample/Pages/Axes/NamedLabels.razor" ~}} {{~ end ~}} -## View model +#### View model ```c# [ObservableObject] @@ -249,11 +306,19 @@ You can also create your own tooltip, the recommended way is to use the LiveChar use anything as tooltip as soon as it implements the `IChartTooltip` interface. In the following example we build a custom control to render tooltips in out charts using the LiveCharts API. -## CustomTooltip.cs +:::tip +The next tooltip is drawn by the library, LiveCharts can only draw inside the control bounds, in some cases it could +cause issues like [#912](https://github.com/beto-rodriguez/LiveCharts2/issues/912). + +Alternatively, you can build your own Tooltips and use the power of your UI framework, +see [#1558](https://github.com/beto-rodriguez/LiveCharts2/issues/1558) for more info. +::: + +#### CustomTooltip.cs {{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs" ~}} -## View +#### View {{~ render_params_file_as_code this "~/../samples/$PlatformSamplesFolder/General/TemplatedTooltips/$PlatformViewFile" ~}} diff --git a/docs/overview/1.2.install.md b/docs/overview/1.2.install.md index cfe356661..bd9404038 100644 --- a/docs/overview/1.2.install.md +++ b/docs/overview/1.2.install.md @@ -16,8 +16,11 @@ Open visual studio 2022, select "Create a new project", then select the WPF Appl

-Name the project and the solution WpfSample, and select .NET 6.0 as the framework, if the framework is not available for you, you can also use -.NET 5.0, .NET core 3.1 or .NET 4.6.2 or greater. +Name the project and the solution WpfSample, select .NET 8.0 as the target framework. + +:::tip +LiveCharts is also compatible with older versions of .NET even with 4.6.2. +::: ## Install from NuGet @@ -32,22 +35,19 @@ After the package is installed add a new class to your project as follows:
using LiveChartsCore;
 using LiveChartsCore.SkiaSharpView;
+using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
 
-namespace WpfSample
+namespace WpfSample;
+
+public class ViewModel
 {
-    public class ViewModel
-    {
-        public ISeries[] Series { get; set; } 
-            = new ISeries[]
-            {
-                new LineSeries<double>
-                {
-                    Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
-                    Fill = null
-                }
-            };
-    }
-}
+ public ISeries[] Series { get; set; } = [ + new ColumnSeries<int>(3, 4, 2), + new ColumnSeries<int>(4, 2, 6), + new ColumnSeries<double, DiamondGeometry>(4, 3, 4) + ]; +} +
## Add the chart control to the UI @@ -74,14 +74,21 @@ then add a `CartesianChart` control and bind the `Series` property: And that's it, start your application and you will see the chart in your main window. +

+ +

+ {{~ end ~}} {{~ if avalonia ~}} -Create a new Avalonia project and name the project and the solution AvaloniaSample, and select .NET 6.0 as the framework, if the framework is not -available for you, you can also use .NET 5.0, .NET core 3.1 or .NET 4.6.2 or greater, if you need help to get started with Avalonia please see +Create a new Avalonia project and name the project and the solution AvaloniaSample Name the project and the solution WpfSample, select .NET 8.0 as the target framework. If you need help to get started with Avalonia please see the [Avalonia docs](https://github.com/AvaloniaUI/Avalonia#-getting-started). +:::tip +LiveCharts is also compatible with older versions of .NET even with 4.6.2. +::: + ## Install from NuGet You can [get LiveCharts from NuGet](https://www.nuget.org/packages/LiveChartsCore.SkiaSharpView.Avalonia). If you need more help to @@ -95,22 +102,19 @@ After the package is installed add a new class to your project as follows:
using LiveChartsCore;
 using LiveChartsCore.SkiaSharpView;
+using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
+
+namespace AvaloniaSample;
 
-namespace AvaloniaSample
+public class ViewModel
 {
-    public class ViewModel
-    {
-        public ISeries[] Series { get; set; } 
-            = new ISeries[]
-            {
-                new LineSeries<double>
-                {
-                    Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
-                    Fill = null
-                }
-            };
-    }
-}
+ public ISeries[] Series { get; set; } = [ + new ColumnSeries<int>(3, 4, 2), + new ColumnSeries<int>(4, 2, 6), + new ColumnSeries<double, DiamondGeometry>(4, 3, 4) + ]; +} + ## Add the chart control to the UI @@ -137,6 +141,10 @@ then add a `CartesianChart` control and bind the `Series` property: And that's it, start your application and you will see the chart in your main window. +

+ +

+ {{~ end ~}} {{~ if winforms ~}} @@ -147,8 +155,11 @@ Open visual studio 2022, select "Create a new project", then select the Windows

-Name the project and the solution WinFormsSample, and select .NET 6.0 as the framework, if the framework is not available for you, you can also use -.NET 5.0, .NET core 3.1 or .NET 4.6.2 or greater. +Name the project and the solution WinFormsSample, select .NET 8.0 as the target framework. + +:::tip +LiveCharts is also compatible with older versions of .NET even with 4.6.2. +::: ## Install from NuGet @@ -419,7 +430,7 @@ Start the project for the rest of the platforms, the chart is ready to run every {{~ if winui ~}} -Open visual studio 2022, select "Create a new project", then select the Blank App, Packed with WAP (WinUI 3 In Desktop) template. +Open visual studio 2022, select "Create a new project", then select the "Blank App, Packed (WinUI 3 In Desktop)" template.

@@ -440,21 +451,17 @@ After the package is installed add a new class to your project as follows:

using LiveChartsCore;
 using LiveChartsCore.SkiaSharpView;
+using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
 
-namespace WinUISample
+namespace WinUISample;
+
+public class ViewModel
 {
-    public class ViewModel
-    {
-        public ISeries[] Series { get; set; } 
-            = new ISeries[]
-            {
-                new LineSeries<double>
-                {
-                    Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
-                    Fill = null
-                }
-            };
-    }
+    public ISeries[] Series { get; set; } = [
+        new ColumnSeries<int>(3, 4, 2),
+        new ColumnSeries<int>(4, 2, 6),
+        new ColumnSeries<double, DiamondGeometry>(4, 3, 4)
+    ];
 }
## Add the chart control to the UI @@ -483,6 +490,10 @@ then add a `CartesianChart` control and bind the `Series` property: And that's it, start your application and you will see the chart in your main window. +

+ +

+ {{~ end ~}} {{~ if blazor ~}} @@ -565,7 +576,7 @@ namespace MauiApp { var builder = MauiApp.CreateBuilder(); builder - .UseSkiaSharp(true) // mark + .UseSkiaSharp() // mark .UseMauiApp() .ConfigureFonts(fonts => { @@ -583,21 +594,19 @@ Now let's add a simple chart, add a new class to your project as follows:
using LiveChartsCore;
 using LiveChartsCore.SkiaSharpView;
+using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
 
 namespace MauiSample;
 
 public class ViewModel
 {
-    public ISeries[] Series { get; set; } 
-        = new ISeries[]
-        {
-            new LineSeries<double>
-            {
-                Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
-                Fill = null
-            }
-        };
-}
+ public ISeries[] Series { get; set; } = [ + new ColumnSeries<int>(3, 4, 2), + new ColumnSeries<int>(4, 2, 6), + new ColumnSeries<double, DiamondGeometry>(4, 3, 4) + ]; +} + ## Add the chart control to the UI @@ -625,8 +634,19 @@ then add a `CartesianChart` control and bind the `Series` property. And that's it, start your application and you will see the chart. +

+ +

+ {{~ end ~}} +:::info +If the chart is not showing, it is most likely that the layout where you placed the chart is hiding the control. +LiveCharts controls do not have any size constraints, a quick fix is to explicitly set the size of the control +(Width and Height), these related issues might help you [#1483](https://github.com/beto-rodriguez/LiveCharts2/issues/1483), +[#1581](https://github.com/beto-rodriguez/LiveCharts2/issues/1581). +::: + ## Configure themes, fonts or mappers (Optional) Optionally you could configure LiveCharts to add a theme, register a global font, enable `right to left` tooltips diff --git a/docs/overview/1.6.paint tasks.md b/docs/overview/1.6.paint tasks.md index e01b8d8a8..e84fa3d97 100644 --- a/docs/overview/1.6.paint tasks.md +++ b/docs/overview/1.6.paint tasks.md @@ -134,8 +134,7 @@ Series = new ISeries[] Values = new []{ 7 }, Stroke = null, Fill = new RadialGradientPaint(colors), - Pushout = 10, - MaxOuterRadius = 0.9 + Pushout = 10 }, new PieSeries<int> { diff --git a/docs/piechart/gauges.md b/docs/piechart/gauges.md index 1ab74dc6c..439ee517a 100644 --- a/docs/piechart/gauges.md +++ b/docs/piechart/gauges.md @@ -4,219 +4,19 @@ ## Gauges -You can also create gauges with the `PieChart` control, the library provides the `GaugeBuilder` class, -it is a helper class that build a collection of `PieSeries` based on the properties -we specify, take a look at the following sample. +You can also create gauges with the `PieChart` control, the library provides the `GaugeGenerator` class, +it is a helper class that builds a collection of `PieSeries` based on the properties +we specify, this documentation contains multiple gauges samples, +[here you can find the basic gauge sample](https://livecharts.dev/docs/{{ platform }}/{{ version }}/samples.pies.gauge1). -{{~ if xaml || blazor ~}} -
GaugeTotal = 100; // 100 is the max value for this gauge.
-Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} +The `GaugeGenerator.BuildSolidGauge()` function, takes one or multiple `GaugeItem` instances as parameters, +a `GaugeItem` instance represents an element in our gauge, the constructor of the `GaugeItem` class takes 2 arguments: -{{~ if xaml ~}} -
<lvc:PieChart
-    Series="{Binding Series}"
-    Total="{Binding GaugeTotal}">
-</lvc:PieChart>
-{{~ end ~}} +- `value`: the gauge value of type `double`. +- `builder`: a delegate where we can configure the assigned series to the `value`, we can here set the color, the labels size and customize every property as a regular [pie series](https://livecharts.dev/docs/{{ platform }}/{{ version }}/PieChart.Pie%20series). -{{~ if blazor ~}} -
<PieChart
-    Series="Series"
-    Total="GaugeTotal">
-</PieChart>
-{{~ end ~}} +You can find an example that uses both parameters in the [slim gauge sample](https://livecharts.dev/docs/{{ platform }}/{{ version }}/samples.pies.gauge4). -{{~ if winforms ~}} -
pieChart1.GaugeTotal = 100; // 100 is the max value for this gauge.
-pieChart1.Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} - -![image]({{ assets_url }}/docs/_assets/basicgauge.png) - -## InitialRotation property - -You could also use the `PieChart.InitialRotation` property to customize the angle where the gauge starts. - -{{~ if xaml || blazor ~}} -
InitialRotation = -90; // -90 degrees for the starting angle // mark
-GaugeTotal = 100;
-Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} - -{{~ if xaml ~}} -
<lvc:PieChart
-    Series="{Binding Series}"
-    Total="{Binding GaugeTotal}"
-    InitialRotation="{Binding InitialRotation}"> <!-- mark -->
-</lvc:PieChart>
-{{~ end ~}} - -{{~ if blazor ~}} -
<PieChart
-    Series="Series"
-    Total="GaugeTotal"
-    InitialRotation="InitialRotation"> <!-- mark -->
-</PieChart>
-{{~ end ~}} - -{{~ if winforms ~}} -
pieChart1.InitialRotation = -90; // mark
-pieChart1.GaugeTotal = 100;
-pieChart1.Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} - -![image]({{ assets_url }}/docs/_assets/basicgauge-90.png) - -## OffsetRadius property - -Now trying the `GaugeBuilder.OffsetRadius`, this property defines an offset in pixels from the `InnerRadius` of the -pie slice shape to the actual start of the shape: - -{{~ if xaml || blazor ~}} -
InitialRotation = -90;
-GaugeTotal = 100;
-Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .WithOffsetRadius(10) // mark
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} - -{{~ if winforms ~}} -
pieChart1.InitialRotation = -90;
-pieChart1.GaugeTotal = 100;
-pieChart1.Series = new GaugeBuilder()
-    .WithLabelsSize(50)
-    .WithInnerRadius(50)
-    .WithBackgroundInnerRadius(50)
-    .WithOffsetRadius(10) // mark
-    .AddValue(30)
-    .BuildSeries();
-{{~ end ~}} - -![image]({{ assets_url }}/docs/_assets/basicgaugeor.png) - -Notice that there is a similar property the `GaugeBuilder.BackgroundOffsetRadius` will do the same effect -but in the background slice (gray one). - -## Multiple series - -You can also compare multiple series in the same gauge, the following sample combines adds 2 more series and -uses the `LabelFormatter` property to customize the labels. - -{{~ if xaml || blazor ~}} -
InitialRotation = 45;
-GaugeTotal = 100;
-Series = new GaugeBuilder()
-    .WithLabelsPosition(PolarLabelsPosition.Start)
-    .WithLabelFormatter(point => point.PrimaryValue + " " + point.Context.Series.Name)
-    .WithLabelsSize(20)
-    .WithInnerRadius(20)
-    .WithOffsetRadius(8)
-    .WithBackgroundInnerRadius(20)
-    .AddValue(30, "Vannesa") // mark
-    .AddValue(50, "Charles") // mark
-    .AddValue(90, "Ana")  // mark
-    .BuildSeries();
-{{~ end ~}} - -{{~ if winforms ~}} -
pieChart1.InitialRotation = 45;
-pieChart1.GaugeTotal = 100;
-pieChart1.Series = new GaugeBuilder()
-    .WithLabelsPosition(PolarLabelsPosition.Start)
-    .WithLabelFormatter(point => point.PrimaryValue + " " + point.Context.Series.Name)
-    .WithLabelsSize(20)
-    .WithInnerRadius(20)
-    .WithOffsetRadius(8)
-    .WithBackgroundInnerRadius(20)
-    .AddValue(30, "Vannesa") // mark
-    .AddValue(50, "Charles") // mark
-    .AddValue(90, "Ana")  // mark
-    .BuildSeries();
-{{~ end ~}} - -![image]({{ assets_url }}/docs/_assets/basicgaugemultiple.png) - -## MaxAngle property - -The max angle property defines the maximum angle the gauge can take, the range goes from 0 to 360 degrees (full circle), -by default the value is 360, we can avoid the overlap of the green series in the previous sample if we reserve a space for -the labels, in this case we will set the `MaxAngle` to 270 degrees, this way we will have space for the labels to render -in the last 90 degrees of our circumference. - -{{~ if xaml || blazor ~}} -
InitialRotation = 45;
-GaugeTotal = 100;
-Series = new GaugeBuilder()
-    .WithLabelsPosition(PolarLabelsPosition.Start)
-    .WithLabelFormatter(point => point.PrimaryValue + " " + point.Context.Series.Name)
-    .WithLabelsSize(20)
-    .WithInnerRadius(20)
-    .WithOffsetRadius(8)
-    .WithBackgroundInnerRadius(20)
-    .AddValue(30, "Vannesa")
-    .AddValue(50, "Charles")
-    .AddValue(90, "Ana")
-    .BuildSeries();
-{{~ end ~}} - -{{~ if xaml ~}} -
<lvc:PieChart
-    Series="{Binding Series}"
-    Total="{Binding GaugeTotal}"
-    InitialRotation="{Binding InitialRotation}"
-    MaxAngle="270"> <!-- mark -->
-</lvc:PieChart>
-{{~ end ~}} - -{{~ if blazor ~}} -
<PieChart
-    Series="Series"
-    Total="GaugeTotal"
-    InitialRotation="InitialRotation"
-    MaxAngle="270"> <!-- mark -->
-</PieChart>
-{{~ end ~}} - -{{~ if winforms ~}} -
pieChart1.MaxAngle = 270; // mark
-pieChart1.InitialRotation = 45;
-pieChart1.GaugeTotal = 100;
-pieChart1.Series = new GaugeBuilder()
-    .WithLabelsPosition(PolarLabelsPosition.Start)
-    .WithLabelFormatter(point => point.PrimaryValue + " " + point.Context.Series.Name)
-    .WithLabelsSize(20)
-    .WithInnerRadius(20)
-    .WithOffsetRadius(8)
-    .WithBackgroundInnerRadius(20)
-    .AddValue(30, "Vannesa")
-    .AddValue(50, "Charles")
-    .AddValue(90, "Ana")
-    .BuildSeries();
-{{~ end ~}} - -![image]({{ assets_url }}/docs/_assets/basicgaugemultiple270.png) +Finally, there is a special value to customize the background series of a gauge, using the `GaugeItem.Background` as the `value` in the +`GaugeItem` class, will create a series behind our gauge values that will behave as the background in our plot, +[here is an example](https://livecharts.dev/docs/{{ platform }}/{{ version }}/samples.pies.gauge2) that uses this feature. diff --git a/docs/samples/general/customTooltips/template.md b/docs/samples/general/customTooltips/template.md index e128f9aeb..c62aeaf1c 100644 --- a/docs/samples/general/customTooltips/template.md +++ b/docs/samples/general/customTooltips/template.md @@ -1,11 +1,13 @@ # Customize default tooltips +:::tip The next article is a quick guide on how to customize the default tooltip,if you want to learn more you can read the full article:
Go to the full tooltips article +::: You can quickly change the position, the font, the text size or the background color: @@ -51,12 +53,133 @@ public partial class ViewModel ![image]({{ assets_url }}/docs/samples/general/customTooltips/styling-tooltips.png) -## Tooltip control from scratch +# Customize tooltip format + +You can define the text the tooltip will display for a given point, using the +`YToolTipLabelFormatter`, `XToolTipLabelFormatter` or `ToolTipLabelFormatter` properties, these +properties are of type `Func` it means that both are a function, that takes a point as parameter +and return a string, the point will be injected by LiveCharts in this function to get a string out of it when it +requires to build the text for a point in a tooltip, the injected point will be different as the user moves the pointer over the +user interface. + +By default the library already defines a default formatter for every series, all the series have a different +formatters, but generally the default value uses the `Series.Name` and the `ChartPoint.Coordinate.PrimaryValue` properties, the following +code snippet illustrates how to build a custom tooltip formatter. + +Lets take the example of the next series:" + +
public ISeries[] Series { get; set; } = [
+    new LineSeries<double>
+    {
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        Fill = null,
+        GeometrySize = 20,
+    },
+    new LineSeries<int, StarGeometry>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        Fill = null,
+        GeometrySize = 20
+    }
+];
+ +By default the tooltip will be: + +![tooltip]({{ assets_url }}/docs/assets/tooltip-format1.png) + +We can add format to the tooltip: + +
public ISeries[] Series { get; set; } = [
+    new LineSeries<double>
+    {
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        Fill = null,
+        GeometrySize = 20,
+        YToolTipLabelFormatter = point => point.Model.ToString("N2") // mark
+    },
+    new LineSeries<int, StarGeometry>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        Fill = null,
+        GeometrySize = 20,
+        YToolTipLabelFormatter = point => point.Model.ToString("N2") // mark
+    }
+];
+ +![tooltip]({{ assets_url }}/docs/assets/tooltip-format2.png) + +We used the Model property of the point, the Model property is just the item in the Values +collection, for example in the next case, the Model property is of type `City`. + +
public ISeries[] Series { get; set; } = [
+    new LineSeries<City>
+    {
+        Values = [new() { Population = 4 }, new() { Population = 2}],
+        YToolTipLabelFormatter = point => point.Model.Population.ToString("N2") // mark
+    }
+];
+
+// ...
+
+public class City
+{
+    public double Population { get; set; }
+}
+ +We can also show a label for the `X` coordinate, the default tooltip uses the X label as the header in the tooltip. + +
new LineSeries<double>
+{
+    Values = [2, 1, 3, 5, 3, 4, 6],
+    Fill = null,
+    GeometrySize = 20,
+    XToolTipLabelFormatter = point => point.Index.ToString(), // mark
+    YToolTipLabelFormatter = point => point.Model.ToString("C2")
+};
+ +![tooltip]({{ assets_url }}/docs/assets/tooltip-format3.png) + +When the series is "Stacked" (`PieSeries`, `StackedColumn` or `StackedRow`) we can find information about the stacked data +in the `StackedValue` property, for example: + + +
public ISeries[] Series { get; set; } = [
+    new StackedColumnSeries<double>
+    {
+        Values = [2, 1, 3, 5, 3, 4, 6],
+        YToolTipLabelFormatter =
+            point => $"{point.Model} / {point.StackedValue!.Total} ({point.StackedValue.Share:P2})"
+    },
+    new StackedColumnSeries<int>
+    {
+        Values = [4, 2, 5, 2, 4, 5, 3],
+        YToolTipLabelFormatter =
+            point => $"{point.Model} / {point.StackedValue!.Total} ({point.StackedValue.Share:P2})"
+    }
+];
+ +Will result in: + +![tooltip]({{ assets_url }}/docs/assets/tooltip-format4.png) + +:::tip +The PieSeries class uses the `ToolTipLabelFormatter` property to configure the text inside the tooltip. +::: + +# Tooltip control from scratch You can also create your own tooltip, the recommended way is to use the LiveCharts API (example bellow) but you can use anything as tooltip as soon as it implements the `IChartTooltip` interface. AT the following example we build a custom control to render tooltips in our charts using the LiveCharts API. +:::tip +The next tooltip is drawn by the library, LiveCharts can only draw inside the control bounds, in some cases it could +cause issues like [#912](https://github.com/beto-rodriguez/LiveCharts2/issues/912). + +Alternatively, you can build your own Tooltips and use the power of your UI framework, +see [#1558](https://github.com/beto-rodriguez/LiveCharts2/issues/1558) for more info. +::: + ## CustomTooltip.cs {{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs" ~}} diff --git a/docs/samples/general/multiThreading/template.md b/docs/samples/general/multiThreading/template.md index b3eb13561..70b859112 100644 --- a/docs/samples/general/multiThreading/template.md +++ b/docs/samples/general/multiThreading/template.md @@ -5,7 +5,7 @@ could cause a `InvalidOperationException (Collection Was Modified)` and some oth changing on multiple threads so it can handle it and prevent [concurrency hazards](https://learn.microsoft.com/en-us/archive/msdn-magazine/2008/october/concurrency-hazards-solving-problems-in-your-multithreaded-code). -There are 2 alternatives you can follow to prevent this issue, 1. use the [lock](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock) keyword to wrap any change in your data, 2. Invoke the changes on the UI tread. +There are 2 alternatives you can follow to prevent this issue, 1. use the [lock](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock) keyword to wrap any change in your data, 2. Invoke the changes on the UI thread.
sample image @@ -47,7 +47,7 @@ Notice that we also set the chart `SyncContext` property so the chart knows our ## Invoke the changes on the UI thread (Alternative 2) You can also force the change to happen on the same thread where the chart is measured, this will prevent concurrency hazards because -everything is happening on the same tread, but you must consider that now the UI tread is doing more operations. +everything is happening on the same thread, but you must consider that now the UI thread is doing more operations. ## View model diff --git a/docs/samples/lines/basic/result.gif b/docs/samples/lines/basic/result.gif index c166e7eee..530bb0998 100644 Binary files a/docs/samples/lines/basic/result.gif and b/docs/samples/lines/basic/result.gif differ diff --git a/docs/samples/lines/basic/result.png b/docs/samples/lines/basic/result.png index 1e2b16973..b5c4446ed 100644 Binary files a/docs/samples/lines/basic/result.png and b/docs/samples/lines/basic/result.png differ diff --git a/docs/samples/lines/xy/template.md b/docs/samples/lines/xy/template.md index 9faab4bbc..ca97aa511 100644 --- a/docs/samples/lines/xy/template.md +++ b/docs/samples/lines/xy/template.md @@ -1 +1,38 @@ -{{ render this "~/shared/genericSampleSimple.md" }} \ No newline at end of file +# {{ name | to_title_case }} + +
+ sample image +
+ +When you need to specify both, X and Y coordinates, you can use the +[ObservablePoint](https://livecharts.dev/api/{{ version }}/LiveChartsCore.Defaults.ObservablePoint) class, +in other examples in this repository you will notice that the library can also plot primitive types such as +`int` or `double`, the library (usually) uses the index of the element in the array as the `X` coordinate +and the value as the `Y` coordinate, so even we are passing an array of primitives, the library is mapping +that object to and `(X, Y)` point, the library can build charts from any object, but we much teach LiveCharts +how to handle that object, if you want to learn more, please read the +[Mappers article](https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers). + +## View Model + +``` +{{ full_name | get_vm_from_docs }} +``` + +{{~ if xaml ~}} +## XAML +{{~ end ~}} + +{{~ if winforms ~}} +## Code Behind +{{~ end ~}} + +{{~ if blazor~}} +## HTML +{{~ end~}} + +``` +{{ full_name | get_view_from_docs }} +``` + +{{ render this "~/shared/relatedTo.md" }} diff --git a/docs/shared/datalabels.md b/docs/shared/datalabels.md index cb2cf2f94..47e31a6f4 100644 --- a/docs/shared/datalabels.md +++ b/docs/shared/datalabels.md @@ -14,7 +14,7 @@ following sample: // that takes the current point as parameter // and returns a string. // in this case we returned the PrimaryValue property as currency - DataLabelsFormatter = (point) => point.PrimaryValue.ToString("C2"), + DataLabelsFormatter = (point) => point.Coordinate.PrimaryValue.ToString("C2"), Values = new ObservableCollection<double> { 2, 1, 3, 5, 3, 4, 6 }, Fill = null } diff --git a/docs/shared/genericSampleHeader.md b/docs/shared/genericSampleHeader.md index 9274f3861..070b4a7cf 100644 --- a/docs/shared/genericSampleHeader.md +++ b/docs/shared/genericSampleHeader.md @@ -1,20 +1,20 @@ # {{ name | to_title_case }} -:::info +
+ sample image + sample image +
+ +:::tip Hover over the image to see the chart animation ::: {{~ if xaml ~}} :::info -The `[ObservableObject]`, `[ObservableProperty]` and `[RelayCommand]` attributes come from the -[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can read more about it +This sample uses C# 12 features, it also uses features from the +[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can learn more about it [here]({{ website_url }}/docs/{{ platform }}/{{ version }}/About.About%20this%20samples). ::: -{{~ end ~}} - -
- sample image - sample image -
\ No newline at end of file +{{~ end ~}} \ No newline at end of file diff --git a/docs/shared/genericSampleJustGifHeader.md b/docs/shared/genericSampleJustGifHeader.md index 8a3b68470..4c615d6a7 100644 --- a/docs/shared/genericSampleJustGifHeader.md +++ b/docs/shared/genericSampleJustGifHeader.md @@ -3,8 +3,8 @@ {{~ if xaml ~}} :::info -The `[ObservableObject]`, `[ObservableProperty]` and `[RelayCommand]` attributes come from the -[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can read more about it +This sample uses C# 12 features, it also uses features from the +[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can learn more about it [here]({{ website_url }}/docs/{{ platform }}/{{ version }}/About.About%20this%20samples). ::: diff --git a/docs/shared/genericSampleSimpleHeader.md b/docs/shared/genericSampleSimpleHeader.md index 6b01a90a3..8bae911e7 100644 --- a/docs/shared/genericSampleSimpleHeader.md +++ b/docs/shared/genericSampleSimpleHeader.md @@ -3,8 +3,8 @@ {{~ if xaml ~}} :::info -The `[ObservableObject]`, `[ObservableProperty]` and `[RelayCommand]` attributes come from the -[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can read more about it +This sample uses C# 12 features, it also uses features from the +[CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm/) package, you can learn more about it [here]({{ website_url }}/docs/{{ platform }}/{{ version }}/About.About%20this%20samples). ::: diff --git a/docs/shared/polarlabels.md b/docs/shared/polarlabels.md index 50c555453..ac9912bf5 100644 --- a/docs/shared/polarlabels.md +++ b/docs/shared/polarlabels.md @@ -19,7 +19,7 @@ following sample: // for more information about available positions see: // {{ website_url }}/api/{{ version }}/LiveChartsCore.Measure.PolarLabelsPosition DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Middle, - DataLabelsFormatter = point => point.PrimaryValue.ToString("N2") + " elements" + DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString("N2") + " elements" }, new PieSeries<double> { @@ -27,7 +27,7 @@ following sample: DataLabelsPaint = new SolidColorPaint(SKColors.Black), DataLabelsSize = 22, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Middle, - DataLabelsFormatter = point => point.PrimaryValue.ToString("N2") + " elements" + DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString("N2") + " elements" }, new PieSeries<double> { @@ -35,7 +35,7 @@ following sample: DataLabelsPaint = new SolidColorPaint(SKColors.Black), DataLabelsSize = 22, DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Middle, - DataLabelsFormatter = point => point.PrimaryValue.ToString("N2") + " elements" + DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString("N2") + " elements" } }; diff --git a/docs/shared/series.md b/docs/shared/series.md index 60741c278..f0d0ef6be 100644 --- a/docs/shared/series.md +++ b/docs/shared/series.md @@ -91,19 +91,16 @@ var citiesSeries = new {{ name | to_title_case_no_spaces }}<City> new City { Name = "New York", Population = 11 }, new City { Name = "Mexico City", Population = 10 }, }, - Mapping = (city, point) => + Mapping = (city, index) => { - // this function will be called for every city in our data collection - // in this case Tokio, New York and Mexico city - // it takes the city and the point in the chart liveCharts built for the given city - // you must map the coordinates to the point - - // use the Population property as the primary value (normally Y) - point.PrimaryValue = (float)city.Population; - - // use the index of the city in our data collection as the secondary value - // (normally X) - point.SecondaryValue = point.Context.Index; + // this function will be called for each instance in our values array, + // the function takes each instance (city) and the index of the item in the array as parameters + // and must return the coordinate of the city in the plot. + + // in this case, we return the index as the X coordinate + // and the Population as the Y value. + + return new Coordinate(index, city.Population.Value); } }; diff --git a/samples/AvaloniaSample/Lines/CustomPoints/View.axaml b/samples/AvaloniaSample/Lines/CustomPoints/View.axaml new file mode 100644 index 000000000..59a00ac04 --- /dev/null +++ b/samples/AvaloniaSample/Lines/CustomPoints/View.axaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/samples/AvaloniaSample/Lines/CustomPoints/View.axaml.cs b/samples/AvaloniaSample/Lines/CustomPoints/View.axaml.cs new file mode 100644 index 000000000..1abb3a6a6 --- /dev/null +++ b/samples/AvaloniaSample/Lines/CustomPoints/View.axaml.cs @@ -0,0 +1,17 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace AvaloniaSample.Lines.CustomPoints; + +public partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/samples/AvaloniaSample/Pies/Icons/View.axaml b/samples/AvaloniaSample/Pies/Icons/View.axaml new file mode 100644 index 000000000..90405309e --- /dev/null +++ b/samples/AvaloniaSample/Pies/Icons/View.axaml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/samples/AvaloniaSample/Pies/Icons/View.axaml.cs b/samples/AvaloniaSample/Pies/Icons/View.axaml.cs new file mode 100644 index 000000000..fb271c081 --- /dev/null +++ b/samples/AvaloniaSample/Pies/Icons/View.axaml.cs @@ -0,0 +1,17 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace AvaloniaSample.Pies.Icons; + +public partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/samples/BlazorSample/Pages/Hello.razor b/samples/BlazorSample/Pages/Hello.razor index ee6647868..4873d4847 100644 --- a/samples/BlazorSample/Pages/Hello.razor +++ b/samples/BlazorSample/Pages/Hello.razor @@ -7,6 +7,7 @@ @using LiveChartsCore.SkiaSharpView; @using System.Collections.ObjectModel; @using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +@using LiveChartsCore.SkiaSharpView.Extensions @using LiveChartsCore.SkiaSharpView.Painting; @using LiveChartsCore.SkiaSharpView.Painting.Effects; @using LiveChartsCore.SkiaSharpView.VisualElements; @@ -480,7 +481,7 @@ values.Add(new(5));"); var outer = 10; PieChart.Series = new[] { 30, 20, 15, 10, 8, 4 } - .AsLiveChartsPieSeries((value, series) => + .AsPieSeries((value, series) => { series.InnerRadius = 50; series.OuterRadiusOffset = outer; @@ -494,7 +495,7 @@ values.Add(new(5));"); .AsLiveChartsPieSeries((value, series) => { series.InnerRadius = 50; - series.MaxOuterRadius = outer; + series.OuterRadiusOffset = outer; outer = outer - 0.1; });"); @@ -514,23 +515,18 @@ values.Add(new(5));"); var charles = new ObservableValue(50); var ana = new ObservableValue(70); - GaugeChart.Series = new GaugeBuilder() - .WithLabelsSize(20) - .WithLabelsPosition(PolarLabelsPosition.Start) - .WithLabelFormatter(point => $"{point.Coordinate.PrimaryValue} {point.Context.Series.Name}") - .WithInnerRadius(20) - .WithOffsetRadius(8) - .WithBackgroundInnerRadius(20) - - .AddValue(vanesa, "Vanessa") - .AddValue(charles, "Charles") - .AddValue(ana, "Ana") - - .BuildSeries(); + GaugeChart.Series = GaugeGenerator.BuildSolidGauge( + new GaugeItem(50, series => SetStyle("Vanessa", series)), + new GaugeItem(80, series => SetStyle("Charles", series)), + new GaugeItem(95, series => SetStyle("Ana", series)), + new GaugeItem(GaugeItem.Background, series => + { + series.Fill = null; + })); GaugeChart.InitialRotation = 45; GaugeChart.MaxAngle = 270; - GaugeChart.Total = 100; + GaugeChart.MaxValue = 100; await JS.InvokeVoidAsync("hlElements", "Gauges", @@ -560,6 +556,17 @@ values.Add(new(5));"); ana.Value = 70; } + public static void SetStyle(string name, PieSeries series) + { + series.Name = name; + series.DataLabelsSize = 20; + series.DataLabelsPosition = PolarLabelsPosition.End; + series.DataLabelsFormatter = + point => point.Coordinate.PrimaryValue.ToString(); + series.InnerRadius = 20; + series.MaxRadialColumnWidth = 5; + } + public async Task Sample6() { PolarChart.EasingFunction = EasingFunctions.QuadraticOut; diff --git a/samples/BlazorSample/Pages/Lines/CustomPoints.razor b/samples/BlazorSample/Pages/Lines/CustomPoints.razor new file mode 100644 index 000000000..08173e9b9 --- /dev/null +++ b/samples/BlazorSample/Pages/Lines/CustomPoints.razor @@ -0,0 +1,11 @@ +@page "/Lines/CustomPoints" +@using LiveChartsCore.SkiaSharpView.Blazor +@using ViewModelsSamples.Lines.CustomPoints + + + + +@code { + public ViewModel ViewModel { get; set; } = new(); +} diff --git a/samples/BlazorSample/Pages/Pies/Icons.razor b/samples/BlazorSample/Pages/Pies/Icons.razor new file mode 100644 index 000000000..0a5fddaad --- /dev/null +++ b/samples/BlazorSample/Pages/Pies/Icons.razor @@ -0,0 +1,11 @@ +@page "/Pies/Icons" +@using LiveChartsCore.SkiaSharpView.Blazor +@using ViewModelsSamples.Pies.Icons + + + + +@code { + public ViewModel ViewModel { get; set; } = new(); +} diff --git a/samples/ConsoleSample/ConsoleSample/Program.cs b/samples/ConsoleSample/ConsoleSample/Program.cs index 103602a66..d3a1c7e87 100644 --- a/samples/ConsoleSample/ConsoleSample/Program.cs +++ b/samples/ConsoleSample/ConsoleSample/Program.cs @@ -12,11 +12,10 @@ { Width = 900, Height = 600, - Series = new ISeries[] - { - new LineSeries { Values = new int[] { 1, 5, 4, 6 } }, - new ColumnSeries { Values = new int[] { 4, 8, 2, 4 } } - }, + Series = [ + new LineSeries { Values = [1, 5, 4, 6] }, + new ColumnSeries { Values = [4, 8, 2, 4] } + ], Title = new LabelVisual { Text = "Hello LiveCharts", @@ -48,12 +47,11 @@ { Width = 900, Height = 600, - Series = new ISeries[] - { - new PieSeries { Values = new int[] { 10, } }, - new PieSeries { Values = new int[] { 6 } }, - new PieSeries { Values = new int[] { 4 } } - }, + Series = [ + new PieSeries { Values = [10,] }, + new PieSeries { Values = [6] }, + new PieSeries { Values = [4] } + ], LegendPosition = LiveChartsCore.Measure.LegendPosition.Right }; @@ -63,18 +61,16 @@ { Width = 900, Height = 600, - Series = new IGeoSeries[] - { + Series = [ new HeatLandSeries { - Lands = new HeatLand[] - { + Lands = [ new() { Name = "mex", Value = 10 }, new() { Name = "usa", Value = 15 }, new() { Name = "can", Value = 8 } - } + ] } - } + ] }; geoHeatMap.SaveImage("geoHeatMap.png"); diff --git a/samples/EtoFormsSample/Lines/CustomPoints/View.cs b/samples/EtoFormsSample/Lines/CustomPoints/View.cs new file mode 100644 index 000000000..e2ff82227 --- /dev/null +++ b/samples/EtoFormsSample/Lines/CustomPoints/View.cs @@ -0,0 +1,22 @@ +using Eto.Forms; +using LiveChartsCore.SkiaSharpView.Eto; +using ViewModelsSamples.Lines.CustomPoints; + +namespace EtoFormsSample.Lines.CustomPoints; + +public class View : Panel +{ + private readonly CartesianChart cartesianChart; + + public View() + { + var viewModel = new ViewModel(); + + cartesianChart = new CartesianChart + { + Series = viewModel.Series, + }; + + Content = cartesianChart; + } +} diff --git a/samples/EtoFormsSample/Pies/Icons/View.cs b/samples/EtoFormsSample/Pies/Icons/View.cs new file mode 100644 index 000000000..85c27d469 --- /dev/null +++ b/samples/EtoFormsSample/Pies/Icons/View.cs @@ -0,0 +1,22 @@ +using Eto.Forms; +using LiveChartsCore.SkiaSharpView.Eto; +using ViewModelsSamples.Pies.Icons; + +namespace EtoFormsSample.Pies.Icons; + +public class View : Panel +{ + private readonly PieChart pieChart; + + public View() + { + var viewModel = new ViewModel(); + + pieChart = new PieChart + { + Series = viewModel.Series + }; + + Content = pieChart; + } +} diff --git a/samples/IChartEntitySample/Program.cs b/samples/IChartEntitySample/Program.cs index 01afd4e29..13400da40 100644 --- a/samples/IChartEntitySample/Program.cs +++ b/samples/IChartEntitySample/Program.cs @@ -15,15 +15,14 @@ { Width = 900, Height = 600, - Series = new[] - { + Series = [ new LineSeries { Values = samples } - }, - XAxes = new[] { new Axis { Labeler = value => $"{value} seconds" } }, - YAxes = new[] { new Axis { Labeler = value => $"{value} °C" } } + ], + XAxes = [new Axis { Labeler = value => $"{value} seconds" }], + YAxes = [new Axis { Labeler = value => $"{value} °C" }] }; // save the chart. diff --git a/samples/MappersSamples/Program.cs b/samples/MappersSamples/Program.cs index 79f643b4f..8c76c8e50 100644 --- a/samples/MappersSamples/Program.cs +++ b/samples/MappersSamples/Program.cs @@ -19,8 +19,7 @@ { Width = 900, Height = 600, - Series = new[] - { + Series = [ new LineSeries { // we set the X coordinate to the Time property @@ -28,9 +27,9 @@ Mapping = (tempSample, index) => new(tempSample.Time, tempSample.Temperature), Values = samples } - }, - XAxes = new[] { new Axis { Labeler = value => $"{value} seconds" } }, - YAxes = new[] { new Axis { Labeler = value => $"{value} °C" } } + ], + XAxes = [new Axis { Labeler = value => $"{value} seconds" }], + YAxes = [new Axis { Labeler = value => $"{value} °C" }] }; chart.SaveImage("using mappers.png"); @@ -61,8 +60,8 @@ { Width = 900, Height = 600, - Series = new[] - { + Series = + [ new ColumnSeries { // we set the X coordinate to the index of the item in the array @@ -70,16 +69,16 @@ Mapping = (city, index) => new(index, city.Population), Values = cities } - }, - XAxes = new[] - { + ], + XAxes = + [ new Axis { Labels = cities.Select(x => x.Name).ToArray(), LabelsRotation = 90 } - }, - YAxes = new[] { new Axis { Labeler = value => value.ToString("N2") } } + ], + YAxes = [new Axis { Labeler = value => value.ToString("N2") }] }; citiesChart.SaveImage("cities.png"); diff --git a/samples/MauiSample/Lines/CustomPoints/View.xaml b/samples/MauiSample/Lines/CustomPoints/View.xaml new file mode 100644 index 000000000..d026a25db --- /dev/null +++ b/samples/MauiSample/Lines/CustomPoints/View.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/samples/MauiSample/Lines/CustomPoints/View.xaml.cs b/samples/MauiSample/Lines/CustomPoints/View.xaml.cs new file mode 100644 index 000000000..08e853813 --- /dev/null +++ b/samples/MauiSample/Lines/CustomPoints/View.xaml.cs @@ -0,0 +1,10 @@ +namespace MauiSample.Lines.CustomPoints; + +[XamlCompilation(XamlCompilationOptions.Compile)] +public partial class View : ContentPage +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/MauiSample/MauiProgram.cs b/samples/MauiSample/MauiProgram.cs index 77d9f8302..2c17f23ef 100644 --- a/samples/MauiSample/MauiProgram.cs +++ b/samples/MauiSample/MauiProgram.cs @@ -8,7 +8,7 @@ public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); _ = builder - .UseSkiaSharp(true) + .UseSkiaSharp() .UseMauiApp() .ConfigureFonts(fonts => { diff --git a/samples/MauiSample/Pies/Icons/View.xaml b/samples/MauiSample/Pies/Icons/View.xaml new file mode 100644 index 000000000..f25a0aab7 --- /dev/null +++ b/samples/MauiSample/Pies/Icons/View.xaml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/samples/MauiSample/Pies/Icons/View.xaml.cs b/samples/MauiSample/Pies/Icons/View.xaml.cs new file mode 100644 index 000000000..d680e1315 --- /dev/null +++ b/samples/MauiSample/Pies/Icons/View.xaml.cs @@ -0,0 +1,10 @@ +namespace MauiSample.Pies.Icons; + +[XamlCompilation(XamlCompilationOptions.Compile)] +public partial class View : ContentPage +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/QuestPDFSample/Program.cs b/samples/QuestPDFSample/Program.cs index 2a62615fb..3a9ad49c3 100644 --- a/samples/QuestPDFSample/Program.cs +++ b/samples/QuestPDFSample/Program.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Reflection; -using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.SKCharts; using QuestPDF.Fluent; @@ -34,11 +33,10 @@ { Width = (int)size.Width, Height = (int)size.Height, - Series = new ISeries[] - { - new LineSeries { Values = new int[] { 1, 5, 4, 6 } }, - new ColumnSeries { Values = new int[] { 4, 8, 2, 4 } } - } + Series = [ + new LineSeries { Values = [1, 5, 4, 6] }, + new ColumnSeries { Values = [4, 8, 2, 4] } + ] }; cartesianChart.SaveImage(canvas); diff --git a/samples/UnoPlatform_v5/Directory.Packages.props b/samples/UnoPlatform_v5/Directory.Packages.props index a09997cbe..7568d86af 100644 --- a/samples/UnoPlatform_v5/Directory.Packages.props +++ b/samples/UnoPlatform_v5/Directory.Packages.props @@ -1,4 +1,4 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml new file mode 100644 index 000000000..2505b1eab --- /dev/null +++ b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml.cs b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml.cs new file mode 100644 index 000000000..8aa559a3a --- /dev/null +++ b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Lines/CustomPoints/View.xaml.cs @@ -0,0 +1,11 @@ +using Microsoft.UI.Xaml.Controls; + +namespace UnoWinUISample.Lines.CustomPoints; + +public sealed partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Gauge/View.xaml b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Gauge/View.xaml index 7f6eca655..444239570 100644 --- a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Gauge/View.xaml +++ b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Gauge/View.xaml @@ -38,7 +38,7 @@ diff --git a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml new file mode 100644 index 000000000..06129e283 --- /dev/null +++ b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml.cs b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml.cs new file mode 100644 index 000000000..f40206a09 --- /dev/null +++ b/samples/UnoPlatform_v5/UnoPlatform_v5/LiveChartsSamples/Pies/Icons/View.xaml.cs @@ -0,0 +1,11 @@ +using Microsoft.UI.Xaml.Controls; + +namespace UnoWinUISample.Pies.Icons; + +public sealed partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/ViewModelsSamples/Axes/ColorsAndPosition/ViewModel.cs b/samples/ViewModelsSamples/Axes/ColorsAndPosition/ViewModel.cs index 17e0dd40b..644793411 100644 --- a/samples/ViewModelsSamples/Axes/ColorsAndPosition/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/ColorsAndPosition/ViewModel.cs @@ -1,5 +1,4 @@ using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Drawing; @@ -11,24 +10,22 @@ namespace ViewModelsSamples.Axes.ColorsAndPosition; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private AxisPosition _selectedPosition = AxisPosition.End; private int _selectedColor = 0; private readonly LvcColor[] _colors = ColorPalletes.FluentDesign; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { Values = new ObservableCollection { 2, 5, 4, -2, 4, -3, 5 }, Stroke = null, Fill = new SolidColorPaint { Color = SKColors.DarkOliveGreen } } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public Axis[] XAxes { get; set; } = [ new Axis { //Name = "X axis", @@ -42,10 +39,9 @@ public partial class ViewModel : ObservableObject Position = AxisPosition.End } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public Axis[] YAxes { get; set; } = [ new Axis { //Name = "Y axis", @@ -54,7 +50,7 @@ public partial class ViewModel : ObservableObject SeparatorsPaint = new SolidColorPaint { Color = SKColors.LightPink, StrokeThickness = 3 }, Position = AxisPosition.End } - }; + ]; [RelayCommand] public void SetNewColor() diff --git a/samples/ViewModelsSamples/Axes/Crosshairs/ViewModel.cs b/samples/ViewModelsSamples/Axes/Crosshairs/ViewModel.cs index 72da8a684..9d82740b7 100644 --- a/samples/ViewModelsSamples/Axes/Crosshairs/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Crosshairs/ViewModel.cs @@ -1,44 +1,35 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.Crosshairs; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { - new LineSeries - { - Values = new ObservableCollection { 200, 558, 458, 249, 457, 339, 587 }, - }, - new LineSeries - { - Values = new ObservableCollection { 210, 400, 300, 350, 219, 323, 618 }, - }, - }; + public ISeries[] Series { get; set; } = [ + new LineSeries { Values = [200, 558, 458, 249, 457, 339, 587] }, + new LineSeries { Values = [210, 400, 300, 350, 219, 323, 618] }, + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { CrosshairLabelsBackground = SKColors.DarkOrange.AsLvcColor(), - CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkRed, 1), + CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkRed), CrosshairPaint = new SolidColorPaint(SKColors.DarkOrange, 1), Labeler = value => value.ToString("N2") } - }; - public Axis[] YAxes { get; set; } = - { + ]; + + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { CrosshairLabelsBackground = SKColors.DarkOrange.AsLvcColor(), - CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkRed, 1), + CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkRed), CrosshairPaint = new SolidColorPaint(SKColors.DarkOrange, 1), CrosshairSnapEnabled = true // snapping is also supported } - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/CustomSeparatorsInterval/ViewModel.cs b/samples/ViewModelsSamples/Axes/CustomSeparatorsInterval/ViewModel.cs index efc5805f6..16bc0f509 100644 --- a/samples/ViewModelsSamples/Axes/CustomSeparatorsInterval/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/CustomSeparatorsInterval/ViewModel.cs @@ -1,29 +1,27 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.CustomSeparatorsInterval; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { - new LineSeries { Values = new[] { 10, 55, 45, 68, 60, 70, 75, 78 } } - }; + public ISeries[] Series { get; set; } = [ + new LineSeries { Values = [10, 55, 45, 68, 60, 70, 75, 78] } + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { // We can specify a custom separator collection // the library will use this separators instead of // calculating them based on the date of the chart - CustomSeparators = new double[] { 0, 10, 25, 50, 100 }, + CustomSeparators = [0, 10, 25, 50, 100], MinLimit = 0, // forces the axis to start at 0 MaxLimit = 100, // forces the axis to end at 100 SeparatorsPaint = new SolidColorPaint(SKColors.Black.WithAlpha(100)) } - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/DateTimeScaled/ViewModel.cs b/samples/ViewModelsSamples/Axes/DateTimeScaled/ViewModel.cs index ea6c4829b..3a4c550f5 100644 --- a/samples/ViewModelsSamples/Axes/DateTimeScaled/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/DateTimeScaled/ViewModel.cs @@ -1,39 +1,35 @@ using System; -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Axes.DateTimeScaled; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new ObservableCollection - { - new DateTimePoint(new DateTime(2021, 1, 1), 3), - new DateTimePoint(new DateTime(2021, 1, 2), 6), - new DateTimePoint(new DateTime(2021, 1, 3), 5), - new DateTimePoint(new DateTime(2021, 1, 4), 3), - new DateTimePoint(new DateTime(2021, 1, 5), 5), - new DateTimePoint(new DateTime(2021, 1, 6), 8), - new DateTimePoint(new DateTime(2021, 1, 7), 6) - } + Values = [ + new() { DateTime = new(2021, 1, 1), Value = 3 }, + new() { DateTime = new(2021, 1, 2), Value = 6 }, + new() { DateTime = new(2021, 1, 3), Value = 5 }, + new() { DateTime = new(2021, 1, 4), Value = 3 }, + new() { DateTime = new(2021, 1, 5), Value = 5 }, + new() { DateTime = new(2021, 1, 6), Value = 8 }, + new() { DateTime = new(2021, 1, 7), Value = 6 } + ] } - }; + ]; // You can use the DateTimeAxis class to define a date time based axis // mark // The first parameter is the time between each point, in this case 1 day // mark // you can also use 1 year, 1 month, 1 hour, 1 minute, 1 second, 1 millisecond, etc // mark - // The second parameter is a function that receives the value and returns the label // mark - public Axis[] XAxes { get; set; } = - { + // The second parameter is a function that receives a date and returns the label as string // mark + public ICartesianAxis[] XAxes { get; set; } = [ new DateTimeAxis(TimeSpan.FromDays(1), date => date.ToString("MMMM dd")) - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/LabelsFormat/ViewModel.cs b/samples/ViewModelsSamples/Axes/LabelsFormat/ViewModel.cs index e5a82ccdd..7177fa5ba 100644 --- a/samples/ViewModelsSamples/Axes/LabelsFormat/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/LabelsFormat/ViewModel.cs @@ -1,32 +1,29 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.LabelsFormat; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { - new ColumnSeries { Values = new double[] { 426, 583, 104 } }, - new LineSeries { Values = new double[] { 200, 558, 458 }, Fill = null }, - }; - - public Axis[] XAxes { get; set; } = - { + public ISeries[] Series { get; set; } = [ + new ColumnSeries { Values = [426, 583, 104] }, + new LineSeries { Values = [200, 558, 458], Fill = null }, + ]; + + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { Name = "Salesman/woman", // Use the labels property for named or static labels // mark - Labels = new string[] { "Sergio", "Lando", "Lewis" }, // mark + Labels = ["Sergio", "Lando", "Lewis"], // mark LabelsRotation = 15, } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { Name = "Salome", @@ -36,11 +33,15 @@ public partial class ViewModel : ObservableObject { Color = SKColors.Blue, FontFamily = "Times New Roman", - SKFontStyle = new SKFontStyle(SKFontStyleWeight.ExtraBold, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic) + SKFontStyle = new SKFontStyle( + SKFontStyleWeight.ExtraBold, + SKFontStyleWidth.Normal, + SKFontStyleSlant.Italic) }, // Use the Labeler property to give format to the axis values // mark - // Now the Y axis we will display it as currency + // Now the Y axis labels have a currency format. + // LiveCharts provides some common formatters // in this case we are using the currency formatter. Labeler = Labelers.Currency // mark @@ -48,9 +49,8 @@ public partial class ViewModel : ObservableObject // you could also build your own currency formatter // for example: // Labeler = (value) => value.ToString("C") - - // But the one that LiveCharts provides creates shorter labels when + // but the one that LiveCharts provides creates shorter labels when // the amount is in millions or trillions } - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/LabelsFormat2/ViewModel.cs b/samples/ViewModelsSamples/Axes/LabelsFormat2/ViewModel.cs index 94406400a..4c16c7264 100644 --- a/samples/ViewModelsSamples/Axes/LabelsFormat2/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/LabelsFormat2/ViewModel.cs @@ -1,12 +1,12 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.LabelsFormat2; -public partial class ViewModel : ObservableObject +public class ViewModel { public ViewModel() { @@ -17,27 +17,24 @@ public ViewModel() config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('汉'))); // You can learn more about extra settings at: // mark - // https://localhost:7053/docs/{{ platform }}/{{ version }}/Overview.Installation#configure-themes-fonts-or-mappers-optional // mark + // https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Installation#configure-themes-fonts-or-mappers-optional // mark } - public ISeries[] Series { get; set; } = - { - new ColumnSeries { Values = new double[] { 426, 583, 104 } }, - new LineSeries { Values = new double[] { 200, 558, 458 }, Fill = null } - }; + public ISeries[] Series { get; set; } = [ + new ColumnSeries { Values = [426, 583, 104] }, + new LineSeries { Values = [200, 558, 458], Fill = null } + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { Name = "Salesman/woman", - Labels = new string[] { "王", "赵", "张" }, + Labels = ["王", "赵", "张"], LabelsPaint = new SolidColorPaint(SKColors.Black) } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { Name = "Sales amount", @@ -47,8 +44,11 @@ public ViewModel() { Color = SKColors.Blue, FontFamily = "Times New Roman", - SKFontStyle = new SKFontStyle(SKFontStyleWeight.ExtraBold, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic) + SKFontStyle = new SKFontStyle( + SKFontStyleWeight.ExtraBold, + SKFontStyleWidth.Normal, + SKFontStyleSlant.Italic) }, } - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/LabelsRotation/ViewModel.cs b/samples/ViewModelsSamples/Axes/LabelsRotation/ViewModel.cs index b5bc9267f..e868c7a44 100644 --- a/samples/ViewModelsSamples/Axes/LabelsRotation/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/LabelsRotation/ViewModel.cs @@ -1,31 +1,29 @@ using System; -using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; namespace ViewModelsSamples.Axes.LabelsRotation; -public partial class ViewModel : ObservableObject +public class ViewModel : ObservableObject { private double _sliderValue = 15; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - Values = new ObservableCollection { 200, 558, 458, 249, 457, 339, 587 }, + Values = [200, 558, 458, 249, 457, 339, 587 ], XToolTipLabelFormatter = (point) => $"This is {Environment.NewLine}" + $"A multi-line label {Environment.NewLine}" + $"With a value of {Environment.NewLine}" + point.Coordinate.PrimaryValue, } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { // Use the Label property to indicate the format of the labels in the axis @@ -45,10 +43,9 @@ public partial class ViewModel : ObservableObject SeparatorsPaint = new SolidColorPaint(SKColors.LightGray, 2) } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { LabelsRotation = 15, @@ -67,7 +64,7 @@ public partial class ViewModel : ObservableObject SeparatorsPaint = new SolidColorPaint(SKColors.LightGray, 2) } - }; + ]; public double SliderValue { diff --git a/samples/ViewModelsSamples/Axes/Logarithmic/LogarithmicPoint.cs b/samples/ViewModelsSamples/Axes/Logarithmic/LogarithmicPoint.cs index 78439bea4..9e98c887e 100644 --- a/samples/ViewModelsSamples/Axes/Logarithmic/LogarithmicPoint.cs +++ b/samples/ViewModelsSamples/Axes/Logarithmic/LogarithmicPoint.cs @@ -1,6 +1,6 @@ namespace ViewModelsSamples.Axes.Logarithmic; -public class LogarithmicPoint +public struct LogarithmicPoint { public double X { get; set; } public double Y { get; set; } diff --git a/samples/ViewModelsSamples/Axes/Logarithmic/ViewModel.cs b/samples/ViewModelsSamples/Axes/Logarithmic/ViewModel.cs index 5a6c2c3a8..bcdc0d664 100644 --- a/samples/ViewModelsSamples/Axes/Logarithmic/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Logarithmic/ViewModel.cs @@ -1,27 +1,22 @@ using System; -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.Logarithmic; -public partial class ViewModel : ObservableObject +public class ViewModel { // base 10 log, change the base if you require it. // or use any custom scale the logic is the same. private static readonly int s_logBase = 10; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - // for the x coordinate, we use the X property - // and for the Y coordinate, we will map it to the logarithm of the value - Mapping = (logPoint, index) => new(logPoint.X, Math.Log(logPoint.Y, s_logBase)), - Values = new LogarithmicPoint[] - { + Values = [ new() { X = 1, Y = 1 }, new() { X = 2, Y = 10 }, new() { X = 3, Y = 100 }, @@ -30,12 +25,20 @@ public partial class ViewModel : ObservableObject new() { X = 6, Y = 100000 }, new() { X = 7, Y = 1000000 }, new() { X = 8, Y = 10000000 } - } + ], + + // lets map the values to the logarithmic scale // mark + // for the x coordinate, we use the X property // mark + // and for the Y coordinate, we will map it to the logarithm of the Y value // mark + Mapping = (logPoint, index) => // mark + new(logPoint.X, Math.Log(logPoint.Y, s_logBase)), // mark + + // for more info about mappers see: + // https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new LogaritmicAxis(s_logBase) { SeparatorsPaint = new SolidColorPaint @@ -50,5 +53,5 @@ public partial class ViewModel : ObservableObject }, SubseparatorsCount = 9, } - }; + ]; } diff --git a/samples/ViewModelsSamples/Axes/Multiple/ViewModel.cs b/samples/ViewModelsSamples/Axes/Multiple/ViewModel.cs index 423039b0c..d8da30363 100644 --- a/samples/ViewModelsSamples/Axes/Multiple/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Multiple/ViewModel.cs @@ -1,25 +1,23 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Axes.Multiple; -public partial class ViewModel : ObservableObject +public class ViewModel { private static readonly SKColor s_blue = new(25, 118, 210); private static readonly SKColor s_red = new(229, 57, 53); private static readonly SKColor s_yellow = new(198, 167, 0); - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { LineSmoothness = 1, Name = "Tens", - Values = new double[] { 14, 13, 14, 15, 17 }, + Values = [14, 13, 14, 15, 17], Stroke = new SolidColorPaint(s_blue, 2), GeometrySize = 10, GeometryStroke = new SolidColorPaint(s_blue, 2), @@ -29,7 +27,7 @@ public partial class ViewModel : ObservableObject new LineSeries { Name = "Tens 2", - Values = new double[] { 11, 12, 13, 10, 13 }, + Values = [11, 12, 13, 10, 13], Stroke = new SolidColorPaint(s_blue, 2), GeometrySize = 10, GeometryStroke = new SolidColorPaint(s_blue, 2), @@ -39,7 +37,7 @@ public partial class ViewModel : ObservableObject new LineSeries { Name = "Hundreds", - Values = new double[] { 533, 586, 425, 579, 518 }, + Values = [533, 586, 425, 579, 518], Stroke = new SolidColorPaint(s_red, 2), GeometrySize = 10, GeometryStroke = new SolidColorPaint(s_red, 2), @@ -49,17 +47,16 @@ public partial class ViewModel : ObservableObject new LineSeries { Name = "Thousands", - Values = new double[] { 5493, 7843, 4368, 9018, 3902 }, + Values = [5493, 7843, 4368, 9018, 3902], Stroke = new SolidColorPaint(s_yellow, 2), GeometrySize = 10, GeometryStroke = new SolidColorPaint(s_yellow, 2), Fill = null, ScalesYAt = 2 // it will be scaled at the YAxes[2] instance // mark } - }; + ]; - public ICartesianAxis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis // the "units" and "tens" series will be scaled on this axis { Name = "Tens", @@ -103,7 +100,7 @@ public partial class ViewModel : ObservableObject ShowSeparatorLines = false, Position = LiveChartsCore.Measure.AxisPosition.End } - }; + ]; public SolidColorPaint LegendTextPaint { get; set; } = new SolidColorPaint diff --git a/samples/ViewModelsSamples/Axes/NamedLabels/ViewModel.cs b/samples/ViewModelsSamples/Axes/NamedLabels/ViewModel.cs index 98111ff66..d51d02359 100644 --- a/samples/ViewModelsSamples/Axes/NamedLabels/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/NamedLabels/ViewModel.cs @@ -1,39 +1,36 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Axes.NamedLabels; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { Name = "Sales", - Values = new int[] { 200, 558, 458, 249 }, + Values = [200, 558, 458, 249], }, new LineSeries { Name = "Projected", - Values = new int[] { 300, 450, 400, 280 }, + Values = [300, 450, 400, 280], Fill = null } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { // Use the labels property to define named labels. - Labels = new string[] { "Anne", "Johnny", "Zac", "Rosa" } + Labels = ["Anne", "Johnny", "Zac", "Rosa"] } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { // Now the Y axis we will display labels as currency @@ -48,7 +45,7 @@ public partial class ViewModel : ObservableObject // But the one that LiveCharts provides creates shorter labels when // the amount is in millions or trillions } - }; + ]; public SolidColorPaint TooltipTextPaint { get; set; } = new SolidColorPaint diff --git a/samples/ViewModelsSamples/Axes/Paging/ViewModel.cs b/samples/ViewModelsSamples/Axes/Paging/ViewModel.cs index b09d2d637..48af49903 100644 --- a/samples/ViewModelsSamples/Axes/Paging/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Paging/ViewModel.cs @@ -1,16 +1,20 @@ using System; using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Axes.Paging; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private readonly Random _random = new(); + public ISeries[] Series { get; } + + public ICartesianAxis[] XAxes { get; } + public ViewModel() { var trend = 100; @@ -22,21 +26,10 @@ public ViewModel() values.Add(trend); } - Series = new ISeries[] - { - new ColumnSeries - { - Values = values - } - }; - - XAxes = new[] { new Axis() }; + Series = [new ColumnSeries(values)]; + XAxes = [new Axis()]; } - public ISeries[] Series { get; } - - public Axis[] XAxes { get; } - [RelayCommand] public void GoToPage1() { diff --git a/samples/ViewModelsSamples/Axes/Shared/ViewModel.cs b/samples/ViewModelsSamples/Axes/Shared/ViewModel.cs index 7b324f2db..e22634033 100644 --- a/samples/ViewModelsSamples/Axes/Shared/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Shared/ViewModel.cs @@ -1,42 +1,57 @@ using System; -using CommunityToolkit.Mvvm.ComponentModel; +using System.Linq; using LiveChartsCore; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView.Painting; +using SkiaSharp; namespace ViewModelsSamples.Axes.Shared; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] SeriesCollection1 { get; set; } + public ISeries[] SeriesCollection2 { get; set; } + public Axis[] X1 { get; set; } + public Axis[] X2 { get; set; } + public Margin DrawMargin { get; set; } + public ViewModel() { - var values1 = new int[50]; - var values2 = new int[50]; - var r = new Random(); - var t = 0; - var t2 = 0; - - for (var i = 0; i < 50; i++) - { - t += r.Next(-90, 100); - values1[i] = t; - - t2 += r.Next(-9000, 10000); - values2[i] = t2; - } - - SeriesCollection1 = new ISeries[] { new LineSeries { Values = values1 } }; - SeriesCollection2 = new ISeries[] { new ColumnSeries { Values = values2 } }; - - // ideally, when sharing an axis, you should set the initial limits for all the axes involved. // mark - var start = 0 - 5; - var end = 50 + 5; - - X1 = new Axis[] { new Axis { MinLimit = start, MaxLimit = end } }; - X2 = new Axis[] { new Axis { MinLimit = start, MaxLimit = end } }; - - X1[0].SharedWith = X2; - X2[0].SharedWith = X1; + var values1 = Fetch(); + var values2 = Fetch(); + + SeriesCollection1 = [new LineSeries { Values = values1 }]; + SeriesCollection2 = [new ColumnSeries { Values = values2 }]; + + // ideally, when sharing an axis, you should set the // mark + // initial limits for all the axes involved. // mark + var padding = 3; + var start = 0 - padding; + var end = values1.Length - 1 + padding; + + X1 = [ + new Axis + { + MinLimit = start, + MaxLimit = end, + CrosshairLabelsBackground = SKColors.OrangeRed.AsLvcColor(), + CrosshairLabelsPaint = new SolidColorPaint(SKColors.White), + CrosshairPaint = new SolidColorPaint(SKColors.OrangeRed.WithAlpha(50), 4), + CrosshairPadding = new(8), + Labeler = value => value.ToString("N2") + } + ]; + X2 = [ + new Axis + { + MinLimit = start, + MaxLimit = end, + CrosshairPaint = new SolidColorPaint(SKColors.OrangeRed.WithAlpha(50), 4) + } + ]; + + SharedAxes.Set(X1[0], X2[0]); // Force the chart to use 70px margin on the left, this way we can align both charts Y axes. // mark DrawMargin = new Margin(70, Margin.Auto, Margin.Auto, Margin.Auto); @@ -59,9 +74,18 @@ public ViewModel() // calculate the required margin. } - public ISeries[] SeriesCollection1 { get; set; } - public ISeries[] SeriesCollection2 { get; set; } - public Axis[] X1 { get; set; } - public Axis[] X2 { get; set; } - public Margin DrawMargin { get; set; } + private static int[] Fetch() + { + var values = new int[50]; + var r = new Random(); + var t = 0; + + for (var i = 0; i < 50; i++) + { + t += r.Next(-90, 100); + values[i] = t; + } + + return values; + } } diff --git a/samples/ViewModelsSamples/Axes/Style/ViewModel.cs b/samples/ViewModelsSamples/Axes/Style/ViewModel.cs index f798e5933..6a1754ff9 100644 --- a/samples/ViewModelsSamples/Axes/Style/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/Style/ViewModel.cs @@ -1,24 +1,23 @@ using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using LiveChartsCore.SkiaSharpView.Painting.Effects; -using SkiaSharp; namespace ViewModelsSamples.Axes.Style; -public partial class ViewModel : ObservableObject +public class ViewModel { private static readonly SKColor s_gray = new(195, 195, 195); private static readonly SKColor s_gray1 = new(160, 160, 160); private static readonly SKColor s_gray2 = new(90, 90, 90); private static readonly SKColor s_dark3 = new(60, 60, 60); - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { Values = Fetch(), @@ -26,10 +25,9 @@ public partial class ViewModel : ObservableObject Fill = null, GeometrySize = 0 } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { Name = "X axis", @@ -41,7 +39,7 @@ public partial class ViewModel : ObservableObject { Color = s_gray, StrokeThickness = 1, - PathEffect = new DashEffect(new float[] { 3, 3 }) + PathEffect = new DashEffect([3, 3]) }, SubseparatorsPaint = new SolidColorPaint { @@ -65,10 +63,9 @@ public partial class ViewModel : ObservableObject StrokeThickness = 1 } } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { Name = "Y axis", @@ -80,7 +77,7 @@ public partial class ViewModel : ObservableObject { Color = s_gray, StrokeThickness = 1, - PathEffect = new DashEffect(new float[] { 3, 3 }) + PathEffect = new DashEffect([3, 3]) }, SubseparatorsPaint = new SolidColorPaint { @@ -104,18 +101,18 @@ public partial class ViewModel : ObservableObject StrokeThickness = 1 } } - }; + ]; public DrawMarginFrame Frame { get; set; } = - new() - { - Fill = new SolidColorPaint(s_dark3), - Stroke = new SolidColorPaint + new() { - Color = s_gray, - StrokeThickness = 1 - } - }; + Fill = new SolidColorPaint(s_dark3), + Stroke = new SolidColorPaint + { + Color = s_gray, + StrokeThickness = 1 + } + }; private static List Fetch() { @@ -125,7 +122,12 @@ private static List Fetch() for (var x = 0f; x < 1f; x += 0.001f) { var y = fx(x); - list.Add(new ObservablePoint(x - 0.5, y - 0.5)); + + list.Add(new() + { + X = x - 0.5, + Y = y - 0.5 + }); } return list; diff --git a/samples/ViewModelsSamples/Axes/TimeSpanScaled/ViewModel.cs b/samples/ViewModelsSamples/Axes/TimeSpanScaled/ViewModel.cs index 0f6ebae87..e2789d831 100644 --- a/samples/ViewModelsSamples/Axes/TimeSpanScaled/ViewModel.cs +++ b/samples/ViewModelsSamples/Axes/TimeSpanScaled/ViewModel.cs @@ -1,28 +1,25 @@ using System; -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Axes.TimeSpanScaled; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new ObservableCollection - { - new TimeSpanPoint(TimeSpan.FromMilliseconds(1), 10), - new TimeSpanPoint(TimeSpan.FromMilliseconds(2), 6), - new TimeSpanPoint(TimeSpan.FromMilliseconds(3), 3), - new TimeSpanPoint(TimeSpan.FromMilliseconds(4), 12), - new TimeSpanPoint(TimeSpan.FromMilliseconds(5), 8), - }, + Values = [ + new () { TimeSpan = TimeSpan.FromMilliseconds(1), Value = 10 }, + new () { TimeSpan = TimeSpan.FromMilliseconds(2), Value = 6 }, + new () { TimeSpan = TimeSpan.FromMilliseconds(3), Value = 3 }, + new () { TimeSpan = TimeSpan.FromMilliseconds(4), Value = 12 }, + new () { TimeSpan = TimeSpan.FromMilliseconds(5), Value = 8 } + ], } - }; + ]; // You can use the TimeSpanAxis class to define a time span based axis // mark @@ -30,8 +27,7 @@ public partial class ViewModel : ObservableObject // you can also use 1 year, 1 month, 1 hour, 1 minute, 1 second, 1 millisecond, etc // mark // The second parameter is a function that receives the value and returns the label // mark - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new TimeSpanAxis(TimeSpan.FromMilliseconds(1), date => date.ToString("fff") + "ms") - }; + ]; } diff --git a/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs index e588efa21..82d563f78 100644 --- a/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Defaults; @@ -9,101 +7,88 @@ namespace ViewModelsSamples.Bars.AutoUpdate; -public partial class ViewModel : ObservableObject +public partial class ViewModel { - private int _index = 0; private readonly Random _random = new(); - private readonly ObservableCollection _observableValues; + + // We use the ObservableCollection class, to let the chart know // mark + // when a new item is added or removed from the chart. // mark + public ObservableCollection Series { get; set; } + public ObservableCollection ObservablePoints { get; set; } public ViewModel() { - // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = - [ - // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark - // or use any INotifyPropertyChanged implementation // mark - new ObservablePoint(_index++, 2), - new(_index++, 5), // the ObservablePoint type is redundant and inferred by the compiler (C# 9 and above) - new(_index++, 4), - new(_index++, 5), - new(_index++, 2), - new(_index++, 6), - new(_index++, 6), - new(_index++, 6), - new(_index++, 4), - new(_index++, 2), - new(_index++, 3), - new(_index++, 8), - new(_index++, 3) + ObservablePoints = [ + new() { X = 0, Y = 2 }, + new() { X = 1, Y = 5 }, + new() { X = 2, Y = 4 } ]; - Series = - [ - new ColumnSeries - { - Values = _observableValues - } + Series = [ + new ColumnSeries(ObservablePoints) ]; - - // in the following sample notice that the type int does not implement INotifyPropertyChanged - // and our Series.Values property is of type List - // List does not implement INotifyCollectionChanged - // this means the following series is not listening for changes. - // Series.Add(new ColumnSeries { Values = new List { 2, 4, 6, 1, 7, -2 } }); // mark } - public ObservableCollection Series { get; set; } - [RelayCommand] - public void AddItem() + public void AddSeries() { - // for this sample only 50 items are supported. - if (_observableValues.Count > 50) return; + // Because the Series property is an ObservableCollection, // mark + // the chart will listen for changes and update // mark + // in this case a new series is added to the chart // mark - var randomValue = _random.Next(1, 10); - _observableValues.Add(new ObservablePoint(_index++, randomValue)); + var newColumnSeries = new ColumnSeries(FetchVales()); + Series.Add(newColumnSeries); } [RelayCommand] - public void RemoveItem() + public void RemoveSeries() { - if (_observableValues.Count < 2) return; + if (Series.Count == 1) return; - _observableValues.RemoveAt(0); + // This will also remove the series from the UI. // mark + Series.RemoveAt(Series.Count - 1); } [RelayCommand] - public void ReplaceItem() + public void AddItem() { - var randomValue = _random.Next(1, 10); - var randomIndex = _random.Next(0, _observableValues.Count - 1); - _observableValues[randomIndex] = new(_observableValues[randomIndex].X, randomValue); + var newPoint = new ObservablePoint + { + X = ObservablePoints.Count, + Y = _random.Next(0, 10) + }; + + // The new point will be drawn at the end of the chart // mark + ObservablePoints.Add(newPoint); } - [RelayCommand] - public void AddSeries() + public void RemoveItem() { - // for this sample only 5 series are supported. - if (Series.Count == 5) return; - - Series.Add( - new ColumnSeries - { - Values = new List - { - _random.Next(0, 10), - _random.Next(0, 10), - _random.Next(0, 10) - } - }); + if (ObservablePoints.Count < 2) return; + + // Because the ObservablePoints property is an ObservableCollection, // mark + // the chart will listen for changes and update // mark + // in this case a point is removed from the chart // mark + + ObservablePoints.RemoveAt(0); } [RelayCommand] - public void RemoveSeries() + public void ReplaceItem() { - if (Series.Count == 1) return; + var randomIndex = _random.Next(0, ObservablePoints.Count - 1); - Series.RemoveAt(Series.Count - 1); + // The chart will update the point at the specified index // mark + ObservablePoints[randomIndex] = new(ObservablePoints[randomIndex].X, _random.Next(1, 10)); + } + + private int[] FetchVales() + { + return [ + _random.Next(0, 10), + _random.Next(0, 10), + _random.Next(0, 10) + ]; } } diff --git a/samples/ViewModelsSamples/Bars/Basic/ViewModel.cs b/samples/ViewModelsSamples/Bars/Basic/ViewModel.cs index 693cab2d1..1ebb85a17 100644 --- a/samples/ViewModelsSamples/Bars/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/Basic/ViewModel.cs @@ -1,32 +1,31 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Bars.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { public ISeries[] Series { get; set; } = - { + [ new ColumnSeries { Name = "Mary", - Values = new double[] { 2, 5, 4 } + Values = [2, 5, 4] }, new ColumnSeries { Name = "Ana", - Values = new double[] { 3, 1, 6 } + Values = [3, 1, 6] } - }; + ]; public Axis[] XAxes { get; set; } = - { + [ new Axis { - Labels = new string[] { "Category 1", "Category 2", "Category 3" }, + Labels = ["Category 1", "Category 2", "Category 3"], LabelsRotation = 0, SeparatorsPaint = new SolidColorPaint(new SKColor(200, 200, 200)), SeparatorsAtCenter = false, @@ -38,5 +37,5 @@ public partial class ViewModel : ObservableObject ForceStepToMin = true, // mark MinStep = 1 // mark } - }; + ]; } diff --git a/samples/ViewModelsSamples/Bars/Custom/ViewModel.cs b/samples/ViewModelsSamples/Bars/Custom/ViewModel.cs index f7dfbe078..20291e8a2 100644 --- a/samples/ViewModelsSamples/Bars/Custom/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/Custom/ViewModel.cs @@ -1,32 +1,28 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Drawing; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace ViewModelsSamples.Bars.Custom; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { - new ColumnSeries - { - Values = new double[] { 2, 1, 4}, - }, + public ISeries[] Series { get; set; } = [ + new ColumnSeries ([2, 1, 4]), + + // use the second generic parameter to define the geometry to draw + // there are many predefined geometries in the LiveChartsCore.Drawing namespace + // for example, the StarGeometry, CrossGeometry, RectangleGeometry and DiamondGeometry + new ColumnSeries([4, 3, 6]), - // You can also use SVG paths to draw the geometry - // LiveCharts already provides some predefined paths in the SVGPoints class. - new ColumnSeries - { - Values = new double[] { -2, 2, 1 }, - GeometrySvg = SVGPoints.Star - }, + // You can also use SVG paths to draw the geometry + // the VariableSVGPathGeometry can change the drawn path at runtime + new ColumnSeries([-2, 2, 1]) + { + GeometrySvg = SVGPoints.Star + }, - // you can declare your own gemetry and use the SkiaSharp api to draw it - new ColumnSeries - { - Values = new double[] { 4, 5, 2 }, - }, - }; + // finally you can also use SkiaSharp to draw your own geometry + new ColumnSeries([4, 5, 2]) + ]; } diff --git a/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs b/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs index 2fa32acd7..64ed2af70 100644 --- a/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; @@ -9,33 +8,22 @@ namespace ViewModelsSamples.Bars.DelayedAnimation; -public partial class ViewModel : ObservableObject +public class ViewModel { + public List Series { get; set; } + public ViewModel() { - var values1 = new List(); - var values2 = new List(); - - var fx = EasingFunctions.BounceInOut; // this is the function we are going to plot - var x = 0f; - - while (x <= 1) - { - values1.Add(fx(x)); - values2.Add(fx(x - 0.15f)); - x += 0.025f; - } - var columnSeries1 = new ColumnSeries { - Values = values1, + Values = FetchVales(0), Stroke = null, Padding = 2 }; var columnSeries2 = new ColumnSeries { - Values = values2, + Values = FetchVales(-0.15f), Stroke = null, Padding = 2 }; @@ -48,10 +36,15 @@ public ViewModel() private void OnPointMeasured(ChartPoint point) { - var perPointDelay = 100; // milliseconds + var perPointDelay = 100; // in milliseconds var delay = point.Context.Entity.MetaData!.EntityIndex * perPointDelay; var speed = (float)point.Context.Chart.AnimationsSpeed.TotalMilliseconds + delay; + // the animation takes a function, that represents the progress of the animation + // the parameter is the progress of the animation, it goes from 0 to 1 + // the function must return a value from 0 to 1, where 0 is the initial state + // and 1 is the end state + point.Visual?.SetTransition( new Animation(progress => { @@ -64,5 +57,22 @@ private void OnPointMeasured(ChartPoint Series { get; set; } + private static List FetchVales(float offset) + { + var values = new List(); + + // the EasingFunctions.BounceInOut, is just + // a function that takes a double and returns a double + + var fx = EasingFunctions.BounceInOut; + var x = 0f; + + while (x <= 1) + { + values.Add(fx(x + offset)); + x += 0.025f; + } + + return values; + } } diff --git a/samples/ViewModelsSamples/Bars/Layered/ViewModel.cs b/samples/ViewModelsSamples/Bars/Layered/ViewModel.cs index db2a238d3..7788a479f 100644 --- a/samples/ViewModelsSamples/Bars/Layered/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/Layered/ViewModel.cs @@ -1,26 +1,24 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Bars.Layered; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new[] { 6, 3, 5, 7, 3, 4, 6, 3 }, + Values = [6, 3, 5, 7, 3, 4, 6, 3], Stroke = null, MaxBarWidth = double.MaxValue, IgnoresBarPosition = true }, new ColumnSeries { - Values = new[] { 2, 4, 8, 9, 5, 2, 4, 7 }, + Values = [2, 4, 8, 9, 5, 2, 4, 7], Stroke = null, MaxBarWidth = 30, IgnoresBarPosition = true } - }; + ]; } diff --git a/samples/ViewModelsSamples/Bars/Race/ViewModel.cs b/samples/ViewModelsSamples/Bars/Race/ViewModel.cs index 7e4af6212..7f40cc013 100644 --- a/samples/ViewModelsSamples/Bars/Race/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/Race/ViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; @@ -20,6 +21,7 @@ public PilotInfo(string name, int value, SolidColorPaint paint) { Name = name; Paint = paint; + // the ObservableValue.Value property is used by the chart Value = value; } @@ -41,8 +43,8 @@ public ViewModel() .ToArray(); // generate some data for each pilot: - _data = new PilotInfo[] - { + _data = + [ new("Tsunoda", 500, paints[0]), new("Sainz", 450, paints[1]), new("Riccardo", 520, paints[2]), @@ -50,11 +52,11 @@ public ViewModel() new("Perez", 660, paints[4]), new("Verstapen", 920, paints[5]), new("Hamilton", 1000, paints[6]) - }; + ]; var rowSeries = new RowSeries { - Values = _data.OrderBy(x => x.Value).ToArray(), + Values = SortData(), DataLabelsPaint = new SolidColorPaint(new SKColor(245, 245, 245)), DataLabelsPosition = DataLabelsPosition.End, DataLabelsTranslate = new(-1, 0), @@ -69,7 +71,7 @@ public ViewModel() point.Visual.Fill = point.Model!.Paint; }); - _series = new[] { rowSeries }; + _series = [rowSeries]; _ = StartRace(); } @@ -78,10 +80,10 @@ public ViewModel() private ISeries[] _series; [ObservableProperty] - private Axis[] _xAxes = { new Axis { SeparatorsPaint = new SolidColorPaint(new SKColor(220, 220, 220)) } }; + private Axis[] _xAxes = [new Axis { SeparatorsPaint = new SolidColorPaint(new SKColor(220, 220, 220)) }]; [ObservableProperty] - private Axis[] _yAxes = { new Axis { IsVisible = false } }; + private Axis[] _yAxes = [new Axis { IsVisible = false }]; public bool IsReading { get; set; } = true; @@ -98,10 +100,11 @@ public async Task StartRace() foreach (var item in _data) item.Value += _r.Next(0, 100); - Series[0].Values = - _data.OrderBy(x => x.Value).ToArray(); + Series[0].Values = SortData(); await Task.Delay(100); } } + + private ICollection SortData() => [.. _data.OrderBy(x => x.Value)]; } diff --git a/samples/ViewModelsSamples/Bars/RowsWithLabels/ViewModel.cs b/samples/ViewModelsSamples/Bars/RowsWithLabels/ViewModel.cs index 1697e1701..45d3606d8 100644 --- a/samples/ViewModelsSamples/Bars/RowsWithLabels/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/RowsWithLabels/ViewModel.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Bars.RowsWithLabels; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new RowSeries { - Values = new List { 8, -3, 4 }, + Values = [8, -3, 4], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(45, 45, 45)), DataLabelsSize = 14, @@ -22,7 +19,7 @@ public partial class ViewModel : ObservableObject }, new RowSeries { - Values = new List { 4, -6, 5 }, + Values = [4, -6, 5], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(250, 250, 250)), DataLabelsSize = 14, @@ -30,11 +27,11 @@ public partial class ViewModel : ObservableObject }, new RowSeries { - Values = new List { 6, -9, 3 }, + Values = [6, -9, 3], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(45, 45, 45)), DataLabelsSize = 14, DataLabelsPosition = DataLabelsPosition.Start } - }; + ]; } diff --git a/samples/ViewModelsSamples/Bars/Spacing/ViewModel.cs b/samples/ViewModelsSamples/Bars/Spacing/ViewModel.cs index aceae5dd5..72a2f46db 100644 --- a/samples/ViewModelsSamples/Bars/Spacing/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/Spacing/ViewModel.cs @@ -1,17 +1,14 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Bars.Spacing; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new ObservableCollection { 20, 50, 40, 20, 40, 30, 50, 20, 50, 40 }, + Values = [ 20, 50, 40, 20, 40, 30, 50, 20, 50, 40 ], // Defines the distance between every bars in the series Padding = 0, @@ -19,5 +16,5 @@ public partial class ViewModel : ObservableObject // Defines the max width a bar can have MaxBarWidth = double.MaxValue } - }; + ]; } diff --git a/samples/ViewModelsSamples/Bars/WithBackground/ViewModel.cs b/samples/ViewModelsSamples/Bars/WithBackground/ViewModel.cs index 5a456c793..fe7d46ffb 100644 --- a/samples/ViewModelsSamples/Bars/WithBackground/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/WithBackground/ViewModel.cs @@ -1,34 +1,32 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.Bars.WithBackground; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { IsHoverable = false, // disables the series from the tooltips // mark - Values = new double[] { 10, 10, 10, 10, 10, 10, 10 }, + Values = [10, 10, 10, 10, 10, 10, 10], Stroke = null, Fill = new SolidColorPaint(new SKColor(30, 30, 30, 30)), IgnoresBarPosition = true }, new ColumnSeries { - Values = new double[] { 3, 10, 5, 3, 7, 3, 8 }, + Values = [3, 10, 5, 3, 7, 3, 8], Stroke = null, Fill = new SolidColorPaint(SKColors.CornflowerBlue), IgnoresBarPosition = true } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { MinLimit = 0, MaxLimit = 10 } - }; + ]; } diff --git a/samples/ViewModelsSamples/Box/Basic/ViewModel.cs b/samples/ViewModelsSamples/Box/Basic/ViewModel.cs index 4ceff16a2..f7ab12e6d 100644 --- a/samples/ViewModelsSamples/Box/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Box/Basic/ViewModel.cs @@ -1,59 +1,53 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Box.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new BoxSeries { Name = "Year 2023", - Values = new BoxValue[] - { + Values = [ // max, upper quartile, median, lower quartile, min new(100, 80, 60, 20, 70), new(90, 70, 50, 30, 60), new(80, 60, 40, 10, 50) - } + ] }, new BoxSeries { Name = "Year 2024", - Values = new BoxValue[] - { + Values = [ new(90, 70, 50, 30, 60), new(80, 60, 40, 10, 50), new(70, 50, 30, 20, 40) - } + ] }, new BoxSeries { Name = "Year 2025", - Values = new BoxValue[] - { + Values = [ new(80, 60, 40, 10, 50), new(70, 50, 30, 20, 40), new(60, 40, 20, 10, 30) - } + ] } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public Axis[] XAxes { get; set; } = [ new Axis { - Labels = new string[] { "Apperitizers", "Mains", "Desserts" }, + Labels = ["Apperitizers", "Mains", "Desserts"], LabelsRotation = 0, SeparatorsPaint = new SolidColorPaint(new SKColor(200, 200, 200)), SeparatorsAtCenter = false, TicksPaint = new SolidColorPaint(new SKColor(35, 35, 35)), TicksAtCenter = true } - }; + ]; } diff --git a/samples/ViewModelsSamples/Design/LinearGradients/ViewModel.cs b/samples/ViewModelsSamples/Design/LinearGradients/ViewModel.cs index 23f32f9d0..687d039b0 100644 --- a/samples/ViewModelsSamples/Design/LinearGradients/ViewModel.cs +++ b/samples/ViewModelsSamples/Design/LinearGradients/ViewModel.cs @@ -1,23 +1,21 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Design.LinearGradients; -public partial class ViewModel : ObservableObject +public class ViewModel { // linear gradients are based on SkiaSharp linear gradients // for more info please see: // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/effects/shaders/linear-gradient - public ISeries[] Series { get; set; } = new ISeries[] - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { Name = "John", - Values = new []{ 3, 7, 2, 9, 4 }, + Values = [3, 7, 2, 9, 4], Stroke = null, // this is an easy way to set a linear gradient: @@ -26,7 +24,7 @@ public partial class ViewModel : ObservableObject // but you can customize the gradient Fill = new LinearGradientPaint( // the gradient will use the following colors array - new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) }, + [new SKColor(255, 140, 148), new SKColor(220, 237, 194)], // now with the following points we are specifying the orientation of the gradient // by default the gradient is orientated horizontally @@ -39,21 +37,29 @@ public partial class ViewModel : ObservableObject // where 0 is the start of the axis and 1 the end. Then to build our vertical gradient // we must go from the point: - // (x0, y0) where x0 could be read as "the middle of the x axis" (0.5) and y0 as "the start of the y axis" (0) + // (x0, y0) where x0 could be read as "the middle of the x axis" (0.5) and y0 as + // "the start of the y axis" (0) new SKPoint(0.5f, 0), // to the point: - // (x1, y1) where x1 could be read as "the middle of the x axis" (0.5) and y0 as "the end of the y axis" (1) + // (x1, y1) where x1 could be read as "the middle of the x axis" (0.5) and y0 as + // "the end of the y axis" (1) new SKPoint(0.5f, 1)) }, new LineSeries { Name = "Charles", - Values = new []{ 4, 2, 8, 5, 3 }, + Values = [4, 2, 8, 5, 3], GeometrySize = 22, - Stroke = new LinearGradientPaint(new[]{ new SKColor(45, 64, 89), new SKColor(255, 212, 96)}) { StrokeThickness = 10 }, - GeometryStroke = new LinearGradientPaint(new[]{ new SKColor(45, 64, 89), new SKColor(255, 212, 96)}) { StrokeThickness = 10 }, + Stroke = new LinearGradientPaint([new SKColor(45, 64, 89), new SKColor(255, 212, 96)]) + { + StrokeThickness = 10 + }, + GeometryStroke = new LinearGradientPaint([new SKColor(45, 64, 89), new SKColor(255, 212, 96)]) + { + StrokeThickness = 10 + }, Fill = null } - }; + ]; } diff --git a/samples/ViewModelsSamples/Design/RadialGradients/ViewModel.cs b/samples/ViewModelsSamples/Design/RadialGradients/ViewModel.cs index 87a8b0d20..4def9d308 100644 --- a/samples/ViewModelsSamples/Design/RadialGradients/ViewModel.cs +++ b/samples/ViewModelsSamples/Design/RadialGradients/ViewModel.cs @@ -1,19 +1,17 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.Design.RadialGradients; -public partial class ViewModel : ObservableObject +public class ViewModel { // radial gradients are based on SkiaSharp circular gradients // for more info please see: // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/effects/shaders/circular-gradients - private static readonly SKColor[] s_colors = - { + private static readonly SKColor[] s_colors = [ new SKColor(179, 229, 252), new SKColor(1, 87, 155) // ... @@ -22,14 +20,13 @@ public partial class ViewModel : ObservableObject // by default all the distance between each color is equal // use the colorPos parameter in the constructor of the RadialGradientPaint class // to specify the distance between each color - }; + ]; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new PieSeries { Name = "Maria", - Values = new []{ 7 }, + Values = [7], Stroke = null, Fill = new RadialGradientPaint(s_colors), Pushout = 10, @@ -38,9 +35,9 @@ public partial class ViewModel : ObservableObject new PieSeries { Name = "Charles", - Values = new []{ 3 }, + Values = [3], Stroke = null, Fill = new RadialGradientPaint(new SKColor(255, 205, 210), new SKColor(183, 28, 28)) } - }; + ]; } diff --git a/samples/ViewModelsSamples/Design/StrokeDashArray/ViewModel.cs b/samples/ViewModelsSamples/Design/StrokeDashArray/ViewModel.cs index 9b6bb8250..6f2d3674c 100644 --- a/samples/ViewModelsSamples/Design/StrokeDashArray/ViewModel.cs +++ b/samples/ViewModelsSamples/Design/StrokeDashArray/ViewModel.cs @@ -1,5 +1,4 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using LiveChartsCore.SkiaSharpView.Painting.Effects; @@ -7,8 +6,10 @@ namespace ViewModelsSamples.Design.StrokeDashArray; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { // The LiveChartsCore.SkiaSharpView.Painting.EffectsPathEffect abstract class is a wrapper for @@ -23,11 +24,10 @@ public ViewModel() var strokeDashArray = new float[] { 3 * strokeThickness, 2 * strokeThickness }; var effect = new DashEffect(strokeDashArray); - Series = new ISeries[] - { + Series = [ new LineSeries { - Values = new [] { 4, 2, 8, 5, 3 }, + Values = [4, 2, 8, 5, 3], LineSmoothness = 1, GeometrySize = 22, Stroke = new SolidColorPaint @@ -39,8 +39,6 @@ public ViewModel() }, Fill = null } - }; + ]; } - - public ISeries[] Series { get; set; } } diff --git a/samples/ViewModelsSamples/Error/Basic/ViewModel.cs b/samples/ViewModelsSamples/Error/Basic/ViewModel.cs index e2b6fe679..a79125512 100644 --- a/samples/ViewModelsSamples/Error/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Error/Basic/ViewModel.cs @@ -1,7 +1,7 @@ using System; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; @@ -9,8 +9,14 @@ namespace ViewModelsSamples.Error.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series0 { get; set; } + + public ISeries[] Series1 { get; set; } + + public ISeries[] Series2 { get; set; } + public ViewModel() { // use the ErrorValue type to define the error in Y // mark @@ -41,8 +47,7 @@ public ViewModel() new(6, 50, 0.3, 6) }; - Series0 = new ISeries[] - { + Series0 = [ new ColumnSeries { Values = values0, @@ -55,11 +60,10 @@ public ViewModel() ErrorPaint = new SolidColorPaint(SKColors.Black), Padding = 0 } - }; + ]; // LineSeries also supports error bars // mark - Series1 = new ISeries[] - { + Series1 = [ new LineSeries { Values = values0, @@ -67,7 +71,7 @@ public ViewModel() GeometrySize = 4, Fill = null } - }; + ]; // You can also use DateTime on the X axis // mark var now = DateTime.Now; @@ -86,27 +90,19 @@ public ViewModel() }; // ScatterSeries also supports error bars // mark - Series2 = new ISeries[] - { + Series2 = [ new ScatterSeries { Values = values2, ErrorPaint = new SolidColorPaint(SKColors.Black), GeometrySize = 10 } - }; + ]; } - public ISeries[] Series0 { get; set; } - - public ISeries[] Series1 { get; set; } - - public ISeries[] Series2 { get; set; } - // To get more help about DateTime axes see: // https://livecharts.dev/docs/{{ platform }}/{{ version }}/samples.axes.dateTimeScaled - public Axis[] DateTimeAxis { get; set; } = - { + public ICartesianAxis[] DateTimeAxis { get; set; } = [ new DateTimeAxis(TimeSpan.FromDays(1), date => date.ToString("MMMM dd")) - }; + ]; } diff --git a/samples/ViewModelsSamples/Events/AddPointOnClick/ViewModel.cs b/samples/ViewModelsSamples/Events/AddPointOnClick/ViewModel.cs index 113f596ab..0f76f287d 100644 --- a/samples/ViewModelsSamples/Events/AddPointOnClick/ViewModel.cs +++ b/samples/ViewModelsSamples/Events/AddPointOnClick/ViewModel.cs @@ -1,5 +1,4 @@ using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Defaults; @@ -10,34 +9,39 @@ namespace ViewModelsSamples.Events.AddPointOnClick; -public partial class ViewModel : ObservableObject +public partial class ViewModel { - public ISeries[] SeriesCollection { get; set; } = - new ISeries[] - { + public ObservableCollection Points { get; set; } + + public ISeries[] SeriesCollection { get; set; } + + public ViewModel() + { + Points = [ + new(0, 5), + new(3, 8), + new(7, 9) + ]; + + SeriesCollection = [ new LineSeries { - Values = new ObservableCollection - { - new(0, 5), - new(3, 8), - new(7, 9) - }, + Values = Points, Fill = null, DataPadding = new LiveChartsCore.Drawing.LvcPoint(5, 5) } - }; + ]; + } [RelayCommand] public void PointerDown(PointerCommandArgs args) { var chart = (ICartesianChartView)args.Chart; - var values = (ObservableCollection)SeriesCollection[0].Values!; // scales the UI coordinates to the corresponding data in the chart. var scaledPoint = chart.ScalePixelsToData(args.PointerPosition); // finally add the new point to the data in our chart. - values.Add(new ObservablePoint(scaledPoint.X, scaledPoint.Y)); + Points.Add(new ObservablePoint(scaledPoint.X, scaledPoint.Y)); } } diff --git a/samples/ViewModelsSamples/Events/Cartesian/ViewModel.cs b/samples/ViewModelsSamples/Events/Cartesian/ViewModel.cs index ee7cc462d..c7285fc4c 100644 --- a/samples/ViewModelsSamples/Events/Cartesian/ViewModel.cs +++ b/samples/ViewModelsSamples/Events/Cartesian/ViewModel.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Sketches; @@ -11,18 +10,20 @@ namespace ViewModelsSamples.Events.Cartesian; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { - var data = new[] + var data = new Fruit[] { - new Fruit { Name = "Apple", SalesPerDay = 4, Stock = 6 }, - new Fruit { Name = "Orange", SalesPerDay = 6, Stock = 4 }, - new Fruit { Name = "Pinaple", SalesPerDay = 2, Stock = 2 }, - new Fruit { Name = "Potoato", SalesPerDay = 8, Stock = 4 }, - new Fruit { Name = "Lettuce", SalesPerDay = 3, Stock = 6 }, - new Fruit { Name = "Cherry", SalesPerDay = 4, Stock = 8 } + new() { Name = "Apple", SalesPerDay = 4, Stock = 6 }, + new() { Name = "Orange", SalesPerDay = 6, Stock = 4 }, + new() { Name = "Pinaple", SalesPerDay = 2, Stock = 2 }, + new() { Name = "Potoato", SalesPerDay = 8, Stock = 4 }, + new() { Name = "Lettuce", SalesPerDay = 3, Stock = 6 }, + new() { Name = "Cherry", SalesPerDay = 4, Stock = 8 } }; var salesPerDaysSeries = new ColumnSeries @@ -38,16 +39,14 @@ public ViewModel() }; // notice that the event signature is different for every series - // use the IDE intellisense to help you (see more bellow in this article). // mark + // use the IDE intellisense to help you (see more bellow in this article). // mark salesPerDaysSeries.ChartPointPointerDown += OnPointerDown; // mark salesPerDaysSeries.ChartPointPointerHover += OnPointerHover; // mark salesPerDaysSeries.ChartPointPointerHoverLost += OnPointerHoverLost; // mark - Series = new ISeries[] { salesPerDaysSeries }; + Series = [salesPerDaysSeries]; } - public ISeries[] Series { get; set; } - private void OnPointerDown(IChartView chart, ChartPoint? point) { if (point?.Visual is null) return; diff --git a/samples/ViewModelsSamples/Events/Pie/ViewModel.cs b/samples/ViewModelsSamples/Events/Pie/ViewModel.cs index af8f51642..36aa70cd7 100644 --- a/samples/ViewModelsSamples/Events/Pie/ViewModel.cs +++ b/samples/ViewModelsSamples/Events/Pie/ViewModel.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Kernel; @@ -11,8 +10,10 @@ namespace ViewModelsSamples.Events.Pie; -public partial class ViewModel : ObservableObject +public partial class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { var data = new[] @@ -25,7 +26,7 @@ public ViewModel() new City { Name = "Guadalajara", Population = 4 } }; - // the parameter in the AsLiveChartsSeries() function is optional + // the parameter in the AsPieSeries() function is optional // and is useful to customize each series // it is a function that takes the city and the series assigned to the city as parameters var seriesCollection = data.AsPieSeries( @@ -38,11 +39,9 @@ public ViewModel() series.DataPointerDown += Series_DataPointerDown; }); - Series = seriesCollection.ToArray(); + Series = [.. seriesCollection]; } - public ISeries[] Series { get; set; } - private void Series_DataPointerDown( IChartView chart, IEnumerable> points) diff --git a/samples/ViewModelsSamples/Events/Polar/ViewModel.cs b/samples/ViewModelsSamples/Events/Polar/ViewModel.cs index 8e7a2a4b3..b89678ab4 100644 --- a/samples/ViewModelsSamples/Events/Polar/ViewModel.cs +++ b/samples/ViewModelsSamples/Events/Polar/ViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Diagnostics; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Kernel; @@ -8,7 +7,7 @@ namespace ViewModelsSamples.Events.Polar; -public partial class ViewModel : ObservableObject +public partial class ViewModel { public ViewModel() { @@ -31,11 +30,11 @@ public ViewModel() Mapping = (city, index) => new(index, city.Population) }; - Series = new ISeries[] - { + Series = + [ polarLineSeries, - new PolarLineSeries { Values = new[] { 6, 7, 2, 9, 6, 2 } }, - }; + new PolarLineSeries { Values = [6, 7, 2, 9, 6, 2] }, + ]; } public ISeries[] Series { get; set; } diff --git a/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs b/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs index 6660ab7db..a4da1a562 100644 --- a/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs +++ b/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs @@ -1,53 +1,39 @@ using System; using System.Linq; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Financial.BasicCandlesticks; -public partial class ViewModel : ObservableObject +public class ViewModel { + public Axis[] XAxes { get; set; } + + public ISeries[] Series { get; set; } + public ViewModel() { var data = new FinancialData[] { - new(new DateTime(2021, 1, 1), 523, 500, 450, 400), - new(new DateTime(2021, 1, 2), 500, 450, 425, 400), - new(new DateTime(2021, 1, 3), 490, 425, 400, 380), - new(new DateTime(2021, 1, 4), 420, 400, 420, 380), - new(new DateTime(2021, 1, 5), 520, 420, 490, 400), - new(new DateTime(2021, 1, 6), 580, 490, 560, 440), - new(new DateTime(2021, 1, 7), 570, 560, 350, 340), - new(new DateTime(2021, 1, 8), 380, 350, 380, 330), - new(new DateTime(2021, 1, 9), 440, 380, 420, 350), - new(new DateTime(2021, 1, 10), 490, 420, 460, 400), - new(new DateTime(2021, 1, 11), 520, 460, 510, 460), - new(new DateTime(2021, 1, 12), 580, 510, 560, 500), - new(new DateTime(2021, 1, 13), 600, 560, 540, 510), - new(new DateTime(2021, 1, 14), 580, 540, 520, 500), - new(new DateTime(2021, 1, 15), 580, 520, 560, 520), - new(new DateTime(2021, 1, 16), 590, 560, 580, 520), - new(new DateTime(2021, 1, 17), 650, 580, 630, 550), - new(new DateTime(2021, 1, 18), 680, 630, 650, 600), - new(new DateTime(2021, 1, 19), 670, 650, 600, 570), - new(new DateTime(2021, 1, 20), 640, 600, 610, 560), - new(new DateTime(2021, 1, 21), 630, 610, 630, 590) + new() { Date = new DateTime(2021, 1, 1), High = 523, Open = 500, Close = 450, Low = 400 }, + new() { Date = new DateTime(2021, 1, 2), High = 500, Open = 450, Close = 425, Low = 400 }, + new() { Date = new DateTime(2021, 1, 3), High = 490, Open = 425, Close = 400, Low = 380 }, + new() { Date = new DateTime(2021, 1, 4), High = 420, Open = 400, Close = 420, Low = 380 }, + new() { Date = new DateTime(2021, 1, 5), High = 520, Open = 420, Close = 490, Low = 400 }, + new() { Date = new DateTime(2021, 1, 6), High = 580, Open = 490, Close = 560, Low = 440 } }; - Series = new ISeries[] - { + Series = [ new CandlesticksSeries { Values = data .Select(x => new FinancialPointI(x.High, x.Open, x.Close, x.Low)) .ToArray() } - }; + ]; - XAxes = new[] - { + XAxes = [ new Axis { LabelsRotation = 15, @@ -55,19 +41,15 @@ public ViewModel() .Select(x => x.Date.ToString("yyyy MMM dd")) .ToArray() } - }; + ]; } - - public Axis[] XAxes { get; set; } - - public ISeries[] Series { get; set; } } -public class FinancialData(DateTime date, double high, double open, double close, double low) +public class FinancialData { - public DateTime Date { get; set; } = date; - public double High { get; set; } = high; - public double Open { get; set; } = open; - public double Close { get; set; } = close; - public double Low { get; set; } = low; + public DateTime Date { get; set; } + public double High { get; set; } + public double Open { get; set; } + public double Close { get; set; } + public double Low { get; set; } } diff --git a/samples/ViewModelsSamples/General/Animations/ViewModel.cs b/samples/ViewModelsSamples/General/Animations/ViewModel.cs index 907547d17..0cde8d5d1 100644 --- a/samples/ViewModelsSamples/General/Animations/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Animations/ViewModel.cs @@ -17,10 +17,10 @@ public ViewModel() } public ISeries[] Series { get; set; } = - { new ColumnSeries { Values = new[] { 5, 6, 3, 1, 8, 5, 3, 5, 6, 3, 1 } } }; + [new ColumnSeries { Values = [5, 6, 3, 1, 8, 5, 3, 5, 6, 3, 1] }]; - public (string, Func)[] AvalaibaleCurves => new (string, Func)[] - { + public (string, Func)[] AvalaibaleCurves => + [ // LiveCharts already contains many common animating curves in the EasingFunctions static class. ("Back in", EasingFunctions.BackIn), ("Back out", EasingFunctions.BackOut), @@ -63,16 +63,16 @@ public ViewModel() // and also based on cubic bezier curves that are common in web development // you can build and play with custom cubic bezier curves at https://cubic-bezier.com/#.17,.67,.83,.67 ("custom cubic bezier", EasingFunctions.BuildCubicBezier(0.17f, 0.67f, 0.83f, 0.67f)), - }; + ]; - public (string, TimeSpan)[] AvailableSpeeds => new (string, TimeSpan)[] - { + public (string, TimeSpan)[] AvailableSpeeds => + [ ("Slowest", TimeSpan.FromMilliseconds(1300)), ("Slow", TimeSpan.FromMilliseconds(800)), ("Medium", TimeSpan.FromMilliseconds(500)), ("Fast", TimeSpan.FromMilliseconds(300)), ("Fastest", TimeSpan.FromMilliseconds(100)), - }; + ]; public (string, Func) SelectedCurve { diff --git a/samples/ViewModelsSamples/General/ChartToImage/ViewModel.cs b/samples/ViewModelsSamples/General/ChartToImage/ViewModel.cs index 3773eb2a8..4c2153bcb 100644 --- a/samples/ViewModelsSamples/General/ChartToImage/ViewModel.cs +++ b/samples/ViewModelsSamples/General/ChartToImage/ViewModel.cs @@ -1,32 +1,26 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Geo; using LiveChartsCore.SkiaSharpView; -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace ViewModelsSamples.General.ChartToImage; -public partial class ViewModel : ObservableObject +public partial class ViewModel { - public ISeries[] CatesianSeries { get; set; } = - { - new LineSeries { Values = new int[] { 1, 5, 4, 6 } }, - new ColumnSeries { Values = new int[] { 4, 8, 2, 4 } } - }; + public ISeries[] CatesianSeries { get; set; } = [ + new LineSeries { Values = [1, 5, 4, 6] }, + new ColumnSeries { Values = [4, 8, 2, 4] } + ]; - public ISeries[] PieSeries { get; set; } = - { - new PieSeries { Values = new int[] { 10, } }, - new PieSeries { Values = new int[] { 6 } }, - new PieSeries { Values = new int[] { 4 } } - }; + public ISeries[] PieSeries { get; set; } = [ + new PieSeries { Values = [10,] }, + new PieSeries { Values = [6] }, + new PieSeries { Values = [4] } + ]; - public IGeoSeries[] GeoSeries { get; set; } = new HeatLandSeries[] - { - new() + public IGeoSeries[] GeoSeries { get; set; } = [ + new HeatLandSeries { - Lands = new HeatLand[] - { + Lands = [ new() { Name = "bra", Value = 13 }, new() { Name = "mex", Value = 10 }, new() { Name = "usa", Value = 15 }, @@ -41,7 +35,7 @@ public partial class ViewModel : ObservableObject new() { Name = "kor", Value = 10 }, new() { Name = "zaf", Value = 12 }, new() { Name = "are", Value = 13 } - } + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs b/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs index b8cd03d99..4abc25dc5 100644 --- a/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs +++ b/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs @@ -1,17 +1,17 @@ using System; using System.Collections.ObjectModel; using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.ConditionalDraw; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; +using LiveChartsCore.Kernel.Sketches; namespace ViewModelsSamples.General.ConditionalDraw; -public partial class ViewModel : ObservableObject +public class ViewModel { private readonly ObservableCollection _values = []; @@ -19,9 +19,10 @@ public ViewModel() { var dangerPaint = new SolidColorPaint(SKColors.Red); - _values = - [ - new(2), new(5), new(4), new(6), new(8), new(3), new(2), new(4), new(6) + _values = [ + new(2), + new(8), + new(4) ]; var series = new ColumnSeries @@ -40,15 +41,14 @@ public ViewModel() : null; // when null, the series fill is used // mark }); - Series = new ISeries[] { series }; + Series = [series]; Randomize(); } public ISeries[] Series { get; set; } - public RectangularSection[] Sections { get; set; } = - { + public RectangularSection[] Sections { get; set; } = [ new RectangularSection { Label = "Danger zone!", @@ -60,12 +60,11 @@ public ViewModel() Yj = 5, Fill = new SolidColorPaint(SKColors.Red.WithAlpha(50)) } - }; + ]; - public Axis[] Y { get; set; } = - { + public ICartesianAxis[] Y { get; set; } = [ new Axis { MinLimit = 0 } - }; + ]; private async void Randomize() { diff --git a/samples/ViewModelsSamples/General/MapPoints/ViewModel.cs b/samples/ViewModelsSamples/General/MapPoints/ViewModel.cs index b1b00dd9e..b433b4cc0 100644 --- a/samples/ViewModelsSamples/General/MapPoints/ViewModel.cs +++ b/samples/ViewModelsSamples/General/MapPoints/ViewModel.cs @@ -1,15 +1,16 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.ConditionalDraw; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.General.MapPoints; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { var paints = new SolidColorPaint[] @@ -22,7 +23,7 @@ public ViewModel() var series = new ColumnSeries { - Values = new[] { 2, 5, 4, 6, 8, 3, 2, 4, 6 }, + Values = [2, 5, 4, 6, 8, 3, 2, 4, 6], DataLabelsPaint = new SolidColorPaint(new SKColor(30, 30, 30)), DataLabelsPosition = DataLabelsPosition.Top } @@ -39,8 +40,6 @@ public ViewModel() point.Visual.Fill = paint; }); - Series = new ISeries[] { series }; + Series = [series]; } - - public ISeries[] Series { get; set; } } diff --git a/samples/ViewModelsSamples/General/MultiThreading/ViewModel.cs b/samples/ViewModelsSamples/General/MultiThreading/ViewModel.cs index 21332b817..624d14024 100644 --- a/samples/ViewModelsSamples/General/MultiThreading/ViewModel.cs +++ b/samples/ViewModelsSamples/General/MultiThreading/ViewModel.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using System.Threading; using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; @@ -11,13 +10,19 @@ namespace ViewModelsSamples.General.MultiThreading; -public partial class ViewModel : ObservableObject +public class ViewModel { private readonly Random _r = new(); private readonly int _delay = 100; private readonly ObservableCollection _values; private int _current; + public ISeries[] Series { get; set; } + + public object Sync { get; } = new object(); + + public bool IsReading { get; set; } = true; + public ViewModel() { // lets create some initial data. // mark @@ -31,8 +36,7 @@ public ViewModel() _values = new ObservableCollection(items); // create a series with the data // mark - Series = new ISeries[] - { + Series = [ new LineSeries { Values = _values, @@ -41,7 +45,7 @@ public ViewModel() LineSmoothness = 0, Stroke = new SolidColorPaint(SKColors.Blue, 1) } - }; + ]; _delay = 1; var readTasks = 10; @@ -55,12 +59,6 @@ public ViewModel() } } - public ISeries[] Series { get; set; } - - public object Sync { get; } = new object(); - - public bool IsReading { get; set; } = true; - private async Task ReadData() { await Task.Delay(1000); diff --git a/samples/ViewModelsSamples/General/MultiThreading2/ViewModel.cs b/samples/ViewModelsSamples/General/MultiThreading2/ViewModel.cs index cc4bf39a7..3861c2459 100644 --- a/samples/ViewModelsSamples/General/MultiThreading2/ViewModel.cs +++ b/samples/ViewModelsSamples/General/MultiThreading2/ViewModel.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; @@ -10,15 +9,19 @@ namespace ViewModelsSamples.General.MultiThreading2; -public partial class ViewModel : ObservableObject +public class ViewModel { private readonly Random _r = new(); private readonly int _delay = 100; private readonly ObservableCollection _values; private static int s_current; - private readonly Action _uiThreadInvoker; + private readonly Action _dispatcherService; - public ViewModel(Action uiThreadInvoker) + public ISeries[] Series { get; set; } + + public bool IsReading { get; set; } = true; + + public ViewModel(Action dispatcherService) { // lets create some initial data. // mark var items = new List(); @@ -31,8 +34,7 @@ public ViewModel(Action uiThreadInvoker) _values = new ObservableCollection(items); // create a series with the data // mark - Series = new ISeries[] - { + Series = [ new LineSeries { Values = _values, @@ -41,11 +43,11 @@ public ViewModel(Action uiThreadInvoker) LineSmoothness = 0, Stroke = new SolidColorPaint(SKColors.Blue, 1) } - }; + ]; // There are simplier ways to do this, but since we are using a MVVM pattern, // mark - // we need to inject a delegate that will run an action in the UI thread. // mark - _uiThreadInvoker = uiThreadInvoker; + // we need to inject a delegate that will run an action on the UI thread. // mark + _dispatcherService = dispatcherService; _delay = 1; var readTasks = 10; @@ -58,10 +60,6 @@ public ViewModel(Action uiThreadInvoker) } } - public ISeries[] Series { get; set; } - - public bool IsReading { get; set; } = true; - public async Task ReadData() { await Task.Delay(1000); @@ -74,7 +72,7 @@ public async Task ReadData() await Task.Delay(_delay); // force the change to happen in the UI thread. // mark - _uiThreadInvoker(() => + _dispatcherService(() => { s_current += _r.Next(-9, 10); _values.Add(s_current); diff --git a/samples/ViewModelsSamples/General/NullPoints/ViewModel.cs b/samples/ViewModelsSamples/General/NullPoints/ViewModel.cs index fc146b10b..dfaf296ab 100644 --- a/samples/ViewModelsSamples/General/NullPoints/ViewModel.cs +++ b/samples/ViewModelsSamples/General/NullPoints/ViewModel.cs @@ -1,35 +1,30 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.General.NullPoints; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = new ISeries[] - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new double?[] { 5, 4, null, 3, 2, 6, 5, 6, 2 } + Values = [5, 4, null, 3, 2, 6, 5, 6, 2] }, - new LineSeries { - Values = new double?[] { 2, 6, 5, 3, null, 5, 2, 4, null } + Values = [2, 6, 5, 3, null, 5, 2, 4, null] }, - new LineSeries { - Values = new ObservablePoint?[] - { + Values = [ new ObservablePoint { X = 0, Y = 1 }, new ObservablePoint { X = 1, Y = 4 }, null, new ObservablePoint { X = 4, Y = 5 }, new ObservablePoint { X = 6, Y = 1 }, new ObservablePoint { X = 8, Y = 6 }, - } + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/RealTime/ViewModel.cs b/samples/ViewModelsSamples/General/RealTime/ViewModel.cs index 3f411faf4..6939a6464 100644 --- a/samples/ViewModelsSamples/General/RealTime/ViewModel.cs +++ b/samples/ViewModelsSamples/General/RealTime/ViewModel.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; @@ -11,16 +10,23 @@ namespace ViewModelsSamples.General.RealTime; -public partial class ViewModel : ObservableObject +public class ViewModel { private readonly Random _random = new(); private readonly List _values = []; private readonly DateTimeAxis _customAxis; + public ObservableCollection Series { get; set; } + + public Axis[] XAxes { get; set; } + + public object Sync { get; } = new object(); + + public bool IsReading { get; set; } = true; + public ViewModel() { - Series = - [ + Series = [ new LineSeries { Values = _values, @@ -37,19 +43,11 @@ public ViewModel() SeparatorsPaint = new SolidColorPaint(SKColors.Black.WithAlpha(100)) }; - XAxes = new Axis[] { _customAxis }; + XAxes = [_customAxis]; _ = ReadData(); } - public ObservableCollection Series { get; set; } - - public Axis[] XAxes { get; set; } - - public object Sync { get; } = new object(); - - public bool IsReading { get; set; } = true; - private async Task ReadData() { // to keep this sample simple, we run the next infinite loop // mark @@ -61,7 +59,7 @@ private async Task ReadData() // Because we are updating the chart from a different thread // mark // we need to use a lock to access the chart data. // mark - // this is not necessary if your changes are made in the UI thread. // mark + // this is not necessary if your changes are made on the UI thread. // mark lock (Sync) { _values.Add(new DateTimePoint(DateTime.Now, _random.Next(0, 10))); @@ -73,19 +71,19 @@ private async Task ReadData() } } - private double[] GetSeparators() + private static double[] GetSeparators() { var now = DateTime.Now; - return new double[] - { + return + [ now.AddSeconds(-25).Ticks, now.AddSeconds(-20).Ticks, now.AddSeconds(-15).Ticks, now.AddSeconds(-10).Ticks, now.AddSeconds(-5).Ticks, now.Ticks - }; + ]; } private static string Formatter(DateTime date) diff --git a/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs b/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs index e48552f83..140f12111 100644 --- a/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs @@ -18,18 +18,23 @@ public partial class ViewModel private bool _isDown = false; private readonly ObservableCollection _values = []; + public ISeries[] Series { get; set; } + public Axis[] ScrollableAxes { get; set; } + public ISeries[] ScrollbarSeries { get; set; } + public Axis[] InvisibleX { get; set; } + public Axis[] InvisibleY { get; set; } + public LiveChartsCore.Measure.Margin Margin { get; set; } + public RectangularSection[] Thumbs { get; set; } + public ViewModel() { var trend = 1000; var r = new Random(); for (var i = 0; i < 500; i++) - { _values.Add(new ObservablePoint(i, trend += r.Next(-20, 20))); - } - Series = new ISeries[] - { + Series = [ new LineSeries { Values = _values, @@ -37,10 +42,9 @@ public ViewModel() GeometryFill = null, DataPadding = new(0, 1) } - }; + ]; - ScrollbarSeries = new ISeries[] - { + ScrollbarSeries = [ new LineSeries { Values = _values, @@ -48,20 +52,19 @@ public ViewModel() GeometryFill = null, DataPadding = new(0, 1) } - }; + ]; - ScrollableAxes = new[] { new Axis() }; + ScrollableAxes = [new Axis()]; - Thumbs = new[] - { + Thumbs = [ new RectangularSection { Fill = new SolidColorPaint(new SKColor(255, 205, 210, 100)) } - }; + ]; - InvisibleX = new[] { new Axis { IsVisible = false } }; - InvisibleY = new[] { new Axis { IsVisible = false } }; + InvisibleX = [new Axis { IsVisible = false }]; + InvisibleY = [new Axis { IsVisible = false }]; // force the left margin to be 100 and the right margin 50 in both charts, this will // align the start and end point of the "draw margin", @@ -70,14 +73,6 @@ public ViewModel() Margin = new(100, auto, 50, auto); } - public ISeries[] Series { get; set; } - public Axis[] ScrollableAxes { get; set; } - public ISeries[] ScrollbarSeries { get; set; } - public Axis[] InvisibleX { get; set; } - public Axis[] InvisibleY { get; set; } - public LiveChartsCore.Measure.Margin Margin { get; set; } - public RectangularSection[] Thumbs { get; set; } - [RelayCommand] public void ChartUpdated(ChartCommandArgs args) { diff --git a/samples/ViewModelsSamples/General/Sections/ViewModel.cs b/samples/ViewModelsSamples/General/Sections/ViewModel.cs index 74d1082da..00711a8b6 100644 --- a/samples/ViewModelsSamples/General/Sections/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Sections/ViewModel.cs @@ -1,17 +1,16 @@ using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.Input; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; namespace ViewModelsSamples.General.Sections; public partial class ViewModel { - public RectangularSection[] Sections { get; set; } = - { + public RectangularSection[] Sections { get; set; } = [ new RectangularSection { // creates a section from 3 to 4 in the X axis @@ -40,10 +39,9 @@ public partial class ViewModel LabelSize = 14, LabelPaint = new SolidColorPaint(new SKColor(255, 111, 0)) } - }; + ]; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ScatterSeries { Values = new ObservableCollection @@ -52,31 +50,13 @@ public partial class ViewModel new(4.5, 2.5), new(4.2, 7.4), new(6.4, 9.9), - new(4.2, 9.2), - new(5.8, 3.5), - new(7.3, 5.8), new(8.9, 3.9), - new(6.1, 4.6), - new(9.4, 7.7), - new(8.4, 8.5), - new(3.6, 9.6), - new(4.4, 6.3), - new(5.8, 4.8), - new(6.9, 3.4), - new(7.6, 1.8), - new(8.3, 8.3), - new(9.9, 5.2), - new(8.1, 4.7), - new(7.4, 3.9), - new(6.8, 2.3), - new(5.3, 7.1), + new(9.9, 5.2) } } - }; + ]; [RelayCommand] - public void ToggleFirst() - { + public void ToggleFirst() => Sections[0].IsVisible = !Sections[0].IsVisible; - } } diff --git a/samples/ViewModelsSamples/General/Sections2/ViewModel.cs b/samples/ViewModelsSamples/General/Sections2/ViewModel.cs index 2a7850d90..1a9d8845c 100644 --- a/samples/ViewModelsSamples/General/Sections2/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Sections2/ViewModel.cs @@ -1,17 +1,15 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using SkiaSharp; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using LiveChartsCore.SkiaSharpView.Painting.Effects; -using SkiaSharp; namespace ViewModelsSamples.General.Sections2; -public partial class ViewModel : ObservableObject +public class ViewModel { - public RectangularSection[] Sections { get; set; } = - { + public RectangularSection[] Sections { get; set; } = [ new RectangularSection { Yi = 8, @@ -20,7 +18,7 @@ public partial class ViewModel : ObservableObject { Color = SKColors.Red, StrokeThickness = 3, - PathEffect = new DashEffect(new float[] { 6, 6 }) + PathEffect = new DashEffect([6, 6]) } }, new RectangularSection @@ -29,17 +27,16 @@ public partial class ViewModel : ObservableObject Xj = 6, Fill = new SolidColorPaint { Color = SKColors.Blue.WithAlpha(20) } }, - }; + ]; - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ScatterSeries { GeometrySize = 10, Stroke = new SolidColorPaint { Color = SKColors.Blue, StrokeThickness = 1 }, Fill = null, - Values = new ObservablePoint[] - { + Values = + [ new(2.2, 5.4), new(4.5, 2.5), new(4.2, 7.4), new(6.4, 9.9), new(4.2, 9.2), new(5.8, 3.5), new(7.3, 5.8), new(8.9, 3.9), new(6.1, 4.6), @@ -47,7 +44,7 @@ public partial class ViewModel : ObservableObject new(4.4, 6.3), new(5.8, 4.8), new(6.9, 3.4), new(7.6, 1.8), new(8.3, 8.3), new(9.9, 5.2), new(8.1, 4.7), new(7.4, 3.9), new(6.8, 2.3) - } + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/TemplatedLegends/CustomLegend.cs b/samples/ViewModelsSamples/General/TemplatedLegends/CustomLegend.cs index 498eaeb27..48d177ad0 100644 --- a/samples/ViewModelsSamples/General/TemplatedLegends/CustomLegend.cs +++ b/samples/ViewModelsSamples/General/TemplatedLegends/CustomLegend.cs @@ -70,6 +70,7 @@ public LvcSize Measure(Chart chart) ZIndex = s_zIndex + 1 } }, + // series.GetMiniature(null, s_zIndex), or get the miniature defined in the series. new LabelVisual { Text = series.Name ?? string.Empty, diff --git a/samples/ViewModelsSamples/General/TemplatedLegends/ViewModel.cs b/samples/ViewModelsSamples/General/TemplatedLegends/ViewModel.cs index d6488cad0..bee51fa55 100644 --- a/samples/ViewModelsSamples/General/TemplatedLegends/ViewModel.cs +++ b/samples/ViewModelsSamples/General/TemplatedLegends/ViewModel.cs @@ -1,18 +1,15 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.General.TemplatedLegends; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { Name = "Roger", - Values = new ObservableCollection { 2, 1, 3, 5, 3, 4, 6 } + Values = [2, 1, 3, 5, 3, 4, 6] } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs b/samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs index fb499d8f6..7d98449fb 100644 --- a/samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs +++ b/samples/ViewModelsSamples/General/TemplatedTooltips/CustomTooltip.cs @@ -50,8 +50,7 @@ public void Show(IEnumerable foundPoints, Chart)point.Context.Series).GetMiniaturesSketch(); - var relativePanel = sketch.AsDrawnControl(s_zIndex); + var skiaSeries = (IChartSeries)point.Context.Series; var label = new LabelVisual { @@ -71,12 +70,12 @@ public void Show(IEnumerable foundPoints, Chart { - Values = new ObservableCollection { 3, 7, 3, 1, 4, 5, 6 }, + Values = [3, 7, 3, 1, 4, 5, 6 ], }, new LineSeries { - Values = new ObservableCollection { 2, 1, 3, 5, 3, 4, 6 }, + Values = [2, 1, 3, 5, 3, 4, 6 ], Fill = null } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/UserDefinedTypes/ViewModel.cs b/samples/ViewModelsSamples/General/UserDefinedTypes/ViewModel.cs index 895c39849..aa791cf21 100644 --- a/samples/ViewModelsSamples/General/UserDefinedTypes/ViewModel.cs +++ b/samples/ViewModelsSamples/General/UserDefinedTypes/ViewModel.cs @@ -1,28 +1,25 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.General.UserDefinedTypes; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { Name = "Population", // use the Population property as the Y coordinate // and the index of the city in our collection as the X coordinate Mapping = (city, index) => new(index, city.Population), - Values = new[] - { + Values = [ new City { Name = "Tokyo", Population = 4 }, new City { Name = "New York", Population = 6 }, new City { Name = "Seoul", Population = 2 }, new City { Name = "Moscow", Population = 8 }, new City { Name = "Shanghai", Population = 3 }, new City { Name = "Guadalajara", Population = 4 } - } + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/General/Visibility/ViewModel.cs b/samples/ViewModelsSamples/General/Visibility/ViewModel.cs index a33b3e053..b3816f774 100644 --- a/samples/ViewModelsSamples/General/Visibility/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Visibility/ViewModel.cs @@ -1,47 +1,38 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.General.Visibility; -public partial class ViewModel : ObservableObject +public partial class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ColumnSeries { - Values = new ObservableCollection { 2, 5, 4, 3 }, + Values = [2, 5, 4, 3], IsVisible = true }, new ColumnSeries { - Values = new ObservableCollection { 6, 3, 2, 8 }, + Values = [6, 3, 2, 8], IsVisible = true }, new ColumnSeries { - Values = new ObservableCollection { 4, 2, 8, 7 }, + Values = [4, 2, 8, 7], IsVisible = true } - }; + ]; [RelayCommand] - public void ToggleSeries0() - { + public void ToggleSeries0() => Series[0].IsVisible = !Series[0].IsVisible; - } [RelayCommand] - public void ToggleSeries1() - { + public void ToggleSeries1() => Series[1].IsVisible = !Series[1].IsVisible; - } [RelayCommand] - public void ToggleSeries2() - { + public void ToggleSeries2() => Series[2].IsVisible = !Series[2].IsVisible; - } } diff --git a/samples/ViewModelsSamples/General/VisualElements/ViewModel.cs b/samples/ViewModelsSamples/General/VisualElements/ViewModel.cs index fb31cf7cb..a22ec7531 100644 --- a/samples/ViewModelsSamples/General/VisualElements/ViewModel.cs +++ b/samples/ViewModelsSamples/General/VisualElements/ViewModel.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; @@ -15,8 +14,12 @@ namespace ViewModelsSamples.General.VisualElements; -public partial class ViewModel : ObservableObject +public class ViewModel { + public IEnumerable> VisualElements { get; set; } + + public ISeries[] Series { get; set; } + public ViewModel() { var visuals = new List>(); @@ -72,20 +75,15 @@ public ViewModel() visuals.Add(svgVisiual); VisualElements = visuals; - Series = new ISeries[] - { + Series = [ new LineSeries { GeometrySize = 13, - Values = new int[] { 2, 2, 3, 4, 2, 2, 3, 6, 3, 5, 2, 1, 4, 5, 2, 3, 2, 4, 5, 3, 2, 6 } + Values = [2, 2, 3, 4, 2, 2, 3, 6, 3, 5, 2, 1, 4, 5, 2, 3, 2, 4, 5, 3, 2, 6] } - }; + ]; } - public IEnumerable> VisualElements { get; set; } - - public ISeries[] Series { get; set; } - private void RectanglePointerDown( VisualElement visual, VisualElementEventArgs visualElementsArgs) diff --git a/samples/ViewModelsSamples/Heat/Basic/ViewModel.cs b/samples/ViewModelsSamples/Heat/Basic/ViewModel.cs index e61fcc7aa..b70e88cdf 100644 --- a/samples/ViewModelsSamples/Heat/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Heat/Basic/ViewModel.cs @@ -1,26 +1,22 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Defaults; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; using SkiaSharp; namespace ViewModelsSamples.Heat.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new HeatSeries { - HeatMap = new[] - { + HeatMap = [ new SKColor(255, 241, 118).AsLvcColor(), // the first element is the "coldest" SKColors.DarkSlateGray.AsLvcColor(), SKColors.Blue.AsLvcColor() // the last element is the "hottest" - }, - Values = new ObservableCollection - { + ], + Values = [ // Charles new(0, 0, 150), // Jan new(0, 1, 123), // Feb @@ -52,23 +48,21 @@ public partial class ViewModel : ObservableObject new(3, 3, 123), // Apr new(3, 4, 432), // May new(3, 5, 142), // Jun - }, + ] } - }; + ]; - public Axis[] XAxes { get; set; } = - { + public ICartesianAxis[] XAxes { get; set; } = [ new Axis { - Labels = new[] { "Charles", "Richard", "Ana", "Mari" } + Labels = ["Charles", "Richard", "Ana", "Mari"] } - }; + ]; - public Axis[] YAxes { get; set; } = - { + public ICartesianAxis[] YAxes { get; set; } = [ new Axis { - Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" } + Labels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] } - }; + ]; } diff --git a/samples/ViewModelsSamples/Index.cs b/samples/ViewModelsSamples/Index.cs index a969557ee..6246438a9 100644 --- a/samples/ViewModelsSamples/Index.cs +++ b/samples/ViewModelsSamples/Index.cs @@ -3,7 +3,7 @@ public static class Index { public static string[] Samples = - { + [ "Design/LinearGradients", "Design/RadialGradients", @@ -13,20 +13,11 @@ public static class Index "Lines/Properties", "Lines/Area", "Lines/Custom", + "Lines/CustomPoints", "Lines/Padding", "Lines/XY", "Lines/Zoom", - "StepLines/Basic", - "StepLines/AutoUpdate", - "StepLines/Properties", - "StepLines/Area", - "StepLines/Custom", - "StepLines/Zoom", - - "StackedArea/Basic", - "StackedArea/StepArea", - "Bars/Basic", "Bars/AutoUpdate", "Bars/Custom", @@ -37,15 +28,13 @@ public static class Index "Bars/RowsWithLabels", "Bars/Layered", - "StackedBars/Basic", - "StackedBars/Groups", - "Pies/Basic", "Pies/AutoUpdate", //"Pies/Processing", "Pies/Doughnut", "Pies/Pushout", "Pies/Custom", + "Pies/Icons", "Pies/OutLabels", "Pies/NightingaleRose", "Pies/Gauges", @@ -62,6 +51,12 @@ public static class Index "Scatter/AutoUpdate", "Scatter/Custom", + "StackedArea/Basic", + "StackedArea/StepArea", + + "StackedBars/Basic", + "StackedBars/Groups", + "Financial/BasicCandlesticks", "Error/Basic", @@ -70,6 +65,13 @@ public static class Index "Heat/Basic", + "StepLines/Basic", + "StepLines/AutoUpdate", + "StepLines/Properties", + "StepLines/Area", + "StepLines/Custom", + "StepLines/Zoom", + "Polar/Basic", "Polar/RadialArea", "Polar/Coordinates", @@ -124,5 +126,5 @@ public static class Index "Test/MotionCanvasDispose", "Maps/World" - }; + ]; } diff --git a/samples/ViewModelsSamples/Lines/Area/ViewModel.cs b/samples/ViewModelsSamples/Lines/Area/ViewModel.cs index efe53a7e3..077f30aba 100644 --- a/samples/ViewModelsSamples/Lines/Area/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Area/ViewModel.cs @@ -1,18 +1,16 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; namespace ViewModelsSamples.Lines.Area; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - Values = new double[] { -2, -1, 3, 5, 3, 4, 6 }, + Values = [-2, -1, 3, 5, 3, 4, 6], // Set he Fill property to build an area series // by default the series has a fill color based on your app theme Fill = new SolidColorPaint(SKColors.CornflowerBlue), // mark @@ -21,7 +19,7 @@ public partial class ViewModel : ObservableObject GeometryFill = null, GeometryStroke = null } - }; + ]; // Creates a gray background and border in the draw margin. public DrawMarginFrame DrawMarginFrame => new() diff --git a/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs index 3bb7e5786..f431b3b4c 100644 --- a/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel; -using CommunityToolkit.Mvvm.ComponentModel; +using System.Linq; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Defaults; @@ -10,101 +8,88 @@ namespace ViewModelsSamples.Lines.AutoUpdate; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private readonly Random _random = new(); - private readonly ObservableCollection _observableValues; + + // We use the ObservableCollection class to let the chart know // mark + // when a new item is added or removed from the chart. // mark + public ObservableCollection Series { get; set; } + + // The ObservablePoints property is an ObservableCollection of ObservableValue // mark + // it means that the chart is listening for changes in this collection // mark + // and also for changes in the properties of each element in the collection // mark + public ObservableCollection ObservableValues { get; set; } public ViewModel() { - // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = - [ - // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark - // or use any INotifyPropertyChanged implementation // mark - new ObservableValue(2), - new(5), // the ObservableValue type is redundant and inferred by the compiler (C# 9 and above) - new(4), - new(5), - new(2), - new(6), - new(6), - new(6), - new(4), - new(2), - new(3), - new(4), - new(3) + ObservableValues = [ + new() { Value = 2 }, + new() { Value = 5 }, + new() { Value = 4 } ]; - Series = - [ - new LineSeries - { - Values = _observableValues, - Fill = null - } + Series = [ + new LineSeries(ObservableValues) ]; - - // in the following sample notice that the type int does not implement INotifyPropertyChanged - // and our Series.Values property is of type List - // List does not implement INotifyCollectionChanged - // this means the following series is not listening for changes. - // Series.Add(new ColumnSeries { Values = new List { 2, 4, 6, 1, 7, -2 } }); // mark } - public ObservableCollection Series { get; set; } - [RelayCommand] public void AddItem() { var randomValue = _random.Next(1, 10); - _observableValues.Add(new(randomValue)); + + // the new value is added to the collection // mark + // the chart is listening, and will update and animate the change // mark + + ObservableValues.Add(new() { Value = randomValue }); } [RelayCommand] public void RemoveItem() { - if (_observableValues.Count == 0) return; - _observableValues.RemoveAt(0); + if (ObservableValues.Count == 0) return; + + // the last value is removed from the collection // mark + // the chart is listening, and will update and animate the change // mark + + ObservableValues.RemoveAt(0); } [RelayCommand] public void UpdateItem() { var randomValue = _random.Next(1, 10); + var lastItem = ObservableValues[ObservableValues.Count - 1]; - // we grab the last instance in our collection - var lastInstance = _observableValues[_observableValues.Count - 1]; + // becase lastItem is an ObservableObject and implements INotifyPropertyChanged // mark + // the chart is listening for changes in the Value property // mark + // and will update and animate the change // mark - // finally modify the value property and the chart is updated! - lastInstance.Value = randomValue; + lastItem.Value = randomValue; } [RelayCommand] public void ReplaceItem() { var randomValue = _random.Next(1, 10); - var randomIndex = _random.Next(0, _observableValues.Count - 1); - _observableValues[randomIndex] = new(randomValue); + var randomIndex = _random.Next(0, ObservableValues.Count - 1); + + // replacing and item also triggers the chart to update and animate the change // mark + + ObservableValues[randomIndex] = new(randomValue); } [RelayCommand] public void AddSeries() { - // for this sample only 5 series are supported. - if (Series.Count == 5) return; - - Series.Add( - new LineSeries - { - Values = new List - { - _random.Next(0, 10), - _random.Next(0, 10), - _random.Next(0, 10) - } - }); + var values = Enumerable.Range(0, 3) + .Select(_ => _random.Next(0, 10)) + .ToArray(); + + // a new line series is added to the chart // mark + + Series.Add(new LineSeries(values)); } [RelayCommand] @@ -112,6 +97,12 @@ public void RemoveSeries() { if (Series.Count == 1) return; + // the last series is removed from the chart // mark + Series.RemoveAt(Series.Count - 1); } } + +// All LiveCharts objects (Series, Axes, etc) implement INotifyPropertyChanged // mark +// this means that the chart is listening for changes in the properties // mark +// the chart will reflect the changes and animate them // mark diff --git a/samples/ViewModelsSamples/Lines/Basic/ViewModel.cs b/samples/ViewModelsSamples/Lines/Basic/ViewModel.cs index 0f72dc28c..a6f7fd748 100644 --- a/samples/ViewModelsSamples/Lines/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Basic/ViewModel.cs @@ -1,29 +1,32 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; -using LiveChartsCore.SkiaSharpView.Painting; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.VisualElements; -using SkiaSharp; namespace ViewModelsSamples.Lines.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - Values = new double[] { 2, 1, 3, 5, 3, 4, 6 }, - Fill = null + Values = [2, 1, 3, 5, 3, 4, 6], + Fill = null, + GeometrySize = 20 + }, + new LineSeries + { + Values = [4, 2, 5, 2, 4, 5, 3], + Fill = null, + GeometrySize = 20, } - }; + ]; public LabelVisual Title { get; set; } = new LabelVisual { Text = "My chart title", TextSize = 25, - Padding = new LiveChartsCore.Drawing.Padding(15), - Paint = new SolidColorPaint(SKColors.DarkSlateGray) + Padding = new LiveChartsCore.Drawing.Padding(15) }; } diff --git a/samples/ViewModelsSamples/Lines/Custom/ViewModel.cs b/samples/ViewModelsSamples/Lines/Custom/ViewModel.cs index b44e4cb00..b98731ad5 100644 --- a/samples/ViewModelsSamples/Lines/Custom/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Custom/ViewModel.cs @@ -1,48 +1,47 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Drawing; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace ViewModelsSamples.Lines.Custom; -public partial class ViewModel : ObservableObject +public class ViewModel { public ISeries[] Series { get; set; } = - { + [ new LineSeries { - Values = new double[] { 2, 1, 4, 2, 2, -5, -2 }, + Values = [2, 1, 4, 2, 2, -5, -2], Fill = null, GeometrySize = 20 }, - // use the second type parameter to specify the geometry to draw for every point - // there are already many predefined geometries in the - // LiveChartsCore.SkiaSharpView.Drawing.Geometries namespace - new LineSeries + // use the second generic parameter to define the geometry to draw + // there are many predefined geometries in the LiveChartsCore.Drawing namespace + // for example, the StarGeometry, CrossGeometry, RectangleGeometry and DiamondGeometry + new LineSeries { - Values = new double[] { 3, 3, -3, -2, -4, -3, -1 }, + Values = [3, 3, -3, -2, -4, -3, -1], Fill = null, GeometrySize = 20 }, // You can also use SVG paths to draw the geometry - // LiveCharts already provides some predefined paths in the SVGPoints class. - new LineSeries + // the VariableSVGPathGeometry can change the drawn path at runtime + new LineSeries { - Values = new double[] { -2, 2, 1, 3, -1, 4, 3 }, + Values = [-2, 2, 1, 3, -1, 4, 3], Fill = null, - GeometrySvg = SVGPoints.Star, + GeometrySvg = SVGPoints.Pin, GeometrySize = 20 }, - // you can declare your own gemetry and use the SkiaSharp api to draw it + // finally you can also use SkiaSharp to draw your own geometry new LineSeries { - Values = new double[] { 4, 5, 2, 4, 3, 2, 1 }, + Values = [4, 5, 2, 4, 3, 2, 1], Fill = null, GeometrySize = 20 }, - }; + ]; } diff --git a/samples/ViewModelsSamples/Lines/CustomPoints/ViewModel.cs b/samples/ViewModelsSamples/Lines/CustomPoints/ViewModel.cs new file mode 100644 index 000000000..0ee19888b --- /dev/null +++ b/samples/ViewModelsSamples/Lines/CustomPoints/ViewModel.cs @@ -0,0 +1,76 @@ +using LiveChartsCore; +using LiveChartsCore.ConditionalDraw; +using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +using LiveChartsCore.SkiaSharpView.Painting; +using SkiaSharp; + +namespace ViewModelsSamples.Lines.CustomPoints; + +public class ViewModel +{ + public ISeries[] Series { get; } + + public ViewModel() + { + var lineSeries = new LineSeries(Fetch()); + + // we use the OnPointMeasured event to rotate the arrow // mark + // according to the Rotation property in the DataPoint class // mark + _ = lineSeries + .OnPointMeasured(point => + { + point.Visual!.TransformOrigin = new(0f, 0f); + point.Visual!.RotateTransform = point.Model!.Rotation; + }); + + lineSeries.GeometrySize = 50; + lineSeries.GeometryStroke = null; + lineSeries.GeometryFill = new SolidColorPaint(SKColors.MediumVioletRed); + lineSeries.Fill = null; + + // The Mapping property is used to map the data points to the series + // to learn more about the Mapping property visit: + // https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers + lineSeries.Mapping = (dataPoint, index) => new(index, dataPoint.Value); + + Series = [lineSeries]; + } + + public DataPoint[] Fetch() + { + return [ + new DataPoint { Value = 4, Rotation = 0 }, + new DataPoint { Value = 6, Rotation = 20 }, + new DataPoint { Value = 8, Rotation = 90 }, + new DataPoint { Value = 2, Rotation = 176 }, + new DataPoint { Value = 7, Rotation = 55 }, + new DataPoint { Value = 9, Rotation = 226 }, + new DataPoint { Value = 3, Rotation = 320 } + ]; + } +} + +public class DataPoint +{ + public int Value { get; set; } + public float Rotation { get; set; } +} + + +public class ArrowGeometry : BaseSVGPathGeometry +{ + // svg path from: + // https://www.svgrepo.com/svg/525637/arrow-up + + private static SKPath _path = SKPath.ParseSvgPathData( + "M12.75 20C12.75 20.4142 12.4142 20.75 12 20.75C11.5858 20.75 11.25 20.4142 11.25 " + + "20L11.25 10.75H6.00002C5.69668 10.75 5.4232 10.5673 5.30711 10.287C5.19103 10.0068 " + + "5.25519 9.68417 5.46969 9.46967L11.4697 3.46967C11.6103 3.32902 11.8011 3.25 12 " + + "3.25C12.1989 3.25 12.3897 3.32902 12.5304 3.46967L18.5304 9.46967C18.7449 9.68417 " + + "18.809 10.0068 18.6929 10.287C18.5768 10.5673 18.3034 10.75 18 10.75H12.75L12.75 20Z"); + + public ArrowGeometry() + : base(_path) + { } +} diff --git a/samples/ViewModelsSamples/Lines/Padding/ViewModel.cs b/samples/ViewModelsSamples/Lines/Padding/ViewModel.cs index 3a930322b..5754bf170 100644 --- a/samples/ViewModelsSamples/Lines/Padding/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Padding/ViewModel.cs @@ -1,5 +1,4 @@ using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Drawing; using LiveChartsCore.SkiaSharpView; @@ -8,10 +7,9 @@ namespace ViewModelsSamples.Lines.Padding; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ // this series fits the draw margin area // the key is to set the DataPadding to 0,0 // also remove GeometryStroke, GeometryFill and GeometrySize @@ -24,7 +22,7 @@ public partial class ViewModel : ObservableObject GeometrySize = 0, DataPadding = new LvcPoint(0,0) } - }; + ]; public DrawMarginFrame DrawMarginFrame => new() { diff --git a/samples/ViewModelsSamples/Lines/Properties/ViewModel.cs b/samples/ViewModelsSamples/Lines/Properties/ViewModel.cs index 5b5c3ce22..b7945ec66 100644 --- a/samples/ViewModelsSamples/Lines/Properties/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Properties/ViewModel.cs @@ -1,5 +1,4 @@ - -using System; +using System; using System.Collections.Generic; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -27,7 +26,7 @@ public ViewModel() LineSmoothness = 0.5 }; - _series = new ISeries[] { _lineSeries }; + _series = [_lineSeries]; } [ObservableProperty] @@ -56,7 +55,7 @@ public void ChangeSeriesInstance() LineSmoothness = 0.5 }; - Series = new ISeries[] { _lineSeries }; + Series = [_lineSeries]; } [RelayCommand] diff --git a/samples/ViewModelsSamples/Lines/Straight/ViewModel.cs b/samples/ViewModelsSamples/Lines/Straight/ViewModel.cs index 5a48d633c..79d7d2db7 100644 --- a/samples/ViewModelsSamples/Lines/Straight/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Straight/ViewModel.cs @@ -1,16 +1,14 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Lines.Straight; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - Values = new double[] { 5, 0, 5, 0, 5, 0 }, + Values = [5, 0, 5, 0, 5, 0], Fill = null, GeometrySize = 0, // use the line smoothness property to control the curve @@ -20,10 +18,10 @@ public partial class ViewModel : ObservableObject }, new LineSeries { - Values = new double[] { 7, 2, 7, 2, 7, 2 }, + Values = [7, 2, 7, 2, 7, 2], Fill = null, GeometrySize = 0, LineSmoothness = 1 // mark } - }; + ]; } diff --git a/samples/ViewModelsSamples/Lines/XY/ViewModel.cs b/samples/ViewModelsSamples/Lines/XY/ViewModel.cs index 551124902..a2400373c 100644 --- a/samples/ViewModelsSamples/Lines/XY/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/XY/ViewModel.cs @@ -1,24 +1,21 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Lines.XY; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new LineSeries { - Values = new ObservablePoint[] - { + Values = [ new ObservablePoint(0, 4), new ObservablePoint(1, 3), new ObservablePoint(3, 8), new ObservablePoint(18, 6), new ObservablePoint(20, 12) - } + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/Lines/Zoom/ViewModel.cs b/samples/ViewModelsSamples/Lines/Zoom/ViewModel.cs index b9a7fd608..286ef6e38 100644 --- a/samples/ViewModelsSamples/Lines/Zoom/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/Zoom/ViewModel.cs @@ -1,13 +1,16 @@ using System; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.Lines.Zoom; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ViewModel() + public ISeries[] SeriesCollection { get; set; } = [ + new LineSeries(Fetch()) + ]; + + private static int[] Fetch() { var values = new int[100]; var r = new Random(); @@ -19,8 +22,6 @@ public ViewModel() values[i] = t; } - SeriesCollection = new ISeries[] { new LineSeries { Values = values } }; + return values; } - - public ISeries[] SeriesCollection { get; set; } -} + } diff --git a/samples/ViewModelsSamples/Maps/World/ViewModel.cs b/samples/ViewModelsSamples/Maps/World/ViewModel.cs index fc892b2da..0c2232b4c 100644 --- a/samples/ViewModelsSamples/Maps/World/ViewModel.cs +++ b/samples/ViewModelsSamples/Maps/World/ViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore.Geo; using LiveChartsCore.SkiaSharpView; @@ -9,10 +8,10 @@ namespace ViewModelsSamples.Maps.World; -public partial class ViewModel +public partial class ViewModel { private bool _isBrazilInChart = true; - private readonly IWeigthedMapLand _brazil; + private readonly HeatLand _brazil; private readonly Random _r = new(); public ViewModel() @@ -39,7 +38,7 @@ public ViewModel() new() { Name = "are", Value = 13 } }; - Series = new HeatLandSeries[] { new HeatLandSeries { Lands = lands } }; + Series = [new HeatLandSeries { Lands = lands }]; _brazil = lands.First(x => x.Name == "bra"); DoRandomChanges(); @@ -60,7 +59,7 @@ public void ToggleBrazil() return; } - Series[0].Lands = lands.Concat(new[] { _brazil }).ToArray(); + Series[0].Lands = [.. lands, _brazil]; _isBrazilInChart = true; } diff --git a/samples/ViewModelsSamples/Pies/AngularGauge/ViewModel.cs b/samples/ViewModelsSamples/Pies/AngularGauge/ViewModel.cs index 85be2fdb4..439c2625b 100644 --- a/samples/ViewModelsSamples/Pies/AngularGauge/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/AngularGauge/ViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Extensions; using LiveChartsCore.VisualElements; @@ -12,10 +11,14 @@ namespace ViewModelsSamples.Pies.AngularGauge; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private readonly Random _random = new(); + public IEnumerable Series { get; set; } + public IEnumerable> VisualElements { get; set; } + public NeedleVisual Needle { get; set; } + public ViewModel() { var sectionsOuter = 130; @@ -31,8 +34,8 @@ public ViewModel() new GaugeItem(30, s => SetStyle(sectionsOuter, sectionsWidth, s)), new GaugeItem(10, s => SetStyle(sectionsOuter, sectionsWidth, s))); - VisualElements = new VisualElement[] - { + VisualElements = + [ new AngularTicksVisual { Labeler = value => value.ToString("N1"), @@ -42,15 +45,9 @@ public ViewModel() TicksLength = 20 }, Needle - }; + ]; } - public IEnumerable Series { get; set; } - - public IEnumerable> VisualElements { get; set; } - - public NeedleVisual Needle { get; set; } - [RelayCommand] public void DoRandomChange() { diff --git a/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs index 5ccd9e9c0..a51f1aeea 100644 --- a/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs @@ -1,6 +1,5 @@ using System; using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore; using LiveChartsCore.Defaults; @@ -8,7 +7,7 @@ namespace ViewModelsSamples.Pies.AutoUpdate; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private readonly Random _random = new(); @@ -19,12 +18,12 @@ public ViewModel() [ // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark - new PieSeries { Values = new[] { new ObservableValue(2) } }, - new PieSeries { Values = new[] { new ObservableValue(5) } }, - new PieSeries { Values = new[] { new ObservableValue(3) } }, - new PieSeries { Values = new[] { new ObservableValue(7) } }, - new PieSeries { Values = new[] { new ObservableValue(4) } }, - new PieSeries { Values = new[] { new ObservableValue(3) } } + new PieSeries { Values = [new ObservableValue(2)] }, + new PieSeries { Values = [new ObservableValue(5)] }, + new PieSeries { Values = [new ObservableValue(3)] }, + new PieSeries { Values = [new ObservableValue(7)] }, + new PieSeries { Values = [new ObservableValue(4)] }, + new PieSeries { Values = [new ObservableValue(3)] } ]; } @@ -39,7 +38,7 @@ public void AddSeries() Series.Add( new PieSeries { - Values = new[] { new ObservableValue(_random.Next(1, 10)) } + Values = [new ObservableValue(_random.Next(1, 10))] }); } diff --git a/samples/ViewModelsSamples/Pies/Basic/ViewModel.cs b/samples/ViewModelsSamples/Pies/Basic/ViewModel.cs index 29999b414..83cf48464 100644 --- a/samples/ViewModelsSamples/Pies/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Basic/ViewModel.cs @@ -1,15 +1,12 @@ using LiveChartsCore; using LiveChartsCore.SkiaSharpView; -using CommunityToolkit.Mvvm.ComponentModel; using System.Collections.Generic; -using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; using LiveChartsCore.SkiaSharpView.VisualElements; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { // you can convert any array, list or IEnumerable to a pie series collection: public IEnumerable Series { get; set; } = @@ -17,21 +14,19 @@ public partial class ViewModel : ObservableObject // the expression above is equivalent to the next series collection: public IEnumerable Series2 { get; set; } = - new[] - { - new PieSeries { Values = new[]{ 2 } }, - new PieSeries { Values = new[]{ 4 } }, - new PieSeries { Values = new[]{ 1 } }, - new PieSeries { Values = new[]{ 4 } }, - new PieSeries { Values = new[]{ 3 } }, - }; + [ + new PieSeries { Values = [2] }, + new PieSeries { Values = [4] }, + new PieSeries { Values = [1] }, + new PieSeries { Values = [4] }, + new PieSeries { Values = [3] }, + ]; public LabelVisual Title { get; set; } = new LabelVisual { Text = "My chart title", TextSize = 25, - Padding = new LiveChartsCore.Drawing.Padding(15), - Paint = new SolidColorPaint(SKColors.DarkSlateGray) + Padding = new LiveChartsCore.Drawing.Padding(15) }; } diff --git a/samples/ViewModelsSamples/Pies/Custom/ViewModel.cs b/samples/ViewModelsSamples/Pies/Custom/ViewModel.cs index 6e07a9aa9..2f8203ae4 100644 --- a/samples/ViewModelsSamples/Pies/Custom/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Custom/ViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; using System; @@ -8,8 +7,10 @@ namespace ViewModelsSamples.Pies.Custom; -public partial class ViewModel : ObservableObject +public class ViewModel { + public IEnumerable Series { get; set; } + public ViewModel() { var outer = 0; @@ -54,6 +55,4 @@ public ViewModel() }; }); } - - public IEnumerable Series { get; set; } } diff --git a/samples/ViewModelsSamples/Pies/Doughnut/ViewModel.cs b/samples/ViewModelsSamples/Pies/Doughnut/ViewModel.cs index eeacfaece..480c3c576 100644 --- a/samples/ViewModelsSamples/Pies/Doughnut/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Doughnut/ViewModel.cs @@ -1,11 +1,10 @@ using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using System.Collections.Generic; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Doughnut; -public partial class ViewModel : ObservableObject +public class ViewModel { // you can convert any array, list or IEnumerable to a pie series collection: public IEnumerable Series { get; set; } = diff --git a/samples/ViewModelsSamples/Pies/Gauge1/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauge1/ViewModel.cs index c93ae53e5..bbd4b7331 100644 --- a/samples/ViewModelsSamples/Pies/Gauge1/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauge1/ViewModel.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Gauge1; -public partial class ViewModel : ObservableObject +public class ViewModel { public IEnumerable Series { get; set; } = GaugeGenerator.BuildSolidGauge( diff --git a/samples/ViewModelsSamples/Pies/Gauge2/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauge2/ViewModel.cs index cebb1406d..f576992fa 100644 --- a/samples/ViewModelsSamples/Pies/Gauge2/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauge2/ViewModel.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using LiveChartsCore; using LiveChartsCore.Measure; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Gauge2; -public partial class ViewModel : ObservableObject +public class ViewModel { public IEnumerable Series { get; set; } = GaugeGenerator.BuildSolidGauge( diff --git a/samples/ViewModelsSamples/Pies/Gauge3/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauge3/ViewModel.cs index 10ae8248b..0469f0535 100644 --- a/samples/ViewModelsSamples/Pies/Gauge3/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauge3/ViewModel.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; namespace ViewModelsSamples.Pies.Gauge3; -public partial class ViewModel : ObservableObject +public class ViewModel { public IEnumerable Series { get; set; } = GaugeGenerator.BuildSolidGauge( diff --git a/samples/ViewModelsSamples/Pies/Gauge4/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauge4/ViewModel.cs index 99c27ccba..4b9501285 100644 --- a/samples/ViewModelsSamples/Pies/Gauge4/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauge4/ViewModel.cs @@ -2,13 +2,12 @@ using LiveChartsCore; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; using LiveChartsCore.Defaults; namespace ViewModelsSamples.Pies.Gauge4; -public partial class ViewModel : ObservableObject +public class ViewModel { public IEnumerable Series { get; set; } = GaugeGenerator.BuildSolidGauge( diff --git a/samples/ViewModelsSamples/Pies/Gauge5/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauge5/ViewModel.cs index 953d34d38..9559bf856 100644 --- a/samples/ViewModelsSamples/Pies/Gauge5/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauge5/ViewModel.cs @@ -3,16 +3,19 @@ using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; -using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Gauge5; -public partial class ViewModel : ObservableObject +public partial class ViewModel { private readonly Random _random = new(); + public ObservableValue ObservableValue1 { get; set; } + public ObservableValue ObservableValue2 { get; set; } + public IEnumerable Series { get; set; } + public ViewModel() { ObservableValue1 = new ObservableValue { Value = 50 }; @@ -31,10 +34,6 @@ public ViewModel() })); } - public ObservableValue ObservableValue1 { get; set; } - public ObservableValue ObservableValue2 { get; set; } - public IEnumerable Series { get; set; } - [RelayCommand] public void DoRandomChange() { diff --git a/samples/ViewModelsSamples/Pies/Gauges/ViewModel.cs b/samples/ViewModelsSamples/Pies/Gauges/ViewModel.cs index 86218cc57..3274abb15 100644 --- a/samples/ViewModelsSamples/Pies/Gauges/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Gauges/ViewModel.cs @@ -1,18 +1,15 @@ -// Ignore Spelling: Gauge - -using System.Collections.Generic; +using System.Collections.Generic; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Gauges; -public partial class ViewModel : ObservableObject +public class ViewModel { public ViewModel() { diff --git a/samples/ViewModelsSamples/Pies/Icons/ViewModel.cs b/samples/ViewModelsSamples/Pies/Icons/ViewModel.cs new file mode 100644 index 000000000..98f6e3f02 --- /dev/null +++ b/samples/ViewModelsSamples/Pies/Icons/ViewModel.cs @@ -0,0 +1,146 @@ +using LiveChartsCore; +using LiveChartsCore.ConditionalDraw; +using LiveChartsCore.Drawing; +using LiveChartsCore.Motion; +using LiveChartsCore.SkiaSharpView.Drawing; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +using LiveChartsCore.SkiaSharpView.Extensions; +using LiveChartsCore.SkiaSharpView.Painting; +using SkiaSharp; +using System.Collections.Generic; + +namespace ViewModelsSamples.Pies.Icons; + +public class ViewModel +{ + public IEnumerable Series { get; set; } + + public ViewModel() + { + BrowserShare[] data = [ + new() { Name = "Chrome", Value = 65.72, Svg = Icons.Chrome }, + new() { Name = "Safari", Value = 18.22, Svg = Icons.Safari }, + new() { Name = "Edge", Value = 5.31, Svg = Icons.Edge } + ]; + + // lets create a pie series collection that plots the BrowserShare class, + // it will use the DoughnutGeometry to draw each point (the default geometry), + // and uses the SvgIconLabel to draw the label, in this case a SVG icon. + Series = data.AsPieSeries( + (dataItem, series) => + { + // define the data labels paint. + series.DataLabelsPaint = new SolidColorPaint(SKColors.WhiteSmoke); + + // now, when the point is measured, + // we will set up the svg label based on the BrowserShare class. + series + .OnPointMeasured(point => + { + var svgLabel = point.Label!; + + svgLabel.Path = dataItem.Svg; + svgLabel.Name = dataItem.Name; + svgLabel.Width = 50; + svgLabel.Height = 50; + svgLabel.TranslateTransform = new(-25, -25); + }); + }); + + // Lets teach LiveCharts how to handle the BrowserShare class + // you can learn more about mappings here: + // https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers + LiveCharts.Configure(config => config + .HasMap((point, index) => new(index, point.Value))); + } +} + +public class BrowserShare +{ + public string Name { get; set; } + public SKPath Svg { get; set; } + public double Value { get; set; } +} + +// this is the geometry that will be used to draw the labels on each point. +// we inherit from VariableSVGPathGeometry to handle the svg path, +// the VariableSVGPathGeometry class scales the svg path to fit the Width and Height properties. +// we also implement ILabelGeometry to satisfy the series requirements. +public class SvgIconLabel : VariableSVGPathGeometry, ILabelGeometry +{ + public string Name { get; set; } = string.Empty; + + public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) + { + // lets draw the icon using the VariableSVGPathGeometry base class. + base.OnDraw(context, paint); + + // and after that, lets draw the name of the browser using the SkiaSharp API. + + using var textPaint = new SKPaint + { + Color = SKColors.WhiteSmoke, + Style = SKPaintStyle.Fill, + TextSize = 16, + FakeBoldText = true, + IsAntialias = true + }; + + context.Canvas.DrawText(Name, X, Y - 10, textPaint); + } + + // All the folowing properties and ctor are required by the ILabelGeometry interface + // in this case we will ignore them. + + public SvgIconLabel() + { + // just a workaround... probably will be imprived in a future version. + _ = RegisterMotionProperty(new FloatMotionProperty(nameof(TextSize), 11)); + } + + public Padding Padding { get; set; } = new(); + public float LineHeight { get; set; } + public Align VerticalAlign { get; set; } + public Align HorizontalAlign { get; set; } + public string Text { get; set; } = string.Empty; + public float TextSize { get; set; } + public float MaxWidth { get; set; } + public LvcColor Background { get; set; } +} + +public static class Icons +{ + // from https://www.svgrepo.com/svg/500807/chrome + public static SKPath Chrome { get; } = SKPath.ParseSvgPathData( + "M21.25 11.031h-10.063c-0.969 0-1.844 0.313-2.625 0.781-1.344 0.844-2.25 2.344-2.313 " + + "4.031l-3.875-6.719c2.063-2.625 5.219-4.344 8.813-4.344 4.406 0 8.25 2.563 10.063 " + + "6.25zM1.875 9.75l5 8.688c0.031 0.031 0.031 0.063 0.063 0.094 0.438 0.781 1.125 " + + "1.406 1.938 1.844 0.719 0.344 1.469 0.594 2.313 0.594s1.625-0.25 2.344-0.594l-3.906 " + + "6.719c-5.438-0.781-9.625-5.438-9.625-11.094 0-2.313 0.688-4.469 1.875-6.25zM13.813 " + + "11.813h7.781c0.5 1.281 0.813 2.719 0.813 4.188 0 6.188-5.031 11.188-11.219 11.188-0.25 " + + "0-0.469 0-0.719-0.031l5-8.625c0.031-0.031 0.031-0.063 0.063-0.094 0.406-0.75 0.625-1.563 " + + "0.625-2.438v-0.156c-0.063-1.688-1-3.188-2.344-4.031zM7.469 16c0-2.094 1.625-3.75 3.719-3.75s3.75 " + + "1.656 3.75 3.75-1.656 3.75-3.75 3.75-3.719-1.656-3.719-3.75z"); + + // from: https://www.svgrepo.com/svg/316925/safari + public static SKPath Safari { get; } = SKPath.ParseSvgPathData( + "M12 3.5C7.30558 3.5 3.5 7.30558 3.5 12C3.5 13.5799 3.93054 15.0576 4.68039 16.324C4.82109 16.5617 " + + "4.74251 16.8683 4.5049 17.009C4.26729 17.1497 3.96061 17.0712 3.81992 16.8335C2.98125 15.4171 2.5 " + + "13.764 2.5 12C2.5 6.75329 6.75329 2.5 12 2.5C17.2467 2.5 21.5 6.75329 21.5 12C21.5 17.2467 17.2467 " + + "21.5 12 21.5C9.41171 21.5 7.06433 20.4642 5.3514 18.7857C5.24102 18.6776 5.18686 18.5244 5.20469 " + + "18.3709C5.22251 18.2174 5.31033 18.0808 5.44256 18.0008L13.111 13.3621L16.0946 8.3816L10.9439 " + + "11.1098L7.81033 15.6802C7.65418 15.908 7.34296 15.966 7.11521 15.8098C6.88746 15.6537 6.82941 15.3425 " + + "6.98557 15.1147L10.1887 10.4428C10.2344 10.3762 10.2956 10.3216 10.367 10.2837L17.2108 6.65874C17.4091 " + + "6.5537 17.6531 6.59365 17.8076 6.75646C17.962 6.91926 17.9891 7.16502 17.8737 7.35754L13.905 " + + "13.9825C13.8631 14.0525 13.8047 14.1112 13.7349 14.1534L6.5337 18.5095C8.01177 19.7521 9.91814 " + + "20.5 12 20.5C16.6944 20.5 20.5 16.6944 20.5 12C20.5 7.30558 16.6944 3.5 12 3.5Z"); + + // from: https://www.svgrepo.com/svg/452194/edge + public static SKPath Edge { get; } = SKPath.ParseSvgPathData( + "M10.1836 13.436H20.098C20.098 9.91613 18.5621 7.51636 14.3743 7.51636C9.42537 7.51634 4.3926 10.7381 " + + "2 14.7553C2.74111 7.78266 7.74053 2.15332 15.2673 2.15332C21.7186 2.15332 27.8309 7.08585 27.8309 " + + "15.2853V18.4026H10.2364C10.2364 22.6456 13.9377 24.3267 17.8142 24.3267C22.5317 24.3267 25.4532 22.2068 " + + "25.4532 22.2068V28.15C25.4532 28.15 22.1552 30.1533 16.8985 30.1533C10.0672 30.1533 5.24517 25.2576 " + + "5.24517 19.1697C5.24517 14.3911 8.13564 10.5759 12.1393 9.00165C10.1904 11.142 10.1835 13.436 10.1835 " + + "13.436H10.1836Z"); +} diff --git a/samples/ViewModelsSamples/Pies/NightingaleRose/ViewModel.cs b/samples/ViewModelsSamples/Pies/NightingaleRose/ViewModel.cs index 666b0c954..ab481f780 100644 --- a/samples/ViewModelsSamples/Pies/NightingaleRose/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/NightingaleRose/ViewModel.cs @@ -1,12 +1,13 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.NightingaleRose; -public partial class ViewModel : ObservableObject +public class ViewModel { + public IEnumerable Series { get; set; } + public ViewModel() { var outer = 0; @@ -24,6 +25,4 @@ public ViewModel() outer += 50; }); } - - public IEnumerable Series { get; set; } } diff --git a/samples/ViewModelsSamples/Pies/OutLabels/ViewModel.cs b/samples/ViewModelsSamples/Pies/OutLabels/ViewModel.cs index 20101b1bc..c7b5f8e98 100644 --- a/samples/ViewModelsSamples/Pies/OutLabels/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/OutLabels/ViewModel.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.OutLabels; -public partial class ViewModel : ObservableObject +public class ViewModel { private static int _index = 0; - private static string[] _names = new[] { "Maria", "Susan", "Charles", "Fiona", "George" }; + private static string[] _names = ["Maria", "Susan", "Charles", "Fiona", "George"]; public IEnumerable Series { get; set; } = new[] { 8, 6, 5, 3, 3 }.AsPieSeries((value, series) => diff --git a/samples/ViewModelsSamples/Pies/Processing/ViewModel.cs b/samples/ViewModelsSamples/Pies/Processing/ViewModel.cs index 1505f2f36..28e0f2071 100644 --- a/samples/ViewModelsSamples/Pies/Processing/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Processing/ViewModel.cs @@ -1,5 +1,4 @@ using System; -using System.ComponentModel; using System.Threading.Tasks; using LiveChartsCore; using LiveChartsCore.Defaults; @@ -20,35 +19,35 @@ public ViewModel() _completed = new ObservableValue(100); _failed = new ObservableValue(100); - Series = new ISeries[] - { + Series = + [ new PieSeries { Name = "Processing", - Values = new []{ _processing }, + Values = [_processing], //InnerRadius = 45 }, new PieSeries { Name = "Failed", - Values = new []{ _failed }, + Values = [_failed], //InnerRadius = 45 }, new PieSeries { Name = "Completed", - Values = new []{ _completed }, + Values = [_completed], //InnerRadius = 45 } - }; + ]; // the ValueSeries property is a workaround for WPF only. - ValueSeries = new ValueSeries[] - { + ValueSeries = + [ new() { Value = _processing, Series = Series[0] }, new() { Value = _failed, Series = Series[1] }, new() { Value = _completed, Series = Series[2] } - }; + ]; Value = _processing; @@ -93,12 +92,12 @@ public async void Read() processed = newTask; //Value = new ObservableValue(_processing.Value ?? 0); - ValueSeries = new ValueSeries[] - { + ValueSeries = + [ new() { Value = _processing, Series = Series[0] }, new() { Value = _failed, Series = Series[1] }, new() { Value = _completed, Series = Series[2] } - }; + ]; OnPropertyChanged(nameof(ValueSeries)); OnPropertyChanged(nameof(Value)); isProcessing = _completed.Value < 1000; diff --git a/samples/ViewModelsSamples/Pies/Pushout/ViewModel.cs b/samples/ViewModelsSamples/Pies/Pushout/ViewModel.cs index 6e74f2eab..c9e3c8d6f 100644 --- a/samples/ViewModelsSamples/Pies/Pushout/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/Pushout/ViewModel.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; using LiveChartsCore; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Pies.Pushout; -public partial class ViewModel : ObservableObject +public class ViewModel { // you can convert any array, list or IEnumerable to a pie series collection: public IEnumerable Series { get; set; } = diff --git a/samples/ViewModelsSamples/Polar/Basic/ViewModel.cs b/samples/ViewModelsSamples/Polar/Basic/ViewModel.cs index 5b126291d..cdc55dfc3 100644 --- a/samples/ViewModelsSamples/Polar/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Polar/Basic/ViewModel.cs @@ -1,6 +1,4 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; @@ -9,13 +7,12 @@ namespace ViewModelsSamples.Polar.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new PolarLineSeries { - Values = new ObservableCollection { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, + Values = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], DataLabelsPaint = new SolidColorPaint(new SKColor(30, 30, 30)), GeometrySize = 15, DataLabelsSize = 8, @@ -23,24 +20,23 @@ public partial class ViewModel : ObservableObject DataLabelsRotation = LiveCharts.CotangentAngle, IsClosed = true } - }; + ]; - public PolarAxis[] RadialAxes { get; set; } = - { + public PolarAxis[] RadialAxes { get; set; } = [ new PolarAxis { LabelsAngle = -60, - MaxLimit = 30 // null to let the chart autoscale (defualt is null) // mark + MaxLimit = 30, // null to let the chart autoscale (defualt is null) // mark } - }; + ]; - public PolarAxis[] AngleAxes { get; set; } = - { + public PolarAxis[] AngleAxes { get; set; } = [ new PolarAxis { - LabelsRotation = LiveCharts.TangentAngle + LabelsRotation = LiveCharts.TangentAngle, + //IsInverted = true // enables counter clockwise draw. // mark } - }; + ]; public LabelVisual Title { get; set; } = new LabelVisual diff --git a/samples/ViewModelsSamples/Polar/Coordinates/ViewModel.cs b/samples/ViewModelsSamples/Polar/Coordinates/ViewModel.cs index 305701acf..6ae9302a3 100644 --- a/samples/ViewModelsSamples/Polar/Coordinates/ViewModel.cs +++ b/samples/ViewModelsSamples/Polar/Coordinates/ViewModel.cs @@ -1,35 +1,31 @@ using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; -using CommunityToolkit.Mvvm.ComponentModel; namespace ViewModelsSamples.Polar.Coordinates; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new PolarLineSeries { - Values = new[] - { - new ObservablePolarPoint(0, 10), - new ObservablePolarPoint(45, 15), - new ObservablePolarPoint(90, 20), - new ObservablePolarPoint(135, 25), - new ObservablePolarPoint(180, 30), - new ObservablePolarPoint(225, 35), - new ObservablePolarPoint(270, 40), - new ObservablePolarPoint(315, 45), - new ObservablePolarPoint(360, 50), - }, + Values = [ + new(0, 10), + new(45, 15), + new(90, 20), + new(135, 25), + new(180, 30), + new(225, 35), + new(270, 40), + new(315, 45), + new(360, 50), + ], IsClosed = false, Fill = null } - }; + ]; - public PolarAxis[] AngleAxes { get; set; } = - { + public PolarAxis[] AngleAxes { get; set; } = [ new PolarAxis { // force the axis to always show 360 degrees. @@ -39,5 +35,5 @@ public partial class ViewModel : ObservableObject ForceStepToMin = true, MinStep = 30 } - }; + ]; } diff --git a/samples/ViewModelsSamples/Polar/RadialArea/ViewModel.cs b/samples/ViewModelsSamples/Polar/RadialArea/ViewModel.cs index afa0b178a..5bfa1670b 100644 --- a/samples/ViewModelsSamples/Polar/RadialArea/ViewModel.cs +++ b/samples/ViewModelsSamples/Polar/RadialArea/ViewModel.cs @@ -2,36 +2,33 @@ using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; -using CommunityToolkit.Mvvm.ComponentModel; namespace ViewModelsSamples.Polar.RadialArea; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new PolarLineSeries { - Values = new[] { 7, 5, 7, 5, 6 }, + Values = [7, 5, 7, 5, 6], LineSmoothness = 0, GeometrySize= 0, Fill = new SolidColorPaint(SKColors.Blue.WithAlpha(90)) }, new PolarLineSeries { - Values = new[] { 2, 7, 5, 9, 7 }, + Values = [2, 7, 5, 9, 7], LineSmoothness = 1, GeometrySize = 0, Fill = new SolidColorPaint(SKColors.Red.WithAlpha(90)) } - }; + ]; - public PolarAxis[] AngleAxes { get; set; } = - { + public PolarAxis[] AngleAxes { get; set; } = [ new PolarAxis { LabelsRotation = LiveCharts.TangentAngle, - Labels = new[] { "first", "second", "third", "forth", "fifth" } + Labels = ["first", "second", "third", "forth", "fifth"] } - }; + ]; } diff --git a/samples/ViewModelsSamples/Polar/Test/ViewModel.cs b/samples/ViewModelsSamples/Polar/Test/ViewModel.cs index 8056760ab..2debff839 100644 --- a/samples/ViewModelsSamples/Polar/Test/ViewModel.cs +++ b/samples/ViewModelsSamples/Polar/Test/ViewModel.cs @@ -32,21 +32,21 @@ public class ViewModel : INotifyPropertyChanged }; public PolarAxis[] RadialAxes { get; set; } = - { + [ new PolarAxis { LabelsAngle = -60, MaxLimit = 30 // null to let the chart autoscale (defualt is null) // mark } - }; + ]; public PolarAxis[] AngleAxes { get; set; } = - { + [ new PolarAxis { LabelsRotation = LiveCharts.TangentAngle } - }; + ]; public bool FitToBounds { diff --git a/samples/ViewModelsSamples/Scatter/Basic/ViewModel.cs b/samples/ViewModelsSamples/Scatter/Basic/ViewModel.cs index 902128cc3..967001267 100644 --- a/samples/ViewModelsSamples/Scatter/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/Scatter/Basic/ViewModel.cs @@ -1,42 +1,21 @@ -using System.Collections.ObjectModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; -using CommunityToolkit.Mvvm.ComponentModel; namespace ViewModelsSamples.Scatter.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new ScatterSeries { - Values = new ObservableCollection - { + Values = [ new(2.2, 5.4), - new(4.5, 2.5), - new(4.2, 7.4), - new(6.4, 9.9), - new(4.2, 9.2), - new(5.8, 3.5), - new(7.3, 5.8), - new(8.9, 3.9), - new(6.1, 4.6), - new(9.4, 7.7), - new(8.4, 8.5), new(3.6, 9.6), - new(4.4, 6.3), - new(5.8, 4.8), - new(6.9, 3.4), - new(7.6, 1.8), - new(8.3, 8.3), new(9.9, 5.2), new(8.1, 4.7), - new(7.4, 3.9), - new(6.8, 2.3), - new(5.3, 7.1), - } + new(5.3, 7.1) + ] } - }; + ]; } diff --git a/samples/ViewModelsSamples/Scatter/Bubbles/ViewModel.cs b/samples/ViewModelsSamples/Scatter/Bubbles/ViewModel.cs index 492d935f2..d668b9b7a 100644 --- a/samples/ViewModelsSamples/Scatter/Bubbles/ViewModel.cs +++ b/samples/ViewModelsSamples/Scatter/Bubbles/ViewModel.cs @@ -1,20 +1,21 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; -using CommunityToolkit.Mvvm.ComponentModel; namespace ViewModelsSamples.Scatter.Bubbles; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { var r = new Random(); - var values1 = new ObservableCollection(); - var values2 = new ObservableCollection(); + var values1 = new List(); + var values2 = new List(); for (var i = 0; i < 8; i++) { @@ -37,22 +38,30 @@ public ViewModel() values2.Add(new WeightedPoint(r.Next(0, 20), r.Next(0, 20), r.Next(0, 100))); } - Series = new ISeries[] - { + Series = [ new ScatterSeries { Values = values1, - GeometrySize = 50, - MinGeometrySize = 5 + GeometrySize = 100, + MinGeometrySize = 5, }, new ScatterSeries { Values = values2, - GeometrySize = 50, - MinGeometrySize = 5 + GeometrySize = 100, + MinGeometrySize = 5, + StackGroup = 1 + }, + new ScatterSeries + { + Values = [ new() { X = 10, Y = 10, Weight = 500 } ], + GeometrySize = 100, + MinGeometrySize = 5, + // use the stack group to share the Weight between series. // mark + // in this case, the previous series shares the same // mark + // StackGroup, thus series share the Weigth bounds. // mark + StackGroup = 1 } - }; + ]; } - - public ISeries[] Series { get; set; } } diff --git a/samples/ViewModelsSamples/Scatter/Custom/ViewModel.cs b/samples/ViewModelsSamples/Scatter/Custom/ViewModel.cs index 9757b398a..de8ef10ad 100644 --- a/samples/ViewModelsSamples/Scatter/Custom/ViewModel.cs +++ b/samples/ViewModelsSamples/Scatter/Custom/ViewModel.cs @@ -1,6 +1,5 @@ using System; using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; @@ -9,8 +8,10 @@ namespace ViewModelsSamples.Scatter.Custom; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] Series { get; set; } + public ViewModel() { var r = new Random(); @@ -25,34 +26,31 @@ public ViewModel() values3.Add(new ObservablePoint(r.Next(0, 20), r.Next(0, 20))); } - Series = new ISeries[] - { - // use the second type parameter to specify the geometry to draw for every point - // there are already many predefined geometries in the - // LiveChartsCore.SkiaSharpView.Drawing.Geometries namespace - new ScatterSeries + Series = [ + // use the second generic parameter to define the geometry to draw + // there are many predefined geometries in the LiveChartsCore.Drawing namespace + // for example, the StarGeometry, CrossGeometry, RectangleGeometry and DiamondGeometry + new ScatterSeries { Values = values1, Stroke = null, - GeometrySize = 40, + GeometrySize = 40 }, // You can also use SVG paths to draw the geometry - // LiveCharts already provides some predefined paths in the SVGPoints class. - new ScatterSeries + // the VariableSVGPathGeometry can change the drawn path at runtime + new ScatterSeries { Values = values2, - GeometrySvg = SVGPoints.Heart + GeometrySvg = SVGPoints.Pin }, - // you can declare your own gemetry and use the SkiaSharp api to draw it + // finally you can also use SkiaSharp to draw your own geometry new ScatterSeries { Values = values3, GeometrySize = 40, } - }; + ]; } - - public ISeries[] Series { get; set; } } diff --git a/samples/ViewModelsSamples/StackedArea/Basic/ViewModel.cs b/samples/ViewModelsSamples/StackedArea/Basic/ViewModel.cs index 852450aec..00e8ad3b8 100644 --- a/samples/ViewModelsSamples/StackedArea/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/StackedArea/Basic/ViewModel.cs @@ -1,25 +1,13 @@ -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.StackedArea.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { - new StackedAreaSeries - { - Values = new List { 3, 2, 3, 5, 3, 4, 6 } - }, - new StackedAreaSeries - { - Values = new List { 6, 5, 6, 3, 8, 5, 2 } - }, - new StackedAreaSeries - { - Values = new List { 4, 8, 2, 8, 9, 5, 3 } - } - }; + public ISeries[] Series { get; set; } = [ + new StackedAreaSeries([3, 2, 3, 5, 3, 4, 6]), + new StackedAreaSeries([6, 5, 6, 3, 8, 5, 2]), + new StackedAreaSeries([4, 8, 2, 8, 9, 5, 3]) + ]; } diff --git a/samples/ViewModelsSamples/StackedArea/StepArea/ViewModel.cs b/samples/ViewModelsSamples/StackedArea/StepArea/ViewModel.cs index 9455aff10..3c7ab70bf 100644 --- a/samples/ViewModelsSamples/StackedArea/StepArea/ViewModel.cs +++ b/samples/ViewModelsSamples/StackedArea/StepArea/ViewModel.cs @@ -1,25 +1,14 @@ -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.StackedArea.StepArea; -public partial class ViewModel : ObservableObject +public class ViewModel { public ISeries[] Series { get; set; } = - { - new StackedStepAreaSeries - { - Values = new List { 3, 2, 3, 5, 3, 4, 6 } - }, - new StackedStepAreaSeries - { - Values = new List { 6, 5, 6, 3, 8, 5, 2 } - }, - new StackedStepAreaSeries - { - Values = new List { 4, 8, 2, 8, 9, 5, 3 } - } - }; + [ + new StackedStepAreaSeries([3, 2, 3, 5, 3, 4, 6]), + new StackedStepAreaSeries([6, 5, 6, 3, 8, 5, 2]), + new StackedStepAreaSeries([4, 8, 2, 8, 9, 5, 3]) + ]; } diff --git a/samples/ViewModelsSamples/StackedBars/Basic/ViewModel.cs b/samples/ViewModelsSamples/StackedBars/Basic/ViewModel.cs index 4454b6624..a11c2a432 100644 --- a/samples/ViewModelsSamples/StackedBars/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/StackedBars/Basic/ViewModel.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; @@ -8,33 +6,39 @@ namespace ViewModelsSamples.StackedBars.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { public ISeries[] Series { get; set; } = - { + [ new StackedColumnSeries { - Values = new List { 3, 5, -3, 2, 5, -4, -2 }, + Values = [3, 5, -3, 2, 5, -4, -2], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(45, 45, 45)), DataLabelsSize = 14, - DataLabelsPosition = DataLabelsPosition.Middle + DataLabelsPosition = DataLabelsPosition.Middle, + YToolTipLabelFormatter = + p => $"{p.Coordinate.PrimaryValue:N} ({p.StackedValue!.Share:P})" }, new StackedColumnSeries { - Values = new List { 4, 2, -3, 2, 3, 4, -2 }, + Values = [4, 2, -3, 2, 3, 4, -2], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(45, 45, 45)), DataLabelsSize = 14, - DataLabelsPosition = DataLabelsPosition.Middle + DataLabelsPosition = DataLabelsPosition.Middle, + YToolTipLabelFormatter = + p => $"{p.Coordinate.PrimaryValue:N} ({p.StackedValue!.Share:P})" }, new StackedColumnSeries { - Values = new List { -2, 6, 6, 5, 4, 3, -2 }, + Values = [-2, 6, 6, 5, 4, 3, -2], Stroke = null, DataLabelsPaint = new SolidColorPaint(new SKColor(45, 45, 45)), DataLabelsSize = 14, - DataLabelsPosition = DataLabelsPosition.Middle + DataLabelsPosition = DataLabelsPosition.Middle, + YToolTipLabelFormatter = + p => $"{p.Coordinate.PrimaryValue:N} ({p.StackedValue!.Share:P})" } - }; + ]; } diff --git a/samples/ViewModelsSamples/StackedBars/Groups/ViewModel.cs b/samples/ViewModelsSamples/StackedBars/Groups/ViewModel.cs index 474d682b2..4ccdd1f93 100644 --- a/samples/ViewModelsSamples/StackedBars/Groups/ViewModel.cs +++ b/samples/ViewModelsSamples/StackedBars/Groups/ViewModel.cs @@ -1,47 +1,44 @@ - -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; +using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.StackedBars.Groups; -public partial class ViewModel : ObservableObject +public class ViewModel { public ISeries[] Series { get; set; } = - { + [ new StackedColumnSeries { - Values = new List { 3, 5, 3 }, + Values = [3, 5, 3], Stroke = null, StackGroup = 0 // mark }, new StackedColumnSeries { - Values = new List { 4, 2, 3 }, + Values = [4, 2, 3], Stroke = null, StackGroup = 0 // mark }, new StackedColumnSeries { - Values = new List { 4, 6, 6 }, + Values = [4, 6, 6], Stroke = null, StackGroup = 1 // mark }, new StackedColumnSeries { - Values = new List { 2, 5, 4 }, + Values = [2, 5, 4], Stroke = null, StackGroup = 1 // mark } - }; + ]; - public Axis[] XAxis { get; set; } = - { + public ICartesianAxis[] XAxis { get; set; } = [ new Axis { LabelsRotation = -15, - Labels = new[] { "Category 1", "Category 2", "Category 3" } + Labels = ["Category 1", "Category 2", "Category 3"] } - }; + ]; } diff --git a/samples/ViewModelsSamples/StepLines/Area/ViewModel.cs b/samples/ViewModelsSamples/StepLines/Area/ViewModel.cs index 7b8171414..bced5d88e 100644 --- a/samples/ViewModelsSamples/StepLines/Area/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/Area/ViewModel.cs @@ -1,18 +1,16 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; namespace ViewModelsSamples.StepLines.Area; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new StepLineSeries { - Values = new double[] { -2, -1, 3, 5, 3, 4, 6 }, + Values = [-2, -1, 3, 5, 3, 4, 6], // Set he Fill property to build an area series // by default the series has a fill color based on your app theme Fill = new SolidColorPaint(SKColors.CornflowerBlue), @@ -21,7 +19,7 @@ public partial class ViewModel : ObservableObject GeometryFill = null, GeometryStroke = null } - }; + ]; // Creates a gray background and border in the draw margin. public DrawMarginFrame DrawMarginFrame => new() diff --git a/samples/ViewModelsSamples/StepLines/Basic/ViewModel.cs b/samples/ViewModelsSamples/StepLines/Basic/ViewModel.cs index 2e6d7b343..898da425b 100644 --- a/samples/ViewModelsSamples/StepLines/Basic/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/Basic/ViewModel.cs @@ -1,18 +1,15 @@ -using System.Collections.ObjectModel; -using CommunityToolkit.Mvvm.ComponentModel; -using LiveChartsCore; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.StepLines.Basic; -public partial class ViewModel : ObservableObject +public class ViewModel { - public ISeries[] Series { get; set; } = - { + public ISeries[] Series { get; set; } = [ new StepLineSeries { - Values = new ObservableCollection { 2, 1, 3, 4, 3, 4, 6 }, + Values = [2, 1, 3, 4, 3, 4, 6], Fill = null } - }; + ]; } diff --git a/samples/ViewModelsSamples/StepLines/Custom/ViewModel.cs b/samples/ViewModelsSamples/StepLines/Custom/ViewModel.cs index cc24a2fb3..a26bc3380 100644 --- a/samples/ViewModelsSamples/StepLines/Custom/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/Custom/ViewModel.cs @@ -9,10 +9,10 @@ namespace ViewModelsSamples.StepLines.Custom; public partial class ViewModel : ObservableObject { public ISeries[] Series { get; set; } = - { + [ new StepLineSeries { - Values = new double[] { 2, 1, 4, 2, 2, -5, -2 }, + Values = [2, 1, 4, 2, 2, -5, -2], Fill = null, GeometrySize = 20 }, @@ -22,16 +22,16 @@ public partial class ViewModel : ObservableObject // LiveChartsCore.SkiaSharpView.Drawing.Geometries namespace new StepLineSeries { - Values = new double[] { 3, 3, -3, -2, -4, -3, -1 }, + Values = [3, 3, -3, -2, -4, -3, -1], Fill = null, GeometrySize = 20 }, // You can also use SVG paths to draw the geometry // LiveCharts already provides some predefined paths in the SVGPoints class. - new StepLineSeries + new StepLineSeries { - Values = new double[] { -2, 2, 1, 3, -1, 4, 3 }, + Values = [-2, 2, 1, 3, -1, 4, 3], Fill = null, GeometrySvg = SVGPoints.Star, GeometrySize = 20 @@ -40,9 +40,9 @@ public partial class ViewModel : ObservableObject // you can declare your own gemetry and use the SkiaSharp api to draw it new StepLineSeries { - Values = new double[] { 4, 5, 2, 4, 3, 2, 1 }, + Values = [4, 5, 2, 4, 3, 2, 1], Fill = null, GeometrySize = 20 }, - }; + ]; } diff --git a/samples/ViewModelsSamples/StepLines/Properties/ViewModel.cs b/samples/ViewModelsSamples/StepLines/Properties/ViewModel.cs index e6c6b2d91..8dfc6a400 100644 --- a/samples/ViewModelsSamples/StepLines/Properties/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/Properties/ViewModel.cs @@ -25,7 +25,7 @@ public ViewModel() Values = new List { -2, -1, 3, 5, 3, 4, 6 }, }; - _series = new ISeries[] { _lineSeries }; + _series = [_lineSeries]; } [ObservableProperty] @@ -52,7 +52,7 @@ public void ChangeSeriesInstance() Values = new List { -2, -1, 3, 5, 3, 4, 6 }, }; - Series = new ISeries[] { _lineSeries }; + Series = [_lineSeries]; } [RelayCommand] diff --git a/samples/ViewModelsSamples/StepLines/Zoom/ViewModel.cs b/samples/ViewModelsSamples/StepLines/Zoom/ViewModel.cs index 95c08ba89..8abf2b2f5 100644 --- a/samples/ViewModelsSamples/StepLines/Zoom/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/Zoom/ViewModel.cs @@ -1,13 +1,13 @@ using System; -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; namespace ViewModelsSamples.StepLines.Zoom; -public partial class ViewModel : ObservableObject +public class ViewModel { + public ISeries[] SeriesCollection { get; set; } + public ViewModel() { var values = new int[100]; @@ -20,8 +20,6 @@ public ViewModel() values[i] = t; } - SeriesCollection = new ISeries[] { new StepLineSeries { Values = values } }; + SeriesCollection = [new StepLineSeries { Values = values }]; } - - public ISeries[] SeriesCollection { get; set; } } diff --git a/samples/ViewModelsSamples/Test/ChangeSeriesInstance/ViewModel.cs b/samples/ViewModelsSamples/Test/ChangeSeriesInstance/ViewModel.cs index 8ef02d8c5..6eb8e2868 100644 --- a/samples/ViewModelsSamples/Test/ChangeSeriesInstance/ViewModel.cs +++ b/samples/ViewModelsSamples/Test/ChangeSeriesInstance/ViewModel.cs @@ -7,6 +7,7 @@ using LiveChartsCore.Geo; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Test.ChangeSeriesInstance; @@ -36,35 +37,35 @@ public void GenerateData() { var data = new double[] { _r.Next(0, 10), _r.Next(0, 10), _r.Next(0, 10) }; - CartesianSeries = new ISeries[] - { + CartesianSeries = + [ new LineSeries { Values = new ObservableCollection(data) }, new ColumnSeries { Values = data }, new StackedAreaSeries { Values = data }, new StackedColumnSeries { Values = data }, new ScatterSeries { Values= data }, new RowSeries { Values = data } - }; + ]; - PieSeries = data.AsLiveChartsPieSeries(); + PieSeries = data.AsPieSeries(); - PolarSeries = new ISeries[] - { + PolarSeries = + [ new PolarLineSeries { Values = new ObservableCollection(data) } - }; + ]; - GeoSeries = new IGeoSeries[] - { + GeoSeries = + [ new HeatLandSeries { - Lands = new HeatLand[] - { + Lands = + [ new() { Name = "bra", Value = 13 }, new() { Name = "mex", Value = 10 }, new() { Name = "usa", Value = 15 }, new() { Name = "can", Value = 8 } - } + ] } - }; + ]; } } diff --git a/samples/ViewModelsSamples/Test/Dispose/ViewModel.cs b/samples/ViewModelsSamples/Test/Dispose/ViewModel.cs index 764c4065a..5f71abceb 100644 --- a/samples/ViewModelsSamples/Test/Dispose/ViewModel.cs +++ b/samples/ViewModelsSamples/Test/Dispose/ViewModel.cs @@ -6,6 +6,7 @@ using LiveChartsCore.Geo; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +using LiveChartsCore.SkiaSharpView.Extensions; namespace ViewModelsSamples.Test.Dispose; @@ -22,36 +23,36 @@ public ViewModel() data.Add(_r.Next(0, 100)); } - CartesianSeries = new ISeries[] - { + CartesianSeries = + [ new LineSeries { Values = new ObservableCollection(data) }, new ColumnSeries { Values = data }, new StackedAreaSeries { Values = data }, new StackedColumnSeries { Values = data }, new ScatterSeries { Values= data }, new RowSeries { Values = data } - }; + ]; - PieSeries = data.AsLiveChartsPieSeries(); + PieSeries = data.AsPieSeries(); - PolarSeries = new ISeries[] - { + PolarSeries = + [ new PolarLineSeries { Values = new ObservableCollection(data) } - }; + ]; - GeoSeries = new IGeoSeries[] - { + GeoSeries = + [ new HeatLandSeries { - Lands = new HeatLand[] - { + Lands = + [ new() { Name = "bra", Value = 13 }, new() { Name = "mex", Value = 10 }, new() { Name = "usa", Value = 15 }, new() { Name = "can", Value = 8 } - } + ] } - }; + ]; } public IEnumerable CartesianSeries { get; } diff --git a/samples/ViewModelsSamples/VisualTest/TwoChartsOneSeries/ViewModel.cs b/samples/ViewModelsSamples/VisualTest/TwoChartsOneSeries/ViewModel.cs index 3b1931a38..3e8f5d4a3 100644 --- a/samples/ViewModelsSamples/VisualTest/TwoChartsOneSeries/ViewModel.cs +++ b/samples/ViewModelsSamples/VisualTest/TwoChartsOneSeries/ViewModel.cs @@ -32,7 +32,7 @@ public ViewModel() values[i] = new(t); } - Series = new ISeries[] { new StepLineSeries { Values = values } }; + Series = [new StepLineSeries { Values = values }]; } public ISeries[] Series { get; set; } diff --git a/samples/WPFSample/Lines/Basic/View.xaml b/samples/WPFSample/Lines/Basic/View.xaml index 7087e8124..3a909ae38 100644 --- a/samples/WPFSample/Lines/Basic/View.xaml +++ b/samples/WPFSample/Lines/Basic/View.xaml @@ -6,5 +6,5 @@ - + diff --git a/samples/WPFSample/Lines/CustomPoints/View.xaml b/samples/WPFSample/Lines/CustomPoints/View.xaml new file mode 100644 index 000000000..ac77782a9 --- /dev/null +++ b/samples/WPFSample/Lines/CustomPoints/View.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/samples/WPFSample/Lines/CustomPoints/View.xaml.cs b/samples/WPFSample/Lines/CustomPoints/View.xaml.cs new file mode 100644 index 000000000..30dc10588 --- /dev/null +++ b/samples/WPFSample/Lines/CustomPoints/View.xaml.cs @@ -0,0 +1,14 @@ +using System.Windows.Controls; + +namespace WPFSample.Lines.CustomPoints; + +/// +/// Interaction logic for View.xaml +/// +public partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/WPFSample/Pies/Gauge/View.xaml b/samples/WPFSample/Pies/Gauge/View.xaml index 75b728dbc..16505d4ce 100644 --- a/samples/WPFSample/Pies/Gauge/View.xaml +++ b/samples/WPFSample/Pies/Gauge/View.xaml @@ -32,7 +32,7 @@ diff --git a/samples/WPFSample/Pies/Icons/View.xaml b/samples/WPFSample/Pies/Icons/View.xaml new file mode 100644 index 000000000..9f0dce633 --- /dev/null +++ b/samples/WPFSample/Pies/Icons/View.xaml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/samples/WPFSample/Pies/Icons/View.xaml.cs b/samples/WPFSample/Pies/Icons/View.xaml.cs new file mode 100644 index 000000000..0da45d4cf --- /dev/null +++ b/samples/WPFSample/Pies/Icons/View.xaml.cs @@ -0,0 +1,14 @@ +using System.Windows.Controls; + +namespace WPFSample.Pies.Icons; + +/// +/// Interaction logic for View.xaml +/// +public partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/WinFormsSample/Lines/Custom/View.Designer.cs b/samples/WinFormsSample/Lines/Custom/View.Designer.cs index 58b67ad65..9ac8fa342 100644 --- a/samples/WinFormsSample/Lines/Custom/View.Designer.cs +++ b/samples/WinFormsSample/Lines/Custom/View.Designer.cs @@ -1,5 +1,5 @@  -namespace WinFormsSample.Lines.Custom +namespace WinFormsSample.Lines.CustomPoints { partial class View { diff --git a/samples/WinFormsSample/Lines/CustomPoints/View.Designer.cs b/samples/WinFormsSample/Lines/CustomPoints/View.Designer.cs new file mode 100644 index 000000000..58b67ad65 --- /dev/null +++ b/samples/WinFormsSample/Lines/CustomPoints/View.Designer.cs @@ -0,0 +1,46 @@ + +namespace WinFormsSample.Lines.Custom +{ + partial class View + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // View + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Name = "View"; + this.Size = new System.Drawing.Size(427, 375); + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/samples/WinFormsSample/Lines/CustomPoints/View.cs b/samples/WinFormsSample/Lines/CustomPoints/View.cs new file mode 100644 index 000000000..45bd49d62 --- /dev/null +++ b/samples/WinFormsSample/Lines/CustomPoints/View.cs @@ -0,0 +1,30 @@ +using System.Windows.Forms; +using LiveChartsCore.SkiaSharpView.WinForms; +using ViewModelsSamples.Lines.CustomPoints; + +namespace WinFormsSample.Lines.CustomPoints; + +public partial class View : UserControl +{ + private readonly CartesianChart cartesianChart; + + public View() + { + InitializeComponent(); + Size = new System.Drawing.Size(50, 50); + + var viewModel = new ViewModel(); + + cartesianChart = new CartesianChart + { + Series = viewModel.Series, + + // out of livecharts properties... + Location = new System.Drawing.Point(0, 0), + Size = new System.Drawing.Size(50, 50), + Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom + }; + + Controls.Add(cartesianChart); + } +} diff --git a/samples/WinFormsSample/Lines/CustomPoints/View.resx b/samples/WinFormsSample/Lines/CustomPoints/View.resx new file mode 100644 index 000000000..f298a7be8 --- /dev/null +++ b/samples/WinFormsSample/Lines/CustomPoints/View.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/WinFormsSample/Pies/Icons/View.Designer.cs b/samples/WinFormsSample/Pies/Icons/View.Designer.cs new file mode 100644 index 000000000..adab338e2 --- /dev/null +++ b/samples/WinFormsSample/Pies/Icons/View.Designer.cs @@ -0,0 +1,46 @@ + +namespace WinFormsSample.Pies.Icons +{ + partial class View + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // View + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Name = "View"; + this.Size = new System.Drawing.Size(427, 375); + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/samples/WinFormsSample/Pies/Icons/View.cs b/samples/WinFormsSample/Pies/Icons/View.cs new file mode 100644 index 000000000..ec23cab93 --- /dev/null +++ b/samples/WinFormsSample/Pies/Icons/View.cs @@ -0,0 +1,30 @@ +using System.Windows.Forms; +using LiveChartsCore.SkiaSharpView.WinForms; +using ViewModelsSamples.Pies.Icons; + +namespace WinFormsSample.Pies.Icons; + +public partial class View : UserControl +{ + private readonly PieChart pieChart; + + public View() + { + InitializeComponent(); + Size = new System.Drawing.Size(50, 50); + + var viewModel = new ViewModel(); + + pieChart = new PieChart + { + Series = viewModel.Series, + + // out of livecharts properties... + Location = new System.Drawing.Point(0, 0), + Size = new System.Drawing.Size(50, 50), + Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom + }; + + Controls.Add(pieChart); + } +} diff --git a/samples/WinFormsSample/Pies/Icons/View.resx b/samples/WinFormsSample/Pies/Icons/View.resx new file mode 100644 index 000000000..f298a7be8 --- /dev/null +++ b/samples/WinFormsSample/Pies/Icons/View.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml b/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml new file mode 100644 index 000000000..620142690 --- /dev/null +++ b/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml.cs b/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml.cs new file mode 100644 index 000000000..93ce2ccc8 --- /dev/null +++ b/samples/WinUISample/WinUISample/Lines/CustomPoints/View.xaml.cs @@ -0,0 +1,11 @@ +using Microsoft.UI.Xaml.Controls; + +namespace WinUISample.Lines.CustomPoints; + +public sealed partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/WinUISample/WinUISample/MainWindow.xaml b/samples/WinUISample/WinUISample/MainWindow.xaml index f8d7dc24f..44f1ee06b 100644 --- a/samples/WinUISample/WinUISample/MainWindow.xaml +++ b/samples/WinUISample/WinUISample/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + @@ -46,7 +46,7 @@ - + diff --git a/samples/WinUISample/WinUISample/Pies/Icons/View.xaml b/samples/WinUISample/WinUISample/Pies/Icons/View.xaml new file mode 100644 index 000000000..3037abfea --- /dev/null +++ b/samples/WinUISample/WinUISample/Pies/Icons/View.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/samples/WinUISample/WinUISample/Pies/Icons/View.xaml.cs b/samples/WinUISample/WinUISample/Pies/Icons/View.xaml.cs new file mode 100644 index 000000000..b4aac8d9a --- /dev/null +++ b/samples/WinUISample/WinUISample/Pies/Icons/View.xaml.cs @@ -0,0 +1,11 @@ +using Microsoft.UI.Xaml.Controls; + +namespace WinUISample.Pies.Icons; + +public sealed partial class View : UserControl +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/WinUISample/WinUISample/WinUISample.csproj b/samples/WinUISample/WinUISample/WinUISample.csproj index 79b65d54b..1bf3293eb 100644 --- a/samples/WinUISample/WinUISample/WinUISample.csproj +++ b/samples/WinUISample/WinUISample/WinUISample.csproj @@ -5,11 +5,12 @@ 10.0.17763.0 WinUISample app.manifest - x86;x64;arm64 - win-x86;win-x64;win-arm64 + x86;x64;ARM64 + win-x86;win-x64;win-arm64 + win10-x86;win10-x64;win10-arm64 win10-$(Platform).pubxml true - true + true @@ -23,8 +24,8 @@ - - + + @@ -34,6 +35,16 @@ + + + + true + + diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml b/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml new file mode 100644 index 000000000..cc79286de --- /dev/null +++ b/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml.cs b/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml.cs new file mode 100644 index 000000000..f37a72db6 --- /dev/null +++ b/samples/XamarinSample/XamarinSample/XamarinSample/Lines/CustomPoints/View.xaml.cs @@ -0,0 +1,13 @@ +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace XamarinSample.Lines.CustomPoints; + +[XamlCompilation(XamlCompilationOptions.Compile)] +public partial class View : ContentPage +{ + public View() + { + InitializeComponent(); + } +} diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/Pies/AngularGauge/View.xaml b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/AngularGauge/View.xaml index 0e3f515a1..99b882271 100644 --- a/samples/XamarinSample/XamarinSample/XamarinSample/Pies/AngularGauge/View.xaml +++ b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/AngularGauge/View.xaml @@ -22,7 +22,7 @@ InitialRotation="-225" MaxAngle="270" MinValue="0" - Total="100"> + MaxValue="100"> diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml new file mode 100644 index 000000000..0d932b1d4 --- /dev/null +++ b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml.cs b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml.cs new file mode 100644 index 000000000..a06f45ab4 --- /dev/null +++ b/samples/XamarinSample/XamarinSample/XamarinSample/Pies/Icons/View.xaml.cs @@ -0,0 +1,13 @@ +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace XamarinSample.Pies.Icons; + +[XamlCompilation(XamlCompilationOptions.Compile)] +public partial class View : ContentPage +{ + public View() + { + InitializeComponent(); + } +} diff --git a/src/LiveChartsCore.Behaviours/AssemblyInfo.cs b/src/LiveChartsCore.Behaviours/AssemblyInfo.cs index b803594ea..e5069d257 100644 --- a/src/LiveChartsCore.Behaviours/AssemblyInfo.cs +++ b/src/LiveChartsCore.Behaviours/AssemblyInfo.cs @@ -20,14 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#if !DEBUG -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyKeyFile("./../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno.WinUI, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WinUI")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno.WinUI")] -#endif diff --git a/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj b/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj index 3f69668aa..ac72e350e 100644 --- a/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj +++ b/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj @@ -27,7 +27,7 @@ LiveChartsCore.Behaviours LiveChartsCore.Behaviours - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Adds user interaction for touch screens, touch pads and mouse. MIT diff --git a/src/LiveChartsCore/AssemblyInfo.cs b/src/LiveChartsCore/AssemblyInfo.cs index ca13dc978..25b92af29 100644 --- a/src/LiveChartsCore/AssemblyInfo.cs +++ b/src/LiveChartsCore/AssemblyInfo.cs @@ -22,34 +22,28 @@ using System.Runtime.CompilerServices; -#if !DEBUG +#if !DEBUG && NET462 using System.Reflection; [assembly: AssemblyKeyFile("./../../LiveCharts.snk")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Avalonia, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WinForms, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WinUI, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno.WinUI, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WPF, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.XamarinForms, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Eto, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Blazor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Maui, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] + #else + [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Avalonia")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WinForms")] +[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WPF")] +[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Avalonia")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WinUI")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Uno.WinUI")] -[assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.WPF")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.XamarinForms")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Eto")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Blazor")] [assembly: InternalsVisibleTo("LiveChartsCore.SkiaSharpView.Maui")] [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] [assembly: InternalsVisibleTo("LiveChartsCore.UnitTesting")] + #endif diff --git a/src/LiveChartsCore/BarSeries.cs b/src/LiveChartsCore/BarSeries.cs index c5fc6b4b9..fea12a6f3 100644 --- a/src/LiveChartsCore/BarSeries.cs +++ b/src/LiveChartsCore/BarSeries.cs @@ -20,13 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; +using System.Collections; using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -39,11 +40,18 @@ namespace LiveChartsCore; /// The type of the drawing context. /// /// -public abstract class BarSeries - : StrokeAndFillCartesianSeries, IBarSeries - where TVisual : class, ISizedGeometry, new() - where TDrawingContext : DrawingContext - where TLabel : class, ILabelGeometry, new() +/// +/// Initializes a new instance of the class. +/// +/// The properties. +/// The values. +public abstract class BarSeries( + SeriesProperties properties, + ICollection? values) + : StrokeAndFillCartesianSeries(properties, values), IBarSeries + where TVisual : class, ISizedGeometry, new() + where TDrawingContext : DrawingContext + where TLabel : class, ILabelGeometry, new() { private double _pading = 2; private double _maxBarWidth = 50; @@ -52,18 +60,6 @@ public abstract class BarSeries private double _ry; private IPaint? _errorPaint; - /// - /// Initializes a new instance of the class. - /// - /// The properties. - protected BarSeries(SeriesProperties properties) - : base(properties) - { } - - /// - [Obsolete($"Replace by {nameof(Padding)} property.")] - public double GroupPadding { get => _pading; set => SetProperty(ref _pading, value); } - /// public double Padding { get => _pading; set => SetProperty(ref _pading, value); } @@ -87,6 +83,7 @@ public IPaint? ErrorPaint } /// + [System.Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -100,6 +97,20 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + return new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + /// /// A mesure helper class. /// @@ -216,6 +227,6 @@ protected override void OnPointerLeft(ChartPoint point) /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { Stroke, Fill, DataLabelsPaint, _errorPaint }; + return [Stroke, Fill, DataLabelsPaint, _errorPaint]; } } diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 82d24f8c3..8f5bf6284 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -40,14 +40,15 @@ namespace LiveChartsCore; public class CartesianChart : Chart where TDrawingContext : DrawingContext { - private readonly ISizedGeometry _zoomingSection; private readonly ICartesianChartView _chartView; + private ISizedGeometry? _zoomingSection; private int _nextSeries = 0; private double _zoomingSpeed = 0; private ZoomAndPanMode _zoomMode; private DrawMarginFrame? _previousDrawMarginFrame; private const double MaxAxisBound = 0.05; private const double MaxAxisActiveBound = 0.15; + private HashSet>? _sharedEvents; private HashSet> _crosshair = []; /// @@ -56,20 +57,13 @@ public class CartesianChart : Chart /// The view. /// The default platform configuration. /// The canvas. - /// The zooming section. public CartesianChart( ICartesianChartView view, Action defaultPlatformConfig, - MotionCanvas canvas, - ISizedGeometry? zoomingSection) + MotionCanvas canvas) : base(canvas, defaultPlatformConfig, view) { _chartView = view; - _zoomingSection = zoomingSection ?? throw new Exception($"{nameof(zoomingSection)} is required."); - _zoomingSection.X = -1; - _zoomingSection.Y = -1; - _zoomingSection.Width = 0; - _zoomingSection.Height = 0; } /// @@ -232,6 +226,10 @@ public void Zoom(LvcPoint pivot, ZoomDirection direction, double? scaleFactor = if (maxt > limits.DataMax && direction == ZoomDirection.ZoomOut) maxt = limits.DataMax + xm; if (mint < limits.DataMin && direction == ZoomDirection.ZoomOut) mint = limits.DataMin - xm; + // even on inverted axes, this is not supported, + // inverted axes handles this just with the magic of math.. + if (maxt < mint) (maxt, mint) = (mint, maxt); + xi.SetLimits(mint, maxt); } } @@ -287,6 +285,10 @@ public void Zoom(LvcPoint pivot, ZoomDirection direction, double? scaleFactor = if (maxt > limits.DataMax && direction == ZoomDirection.ZoomOut) maxt = limits.DataMax + ym; if (mint < limits.DataMin && direction == ZoomDirection.ZoomOut) mint = limits.DataMin - ym; + // even on inverted axes, this is not supported, + // inverted axes handles this just with the magic of math.. + if (maxt < mint) (maxt, mint) = (mint, maxt); + yi.SetLimits(mint, maxt); } } @@ -380,7 +382,7 @@ protected internal override void Measure() { Trace.WriteLine( $"[Cartesian chart measured]".PadRight(60) + - $"tread: {Environment.CurrentManagedThreadId}"); + $"thread: {Environment.CurrentManagedThreadId}"); } #endif @@ -444,18 +446,18 @@ protected internal override void Measure() #endregion SeriesContext = new SeriesContext(VisibleSeries, this); - var isNewTheme = LiveCharts.DefaultSettings.CurrentThemeId != ThemeId; + var themeId = LiveCharts.DefaultSettings.CurrentThemeId; // restart axes bounds and meta data foreach (var axis in XAxes) { var ce = (ChartElement)axis; ce._isInternalSet = true; - axis.Initialize(AxisOrientation.X); - if (!ce._isThemeSet || isNewTheme) + axis.OnMeasureStarted(this, AxisOrientation.X); + if (ce._theme != themeId) { theme.ApplyStyleToAxis((IPlane)axis); - ce._isThemeSet = true; + ce._theme = themeId; } ce._isInternalSet = false; if (axis.CrosshairPaint is not null) _crosshair.Add(axis); @@ -464,11 +466,11 @@ protected internal override void Measure() { var ce = (ChartElement)axis; ce._isInternalSet = true; - axis.Initialize(AxisOrientation.Y); - if (!ce._isThemeSet || isNewTheme) + axis.OnMeasureStarted(this, AxisOrientation.Y); + if (ce._theme != themeId) { theme.ApplyStyleToAxis((IPlane)axis); - ce._isThemeSet = true; + ce._theme = themeId; } ce._isInternalSet = false; if (axis.CrosshairPaint is not null) _crosshair.Add(axis); @@ -483,10 +485,10 @@ protected internal override void Measure() var ce = (ChartElement)series; ce._isInternalSet = true; - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { theme.ApplyStyleToSeries(series); - ce._isThemeSet = true; + ce._theme = themeId; } var xAxis = XAxes[series.ScalesXAt]; @@ -708,8 +710,9 @@ protected internal override void Measure() axis.Xo = ls + w * 0.5f + ns.Width; ls += w + ns.Width; m.Left = ls; - if (s.Height * 0.5f > m.Top) { m.Top = s.Height * 0.5f; } - if (s.Height * 0.5f > m.Bottom) { m.Bottom = s.Height * 0.5f; } + + if (s.Height * 0.5f > m.Top) m.Top = s.Height * 0.5f; + if (s.Height * 0.5f > m.Bottom) m.Bottom = s.Height * 0.5f; } } else @@ -740,8 +743,9 @@ protected internal override void Measure() axis.Xo = rs + w * 0.5f + ns.Width; rs += w + ns.Width; m.Right = rs; - if (ts + s.Height * 0.5f > m.Top) m.Top = ts + s.Height * 0.5f; - if (bs + s.Height * 0.5f > m.Bottom) m.Bottom = bs + s.Height * 0.5f; + + if (s.Height * 0.5f > m.Top) m.Top = s.Height * 0.5f; + if (s.Height * 0.5f > m.Bottom) m.Bottom = s.Height * 0.5f; } } } @@ -814,9 +818,15 @@ protected internal override void Measure() ((ChartElement)axis).RemoveOldPaints(View); // <- this is probably obsolete. // the probable issue is the "IsVisible" property } - foreach (var section in Sections) AddVisual(section); - foreach (var visual in VisualElements) AddVisual(visual); - foreach (var series in VisibleSeries) + + // we draw all the series even invisible because it animates the series when hidden. + // Sections and Visuals are not animated when hidden, thus we just skip them. + // it means that invisible series have a performance impact, it should not be a big deal + // but ideally, do not keep invisible series in the chart, instead, add/remove them when needed. + + foreach (var section in Sections.Where(x => x.IsVisible)) AddVisual(section); + foreach (var visual in VisualElements.Where(x => x.IsVisible)) AddVisual(visual); + foreach (var series in Series) { AddVisual((ChartElement)series); _drawnSeries.Add(series.SeriesId); @@ -832,15 +842,15 @@ protected internal override void Measure() if (_chartView.DrawMarginFrame is not null) { var ce = (ChartElement)_chartView.DrawMarginFrame; - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { ce._isInternalSet = true; theme.ApplyStyleToDrawMargin(_chartView.DrawMarginFrame); - ce._isThemeSet = true; + ce._theme = themeId; ce._isInternalSet = false; } - AddVisual(_chartView.DrawMarginFrame); + if (_chartView.DrawMarginFrame.IsVisible) AddVisual(_chartView.DrawMarginFrame); _previousDrawMarginFrame = _chartView.DrawMarginFrame; } @@ -861,8 +871,7 @@ protected internal override void Measure() IsZoomingOrPanning = false; InvokeOnUpdateStarted(); - if (_isToolTipOpen) DrawToolTip(); - ThemeId = LiveCharts.DefaultSettings.CurrentThemeId; + if (_isToolTipOpen) _ = DrawToolTip(); Canvas.Invalidate(); _isFirstDraw = false; @@ -873,12 +882,19 @@ public override void Unload() { base.Unload(); _crosshair = []; + _sharedEvents = null; + _zoomingSection = null; _isFirstDraw = true; } private LvcPoint? _sectionZoomingStart = null; - internal override void InvokePointerDown(LvcPoint point, bool isSecondaryAction) + /// + /// Invokes the pointer down. + /// + /// The pointer position. + /// Flags the action as secondary (normally rigth click or double tap on mobile) + protected internal override void InvokePointerDown(LvcPoint point, bool isSecondaryAction) { var caretesianView = (ICartesianChartView)View; if ((caretesianView.ZoomMode & ZoomAndPanMode.InvertPanningPointerTrigger) != 0) @@ -886,6 +902,10 @@ internal override void InvokePointerDown(LvcPoint point, bool isSecondaryAction) if (isSecondaryAction && _zoomMode != ZoomAndPanMode.None) { + if (_zoomingSection is null) InitializeZoomingSection(); + if (_zoomingSection is null) + throw new Exception("Something went wrong when initializing the zoomming section."); + _sectionZoomingStart = point; var x = point.X; @@ -922,15 +942,18 @@ internal override void InvokePointerDown(LvcPoint point, bool isSecondaryAction) base.InvokePointerDown(point, isSecondaryAction); } - internal override void InvokePointerMove(LvcPoint point) + /// + /// Invokes the pointer move. + /// + /// The pointer position. + protected internal override void InvokePointerMove(LvcPoint point) { - foreach (var axis in _crosshair) - { - axis.InvalidateCrosshair(this, point); - } + InvalidateCrosshairs(this, point); if (_sectionZoomingStart is not null) { + if (_zoomingSection is null) return; + var xMode = (_zoomMode & ZoomAndPanMode.X) == ZoomAndPanMode.X; var yMode = (_zoomMode & ZoomAndPanMode.Y) == ZoomAndPanMode.Y; @@ -952,10 +975,17 @@ internal override void InvokePointerMove(LvcPoint point) base.InvokePointerMove(point); } - internal override void InvokePointerUp(LvcPoint point, bool isSecondaryAction) + /// + /// Invokes the pointer up. + /// + /// The pointer position. + /// Flags the action as secondary (normally rigth click or double tap on mobile) + protected internal override void InvokePointerUp(LvcPoint point, bool isSecondaryAction) { if (_sectionZoomingStart is not null) { + if (_zoomingSection is null) return; + var xy = Math.Sqrt(Math.Pow(point.X - _sectionZoomingStart.Value.X, 2) + Math.Pow(point.Y - _sectionZoomingStart.Value.Y, 2)); if (xy < 15) { @@ -997,19 +1027,17 @@ internal override void InvokePointerUp(LvcPoint point, bool isSecondaryAction) if (xMax - xMin > min) { - x.MinLimit = xMin; - x.MaxLimit = xMax; + x.SetLimits(xMin, xMax); } else { if (x.MaxLimit is not null && x.MinLimit is not null) { var d = xMax - xMin; - var ad = x.MaxLimit - x.MinLimit; + var ad = x.MaxLimit.Value - x.MinLimit.Value; var c = (ad - d) * 0.5; - x.MinLimit = xMin - c; - x.MaxLimit = xMax + c; + x.SetLimits(xMin - c, xMax + c); } } } @@ -1044,19 +1072,17 @@ internal override void InvokePointerUp(LvcPoint point, bool isSecondaryAction) if (yMax - yMin > min) { - y.MinLimit = yMin; - y.MaxLimit = yMax; + y.SetLimits(yMin, yMax); } else { if (y.MaxLimit is not null && y.MinLimit is not null) { var d = yMax - yMin; - var ad = y.MaxLimit - y.MinLimit; + var ad = y.MaxLimit.Value - y.MinLimit.Value; var c = (ad - d) * 0.5; - y.MinLimit = yMin - c; - y.MaxLimit = yMax + c; + y.SetLimits(yMin - c, yMax + c); } } } @@ -1067,12 +1093,64 @@ internal override void InvokePointerUp(LvcPoint point, bool isSecondaryAction) _zoomingSection.Width = 0; _zoomingSection.Height = 0; _sectionZoomingStart = null; + return; } base.InvokePointerUp(point, isSecondaryAction); } + /// + protected internal override void InvokePointerLeft() + { + OnPointerLeft(); + + //propagate to shared charts + foreach (var sharedChart in _sharedEvents ?? []) + { + if (sharedChart == this) continue; + + sharedChart.OnPointerLeft(); + } + } + + internal void SubscribeSharedEvents(HashSet> instance) + { + // An experimental feature, it allows a chart to propagate some events to other charts, + // this feature was created to share crosshairs between multiple charts. + + _sharedEvents = instance; + _ = _sharedEvents.Add(this); + } + + private void OnPointerLeft() => base.InvokePointerLeft(); + + private void InvalidateCrosshairs(Chart chart, LvcPoint point) + { + foreach (var axis in _crosshair) + axis.InvalidateCrosshair(chart, point); + + //propagate to shared charts + foreach (var sharedChart in _sharedEvents ?? []) + { + if (sharedChart == this) continue; + + foreach (var axis in sharedChart._crosshair) + axis.InvalidateCrosshair(sharedChart, point); + } + } + + private void InitializeZoomingSection() + { + var provider = LiveCharts.DefaultSettings.GetProvider(); + _zoomingSection = provider.InitializeZoommingSection(Canvas); + + _zoomingSection.X = -1; + _zoomingSection.Y = -1; + _zoomingSection.Width = 0; + _zoomingSection.Height = 0; + } + private static void AppendLimits(ICartesianAxis x, ICartesianAxis y, DimensionalBounds bounds) { x.DataBounds.AppendValue(bounds.SecondaryBounds); diff --git a/src/LiveChartsCore/CartesianSeries.cs b/src/LiveChartsCore/CartesianSeries.cs index 2f1f08d8b..c422c0fca 100644 --- a/src/LiveChartsCore/CartesianSeries.cs +++ b/src/LiveChartsCore/CartesianSeries.cs @@ -39,11 +39,18 @@ namespace LiveChartsCore; /// /// /// -public abstract class CartesianSeries - : ChartSeries, ICartesianSeries - where TDrawingContext : DrawingContext - where TVisual : class, IGeometry, new() - where TLabel : class, ILabelGeometry, new() +/// +/// Initializes a new instance of the class. +/// +/// The series properties. +/// The values. +public abstract class CartesianSeries( + SeriesProperties properties, + ICollection? values) + : ChartSeries(properties, values), ICartesianSeries + where TDrawingContext : DrawingContext + where TVisual : class, IGeometry, new() + where TLabel : class, ILabelGeometry, new() { private int _scalesXAt; private int _scalesYAt; @@ -53,12 +60,6 @@ public abstract class CartesianSeries private Func, string>? _yTooltipLabelFormatter; private ClipMode _clippingMode = ClipMode.XY; - /// - /// Initializes a new instance of the class. - /// - /// The series properties. - protected CartesianSeries(SeriesProperties properties) : base(properties) { } - /// public int ScalesXAt { get => _scalesXAt; set => SetProperty(ref _scalesXAt, value); } @@ -287,8 +288,6 @@ public override void SoftDeleteOrDispose(IChartView chart) } foreach (var item in deleted) _ = everFetched.Remove(item); - - OnVisibilityChanged(); } /// diff --git a/src/LiveChartsCore/Chart.cs b/src/LiveChartsCore/Chart.cs index 702b7f118..f9885b3cf 100644 --- a/src/LiveChartsCore/Chart.cs +++ b/src/LiveChartsCore/Chart.cs @@ -130,14 +130,6 @@ protected Chart( /// public object MeasureWork { get; protected set; } = new(); - /// - /// Gets or sets the theme identifier. - /// - /// - /// The theme identifier. - /// - public object ThemeId { get; protected set; } = new(); - /// /// Gets whether the control is loaded. /// @@ -322,7 +314,12 @@ public virtual void Unload() Canvas.Dispose(); } - internal virtual void InvokePointerDown(LvcPoint point, bool isSecondaryAction) + /// + /// Invokes the pointer down event. + /// + /// The pointer position. + /// Flags the action as secondary (normally rigth click or double tap on mobile) + protected internal virtual void InvokePointerDown(LvcPoint point, bool isSecondaryAction) { _isPanning = true; _pointerPreviousPanningPosition = point; @@ -364,7 +361,11 @@ internal virtual void InvokePointerDown(LvcPoint point, bool isSecondaryAction) } } - internal virtual void InvokePointerMove(LvcPoint point) + /// + /// Invokes the pointer move event. + /// + /// The pointer position. + protected internal virtual void InvokePointerMove(LvcPoint point) { _pointerPosition = point; _isPointerIn = true; @@ -375,7 +376,12 @@ internal virtual void InvokePointerMove(LvcPoint point) _panningThrottler.Call(); } - internal virtual void InvokePointerUp(LvcPoint point, bool isSecondaryAction) + /// + /// Invokes the pointer up event. + /// + /// The pointer position. + /// Flags the action as secondary (normally rigth click or double tap on mobile) + protected internal virtual void InvokePointerUp(LvcPoint point, bool isSecondaryAction) { #if NET5_0_OR_GREATER if (_isMobile) @@ -395,7 +401,10 @@ internal virtual void InvokePointerUp(LvcPoint point, bool isSecondaryAction) _panningThrottler.Call(); } - internal void InvokePointerLeft() + /// + /// Invokes the pointer out event. + /// + protected internal virtual void InvokePointerLeft() { View.InvokeOnUIThread(CloseTooltip); _isPointerIn = false; @@ -574,6 +583,9 @@ protected void CollectVisuals() if (visual is ISeries series) { // series delete softly and animate as they leave the UI. + // UPDATE + // actually series are not even removed sofly.. this is only disposing things + // and causes bugs such as #1164 series.SoftDeleteOrDispose(View); } else @@ -618,7 +630,8 @@ protected void DrawLegend(ref float ts, ref float bs, ref float ls, ref float rs /// /// Draws the current tool tip, requires canvas invalidation after this call. /// - protected void DrawToolTip() + /// A value indicating whether the tooltip was drawn. + protected bool DrawToolTip() { var x = _pointerPosition.X; var y = _pointerPosition.Y; @@ -627,7 +640,7 @@ protected void DrawToolTip() x < DrawMarginLocation.X || x > DrawMarginLocation.X + DrawMarginSize.Width || y < DrawMarginLocation.Y || y > DrawMarginLocation.Y + DrawMarginSize.Height) { - return; + return false; } var points = FindHoveredPointsBy(_pointerPosition); @@ -643,10 +656,12 @@ protected void DrawToolTip() CleanHoveredPoints(o); - if (isEmpty) return; + if (isEmpty) return true; Tooltip?.Show(points, this); _isToolTipOpen = true; + + return true; } private void CleanHoveredPoints(object comparer) @@ -670,7 +685,9 @@ private Task TooltipThrottlerUnlocked() #if NET5_0_OR_GREATER if (_isTooltipCanceled) return; #endif - DrawToolTip(); + var tooltipDrawn = DrawToolTip(); + if (!tooltipDrawn) return; + Canvas.Invalidate(); } })); diff --git a/src/LiveChartsCore/ChartSeries.cs b/src/LiveChartsCore/ChartSeries.cs index 5946b4fbc..31b4194c0 100644 --- a/src/LiveChartsCore/ChartSeries.cs +++ b/src/LiveChartsCore/ChartSeries.cs @@ -36,11 +36,18 @@ namespace LiveChartsCore; /// The type of the drawing context. /// /// -public abstract class ChartSeries - : Series, IChartSeries - where TDrawingContext : DrawingContext - where TVisual : class, IGeometry, new() - where TLabel : class, ILabelGeometry, new() +/// +/// Initializes a new instance of the class. +/// +/// The properties. +/// The values. +public abstract class ChartSeries( + SeriesProperties properties, + ICollection? values) + : Series(properties, values), IChartSeries + where TDrawingContext : DrawingContext + where TVisual : class, IGeometry, new() + where TLabel : class, ILabelGeometry, new() { private IPaint? _dataLabelsPaint; private double _dataLabelsSize = 16; @@ -48,12 +55,6 @@ public abstract class ChartSeries private Padding _dataLabelsPadding = new() { Left = 6, Top = 8, Right = 6, Bottom = 8 }; private double _dataLabelsMaxWidth = LiveCharts.DefaultSettings.MaxTooltipsAndLegendsLabelsWidth; - /// - /// Initializes a new instance of the class. - /// - /// The properties. - protected ChartSeries(SeriesProperties properties) : base(properties) { } - /// public IPaint? DataLabelsPaint { diff --git a/src/LiveChartsCore/ConditionalDraw/ConditinalExtensions.cs b/src/LiveChartsCore/ConditionalDraw/ConditinalExtensions.cs index b7f865dd4..20a392b0f 100644 --- a/src/LiveChartsCore/ConditionalDraw/ConditinalExtensions.cs +++ b/src/LiveChartsCore/ConditionalDraw/ConditinalExtensions.cs @@ -54,24 +54,4 @@ public static Series OnPointMeasured - /// Returns a for the given paint. - /// - /// The type of the model. - /// The type of the visual. - /// The type of the label. - /// The type of the drawing context. - /// The series. - /// The paint. - /// - [Obsolete($"Use {nameof(OnPointMeasured)} instead.")] - public static ConditionalPaintBuilder WithConditionalPaint( - this Series series, IPaint paint) - where TDrawingContext : DrawingContext - where TVisual : class, IGeometry, new() - where TLabel : class, ILabelGeometry, new() - { - return new ConditionalPaintBuilder(series, paint); - } } diff --git a/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs b/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs deleted file mode 100644 index afa727ce9..000000000 --- a/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs +++ /dev/null @@ -1,109 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using LiveChartsCore.Drawing; -using LiveChartsCore.Kernel; - -namespace LiveChartsCore.ConditionalDraw; - -/// -/// Defines a instance. -/// -/// -/// Initializes a new builder for the given paint. -/// -/// The series. -/// The paint. -[Obsolete("Replaced by MaPoints extensiion.")] -public class ConditionalPaintBuilder(Series series, IPaint paint) - where TDrawingContext : DrawingContext - where TVisual : class, IGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ - private bool _isPaintInCanvas = false; - private object _clipFor = new(); - private Func, bool>? _whenPredicate; - - /// - /// Applies the paint when the given condition is true. - /// - /// - public Series When( - Func, bool> predicate) - { - _whenPredicate = predicate; - series.PointMeasured += OnMeasured; - return series; - } - - /// - /// Un-subscribes the generated event handlers from the target series. - /// - public void UnSubscribe() - { - series.PointMeasured -= OnMeasured; - } - - private void OnMeasured(ChartPoint point) - { - if (_whenPredicate is null || point.Visual is null) return; - - var isTriggered = _whenPredicate.Invoke(point); - var canvas = ((Chart)point.Context.Chart.CoreChart).Canvas; - var drawable = (IDrawable?)point.Visual; // see note #20221909 - if (drawable is null) return; - - if (!_isPaintInCanvas) - { - canvas.AddDrawableTask(paint); - if (paint.ZIndex == 0) paint.ZIndex = int.MaxValue; - _isPaintInCanvas = true; - } - - if (point.Context.Chart.CoreChart.MeasureWork != _clipFor) - { - _clipFor = point.Context.Chart.CoreChart.MeasureWork; - if (point.Context.Chart.CoreChart is CartesianChart cartesianChart) - { - var drawLocation = cartesianChart.DrawMarginLocation; - var drawMarginSize = cartesianChart.DrawMarginSize; - paint.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize)); - } - } - - if (isTriggered) - { - paint.AddGeometryToPaintTask(canvas, drawable); - - foreach (var paint in series.GetPaintTasks()) - { - if (paint is null) continue; - paint.RemoveGeometryFromPainTask(canvas, drawable); - } - } - else - { - paint.RemoveGeometryFromPainTask(canvas, drawable); - } - } -} diff --git a/src/LiveChartsCore/CoreAxis.cs b/src/LiveChartsCore/CoreAxis.cs index 0a5b9af2e..ce1329f90 100644 --- a/src/LiveChartsCore/CoreAxis.cs +++ b/src/LiveChartsCore/CoreAxis.cs @@ -91,7 +91,6 @@ public abstract class CoreAxis private IPaint? _crosshairLabelsPaint; private LvcColor? _crosshairLabelsBackground; private bool _showSeparatorLines = true; - private bool _isVisible = true; private bool _isInverted; private bool _separatorsAtCenter = true; private bool _ticksAtCenter = true; @@ -102,6 +101,7 @@ public abstract class CoreAxis private Align? _labelsAlignment; private bool _inLineNamePlacement; private IEnumerable? _customSeparators; + private float _labelsDensity = 0.85f; internal double? _logBase; #endregion @@ -141,6 +141,9 @@ public abstract class CoreAxis /// public Padding Padding { get => _padding; set => SetProperty(ref _padding, value); } + /// + public float LabelsDensity { get => _labelsDensity; set => SetProperty(ref _labelsDensity, value); } + /// public Func Labeler { get => _labeler; set => SetProperty(ref _labeler, value); } @@ -177,9 +180,6 @@ public abstract class CoreAxis /// public IEnumerable? CustomSeparators { get => _customSeparators; set => SetProperty(ref _customSeparators, value); } - /// - public bool IsVisible { get => _isVisible; set => SetProperty(ref _isVisible, value); } - /// public bool IsInverted { get => _isInverted; set => SetProperty(ref _isInverted, value); } @@ -278,18 +278,6 @@ public LvcColor? CrosshairLabelsBackground /// public bool CrosshairSnapEnabled { get => _crosshairSnapEnabled; set => SetProperty(ref _crosshairSnapEnabled, value); } - /// - /// - /// - [Obsolete("Renamed to LabelsPaint")] - public IPaint? TextBrush { get => LabelsPaint; set => LabelsPaint = value; } - - /// - /// - /// - [Obsolete("Renamed to SeparatorsPaint")] - public IPaint? SeparatorsBrush { get => SeparatorsPaint; set => SeparatorsPaint = value; } - /// public TimeSpan? AnimationsSpeed { get; set; } @@ -307,8 +295,8 @@ public LvcColor? CrosshairLabelsBackground #endregion - /// - public event Action? Initialized; + /// + public event Action? MeasureStarted; /// public override void Invalidate(Chart chart) @@ -950,15 +938,15 @@ public void SetLimits(double min, double max) MaxLimit = max; } - /// - void ICartesianAxis.Initialize(AxisOrientation orientation) + /// + void ICartesianAxis.OnMeasureStarted(IChart chart, AxisOrientation orientation) { _orientation = orientation; _dataBounds = new Bounds(); _visibleDataBounds = new Bounds(); _animatableBounds ??= new(); _possibleMaxLabelsSize = null; - Initialized?.Invoke(this); + MeasureStarted?.Invoke(chart, this); } /// diff --git a/src/LiveChartsCore/CoreBoxSeries.cs b/src/LiveChartsCore/CoreBoxSeries.cs index a5c50b3c7..313b01fd3 100644 --- a/src/LiveChartsCore/CoreBoxSeries.cs +++ b/src/LiveChartsCore/CoreBoxSeries.cs @@ -21,12 +21,14 @@ // SOFTWARE. using System; +using System.Collections; using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -54,10 +56,8 @@ public abstract class CoreBoxSeries /// Initializes a new instance of the class. /// - protected CoreBoxSeries() - : base( - SeriesProperties.BoxSeries | SeriesProperties.PrimaryAxisVerticalOrientation | - SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips) + protected CoreBoxSeries(ICollection? values) + : base(GetProperties(), values) { YToolTipLabelFormatter = p => { @@ -152,7 +152,7 @@ public override void Invalidate(Chart chart) var median = primaryScale.ToPixels(coordinate.SenaryValue); var middle = open; - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -340,6 +340,7 @@ public override SeriesBounds GetBounds( } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -353,6 +354,20 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + return new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + /// protected override double GetRequestedSecondaryOffset() { @@ -503,4 +518,10 @@ public MeasureHelper( /// public float uw, uwm, cp, p, actualUw; } + + private static SeriesProperties GetProperties() + { + return SeriesProperties.BoxSeries | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips; + } } diff --git a/src/LiveChartsCore/CoreColumnSeries.cs b/src/LiveChartsCore/CoreColumnSeries.cs index d4fe48af2..0f3ea53fb 100644 --- a/src/LiveChartsCore/CoreColumnSeries.cs +++ b/src/LiveChartsCore/CoreColumnSeries.cs @@ -21,6 +21,7 @@ // SOFTWARE. using System; +using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Drawing; @@ -37,21 +38,20 @@ namespace LiveChartsCore; /// the type of the label. /// The type of the drawing context. /// The type of the error geometry. -public abstract class CoreColumnSeries : BarSeries - where TVisual : class, ISizedGeometry, new() - where TDrawingContext : DrawingContext - where TLabel : class, ILabelGeometry, new() - where TErrorGeometry : class, ILineGeometry, new() +public abstract class CoreColumnSeries + : BarSeries + where TVisual : class, ISizedGeometry, new() + where TDrawingContext : DrawingContext + where TLabel : class, ILabelGeometry, new() + where TErrorGeometry : class, ILineGeometry, new() { private readonly bool _isRounded = false; /// /// Initializes a new instance of the class. /// - protected CoreColumnSeries(bool isStacked = false) - : base( - SeriesProperties.Bar | SeriesProperties.PrimaryAxisVerticalOrientation | - SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips | (isStacked ? SeriesProperties.Stacked : 0)) + protected CoreColumnSeries(ICollection? values, bool isStacked = false) + : base(GetProperties(isStacked), values) { DataPadding = new LvcPoint(0, 1); _isRounded = typeof(IRoundedGeometry).IsAssignableFrom(typeof(TVisual)); @@ -119,7 +119,7 @@ public override void Invalidate(Chart chart) var ry = (float)Ry; var stacker = isStacked ? cartesianChart.SeriesContext.GetStackPosition(this, GetStackGroup()) : null; - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -134,7 +134,7 @@ public override void Invalidate(Chart chart) var secondary = secondaryScale.ToPixels(coordinate.SecondaryValue); var b = Math.Abs(primary - helper.p); - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -207,7 +207,7 @@ public override void Invalidate(Chart chart) if (hasSvg) { - var svgVisual = (ISvgPath)visual; + var svgVisual = (IVariableSvgPath)visual; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -394,4 +394,11 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal label.TextSize = 1; label.RemoveOnCompleted = true; } + + private static SeriesProperties GetProperties(bool isStacked) + { + return SeriesProperties.Bar | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips | + (isStacked ? SeriesProperties.Stacked : 0); + } } diff --git a/src/LiveChartsCore/CoreFinancialSeries.cs b/src/LiveChartsCore/CoreFinancialSeries.cs index a4456d788..0e85813ed 100644 --- a/src/LiveChartsCore/CoreFinancialSeries.cs +++ b/src/LiveChartsCore/CoreFinancialSeries.cs @@ -22,12 +22,14 @@ // SOFTWARE. using System; +using System.Collections; using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -58,10 +60,8 @@ public abstract class CoreFinancialSeries /// Initializes a new instance of the class. /// - protected CoreFinancialSeries() - : base( - SeriesProperties.Financial | SeriesProperties.PrimaryAxisVerticalOrientation | - SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips) + protected CoreFinancialSeries(ICollection? values) + : base(GetProperties(), values) { YToolTipLabelFormatter = p => { @@ -189,7 +189,7 @@ public override void Invalidate(Chart chart) var low = primaryScale.ToPixels(coordinate.QuinaryValue); var middle = open; - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -442,7 +442,7 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { _upFill, _upStroke, _downFill, _downStroke, DataLabelsPaint }; + return [_upFill, _upStroke, _downFill, _downStroke, DataLabelsPaint]; } /// @@ -477,6 +477,7 @@ protected override void OnPaintChanged(string? propertyName) } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -488,4 +489,21 @@ public override Sketch GetMiniaturesSketch() PaintSchedules = schedules }; } + + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + // No miniature. + return new GeometryVisual + { + Width = 0, + Height = 0 + }; + } + + private static SeriesProperties GetProperties() + { + return SeriesProperties.Financial | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips; + } } diff --git a/src/LiveChartsCore/CoreHeatLandSeries.cs b/src/LiveChartsCore/CoreHeatLandSeries.cs index 9545fec6c..f749b3a8c 100644 --- a/src/LiveChartsCore/CoreHeatLandSeries.cs +++ b/src/LiveChartsCore/CoreHeatLandSeries.cs @@ -35,26 +35,31 @@ namespace LiveChartsCore; /// /// Defines the heat land series class. /// -/// -public class CoreHeatLandSeries : IGeoSeries, INotifyPropertyChanged +/// The type fo the model. +/// The type of the drawing context. +public class CoreHeatLandSeries : IGeoSeries, INotifyPropertyChanged + where TModel : IWeigthedMapLand where TDrawingContext : DrawingContext { private IPaint? _heatPaint; private bool _isHeatInCanvas = false; private LvcColor[] _heatMap = []; private double[]? _colorStops; - private IEnumerable? _lands; + private ICollection? _lands; private bool _isVisible; private readonly HashSet> _subscribedTo = []; - private readonly CollectionDeepObserver _observer; + private readonly CollectionDeepObserver _observer; private readonly HashSet _everUsed = []; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CoreHeatLandSeries() + /// The lands. + public CoreHeatLandSeries(ICollection? lands) { - _observer = new CollectionDeepObserver( + Lands = lands; + + _observer = new CollectionDeepObserver( (sender, e) => NotifySubscribers(), (sender, e) => NotifySubscribers()); } @@ -82,7 +87,7 @@ public CoreHeatLandSeries() /// /// Gets or sets the lands. /// - public IEnumerable? Lands + public ICollection? Lands { get => _lands; set @@ -114,7 +119,7 @@ public void Measure(MapContext context) _heatPaint.ZIndex = i + 1; var bounds = new Bounds(); - foreach (var shape in Lands ?? Enumerable.Empty()) + foreach (var shape in Lands ?? []) { bounds.AppendValue(shape.Value); } @@ -123,10 +128,10 @@ public void Measure(MapContext context) var shapeContext = new MapShapeContext(context.View, _heatPaint, heatStops, bounds); var toRemove = new HashSet(_everUsed); - foreach (var land in Lands ?? Enumerable.Empty()) + foreach (var land in Lands ?? []) { var projector = Maps.BuildProjector( - context.View.MapProjection, new[] { context.View.Width, context.View.Height }); + context.View.MapProjection, [context.View.Width, context.View.Height]); var heat = HeatFunctions.InterpolateColor((float)land.Value, bounds, HeatMap, heatStops); diff --git a/src/LiveChartsCore/CoreHeatSeries.cs b/src/LiveChartsCore/CoreHeatSeries.cs index 70acf8b4c..e7ba81c40 100644 --- a/src/LiveChartsCore/CoreHeatSeries.cs +++ b/src/LiveChartsCore/CoreHeatSeries.cs @@ -27,6 +27,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -48,20 +49,21 @@ public abstract class CoreHeatSeries private int _heatKnownLength = 0; private List> _heatStops = []; private LvcColor[] _heatMap = - { + [ LvcColor.FromArgb(255, 87, 103, 222), // cold (min value) LvcColor.FromArgb(255, 95, 207, 249) // hot (max value) - }; + ]; private double[]? _colorStops; private Padding _pointPadding = new(4); + private double? _minValue; + private double? _maxValue; /// /// Initializes a new instance of the class. /// - protected CoreHeatSeries() - : base( - SeriesProperties.Heat | SeriesProperties.PrimaryAxisVerticalOrientation | - SeriesProperties.Solid | SeriesProperties.PrefersXYStrategyTooltips) + /// The values. + protected CoreHeatSeries(ICollection? values) + : base(GetProperties(), values) { DataPadding = new LvcPoint(0, 0); YToolTipLabelFormatter = (point) => @@ -85,11 +87,7 @@ protected CoreHeatSeries() public LvcColor[] HeatMap { get => _heatMap; - set - { - OnMiniatureChanged(); - SetProperty(ref _heatMap, value); - } + set => SetProperty(ref _heatMap, value); } /// @@ -98,6 +96,12 @@ public LvcColor[] HeatMap /// public Padding PointPadding { get => _pointPadding; set => SetProperty(ref _pointPadding, value); } + /// + public double? MinValue { get => _minValue; set => SetProperty(ref _minValue, value); } + + /// + public double? MaxValue { get => _maxValue; set => SetProperty(ref _maxValue, value); } + /// public override void Invalidate(Chart chart) { @@ -144,7 +148,7 @@ public override void Invalidate(Chart chart) _heatKnownLength = HeatMap.Length; } - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -158,7 +162,7 @@ public override void Invalidate(Chart chart) var baseColor = HeatFunctions.InterpolateColor(tertiary, _weightBounds, HeatMap, _heatStops); - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -207,7 +211,7 @@ public override void Invalidate(Chart chart) if (hasSvg) { - var svgVisual = (ISvgPath)visual; + var svgVisual = (IVariableSvgPath)visual; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -271,7 +275,8 @@ public override void Invalidate(Chart chart) public override SeriesBounds GetBounds(CartesianChart chart, ICartesianAxis secondaryAxis, ICartesianAxis primaryAxis) { var seriesBounds = base.GetBounds(chart, secondaryAxis, primaryAxis); - _weightBounds = seriesBounds.Bounds.TertiaryBounds; + var b = seriesBounds.Bounds.TertiaryBounds; + _weightBounds = new(_minValue ?? b.Min, _maxValue ?? b.Max); return seriesBounds; } @@ -322,6 +327,7 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -352,9 +358,27 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + // ToDo <- draw the gradient? + // what to show in the legend? + return new GeometryVisual + { + Width = 0, + Height = 0, + }; + } + /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { _paintTaks }; + return [_paintTaks]; + } + + private static SeriesProperties GetProperties() + { + return SeriesProperties.Heat | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Solid | SeriesProperties.PrefersXYStrategyTooltips; } } diff --git a/src/LiveChartsCore/CoreLineSeries.cs b/src/LiveChartsCore/CoreLineSeries.cs index 02dab12b0..c9ee6d119 100644 --- a/src/LiveChartsCore/CoreLineSeries.cs +++ b/src/LiveChartsCore/CoreLineSeries.cs @@ -29,6 +29,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -64,10 +65,9 @@ public class CoreLineSeries /// if set to true [is stacked]. - public CoreLineSeries(bool isStacked = false) - : base( - SeriesProperties.Line | SeriesProperties.PrimaryAxisVerticalOrientation | - (isStacked ? SeriesProperties.Stacked : 0) | SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips) + /// The values. + public CoreLineSeries(ICollection? values, bool isStacked = false) + : base(GetProperties(isStacked), values) { DataPadding = new LvcPoint(0.5f, 1f); } @@ -137,8 +137,7 @@ public override void Invalidate(Chart chart) // ToDo: Check this out, maybe this is unnecessary now and we should just go for the first approach all the times. var segments = _enableNullSplitting ? Fetch(cartesianChart).SplitByNullGaps(point => DeleteNullPoint(point, secondaryScale, primaryScale)) // calling this method is probably as expensive as the line bellow - : new List>() { Fetch(cartesianChart) }; - + : [Fetch(cartesianChart)]; var stacker = (SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked ? cartesianChart.SeriesContext.GetStackPosition(this, GetStackGroup()) : null; @@ -177,7 +176,7 @@ public override void Invalidate(Chart chart) var tooltipPositon = chart.TooltipPosition; var segmentI = 0; - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -187,9 +186,7 @@ public override void Invalidate(Chart chart) var isSegmentEmpty = true; VectorManager? strokeVector = null, fillVector = null; - var line = GetSpline(segment, stacker).ToArray(); - - foreach (var data in line) + foreach (var data in GetSpline(segment, stacker)) { if (!hasPaths) { @@ -247,6 +244,9 @@ public override void Invalidate(Chart chart) strokePath.Animate(EasingFunction ?? cartesianChart.EasingFunction, AnimationsSpeed ?? cartesianChart.AnimationsSpeed); } } + + strokePath.Opacity = IsVisible ? 1 : 0; + fillPath.Opacity = IsVisible ? 1 : 0; } var coordinate = data.TargetPoint.Coordinate; @@ -262,6 +262,30 @@ public override void Invalidate(Chart chart) (BezierErrorVisualPoint?) data.TargetPoint.Context.AdditionalVisuals; + if (!IsVisible) + { + if (visual is not null) + { + visual.Geometry.X = secondaryScale.ToPixels(coordinate.SecondaryValue); + visual.Geometry.Y = p; + visual.Geometry.Opacity = 0; + visual.Geometry.RemoveOnCompleted = true; + + visual.Bezier.Xi = secondaryScale.ToPixels(data.X0); + visual.Bezier.Xm = secondaryScale.ToPixels(data.X1); + visual.Bezier.Xj = secondaryScale.ToPixels(data.X2); + visual.Bezier.Yi = p; + visual.Bezier.Ym = p; + visual.Bezier.Yj = p; + + data.TargetPoint.Context.Visual = null; + } + + pointsCleanup.Clean(data.TargetPoint); + + continue; + } + if (visual is null) { var v = new BezierErrorVisualPoint(); @@ -303,9 +327,11 @@ public override void Invalidate(Chart chart) OnPointCreated(data.TargetPoint); } + visual.Geometry.Opacity = 1; + if (hasSvg) { - var svgVisual = (ISvgPath)visual.Geometry; + var svgVisual = (IVariableSvgPath)visual.Geometry; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -500,6 +526,7 @@ protected override double GetRequestedGeometrySize() } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -516,6 +543,52 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + var noGeometryPaint = GeometryStroke is null && GeometryFill is null; + var usesLine = (GeometrySize < 1 || noGeometryPaint) && Stroke is not null; + + var typedPoint = point is null ? null : ConvertToTypedChartPoint(point); + + return usesLine + ? new LineVisual + { + Stroke = GetMiniaturePaint(Stroke, zindex + 2), + Width = MiniatureShapeSize, + Height = 0, + ClippingMode = ClipMode.None + } + : new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Rotation = typedPoint?.Visual?.RotateTransform ?? 0, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + + /// + protected override IPaint? GetMiniatureFill(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? GeometryFill; + + return GetMiniaturePaint(paint, zIndex); + } + + /// + protected override IPaint? GetMiniatureStroke(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? GeometryStroke; + + return GetMiniaturePaint(paint, zIndex); + } + /// public override void SoftDeleteOrDispose(IChartView chart) { @@ -552,7 +625,7 @@ public override void RemoveFromUI(Chart chart) /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint, _errorPaint }; + return [Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint, _errorPaint]; } /// @@ -571,7 +644,7 @@ protected internal IEnumerable GetSpline( { var c = item.Current.Coordinate; - var sc = (c.PrimaryValue > 0 + var sc = (c.PrimaryValue >= 0 ? stacker?.GetStack(item.Current).Start : stacker?.GetStack(item.Current).NegativeStart) ?? 0; @@ -601,16 +674,18 @@ protected internal IEnumerable GetSpline( if (stacker is not null) { - pys = previous.PrimaryValue > 0 + var isPositive = current.PrimaryValue >= 0; + + pys = isPositive ? stacker.GetStack(item.Previous).Start : stacker.GetStack(item.Previous).NegativeStart; - cys = current.PrimaryValue > 0 + cys = isPositive ? stacker.GetStack(item.Current).Start : stacker.GetStack(item.Current).NegativeStart; - nys = next.PrimaryValue > 0 + nys = isPositive ? stacker.GetStack(item.Next).Start : stacker.GetStack(item.Next).NegativeStart; - nnys = afterNext.PrimaryValue > 0 + nnys = isPositive ? stacker.GetStack(item.AfterNext).Start : stacker.GetStack(item.AfterNext).NegativeStart; } @@ -696,6 +771,7 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal visual.Geometry.Y = y + visual.Geometry.Height * 0.5f; visual.Geometry.Height = 0; visual.Geometry.Width = 0; + visual.Geometry.Opacity = 0; visual.Geometry.RemoveOnCompleted = true; if (visual.YError is not null) @@ -785,4 +861,11 @@ private class SegmentVisual(bool isNew, TPathGeometry path) public TPathGeometry Path { get; set; } = path; } + + private static SeriesProperties GetProperties(bool isStacked) + { + return SeriesProperties.Line | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips | + (isStacked ? SeriesProperties.Stacked : 0); + } } diff --git a/src/LiveChartsCore/CorePieSeries.cs b/src/LiveChartsCore/CorePieSeries.cs index 9da0f2181..d61edc7f9 100644 --- a/src/LiveChartsCore/CorePieSeries.cs +++ b/src/LiveChartsCore/CorePieSeries.cs @@ -20,8 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -// Ignore Spelling: Gauge Pushout - using System; using System.Collections.Generic; using System.Linq; @@ -30,6 +28,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -41,18 +40,23 @@ namespace LiveChartsCore; /// The type of the label. /// The type of the miniature geometry, used in tool tips and legends. /// The type of the drawing context. -public abstract class CorePieSeries - : ChartSeries, IPieSeries - where TDrawingContext : DrawingContext - where TVisual : class, IDoughnutGeometry, new() - where TLabel : class, ILabelGeometry, new() - where TMiniatureGeometry : ISizedGeometry, new() +/// +/// Initializes a new instance of the class. +/// +public abstract class CorePieSeries( + ICollection? values, + bool isGauge = false, + bool isGaugeFill = false) + : ChartSeries(GetProperties(isGauge, isGaugeFill), values), IPieSeries + where TDrawingContext : DrawingContext + where TVisual : class, IDoughnutGeometry, new() + where TLabel : class, ILabelGeometry, new() + where TMiniatureGeometry : ISizedGeometry, new() { private IPaint? _stroke = null; private IPaint? _fill = null; private double _pushout = 0; private double _innerRadius = 0; - private double _maxOuterRadius = 1; private double _outerRadiusOffset = 0; private double _hoverPushout = 20; private double _innerPadding = 0; @@ -66,14 +70,6 @@ public abstract class CorePieSeries, string>? _tooltipLabelFormatter; - /// - /// Initializes a new instance of the class. - /// - protected CorePieSeries(bool isGauge = false, bool isGaugeFill = false) - : base(SeriesProperties.PieSeries | SeriesProperties.Stacked | - (isGauge ? SeriesProperties.Gauge : 0) | (isGaugeFill ? SeriesProperties.GaugeFill : 0) | SeriesProperties.Solid) - { } - /// /// Gets or sets the stroke. /// @@ -107,10 +103,6 @@ public IPaint? Fill /// public double OuterRadiusOffset { get => _outerRadiusOffset; set => SetProperty(ref _outerRadiusOffset, value); } - /// - [Obsolete($"Use {nameof(OuterRadiusOffset)} instead.")] - public double MaxOuterRadius { get => _maxOuterRadius; set => SetProperty(ref _maxOuterRadius, value); } - /// public double HoverPushout { get => _hoverPushout; set => SetProperty(ref _hoverPushout, value); } @@ -271,7 +263,7 @@ public override void Invalidate(Chart chart) var coordinate = point.Coordinate; var visual = point.Context.Visual as TVisual; - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -462,6 +454,7 @@ public virtual DimensionalBounds GetBounds(PieChart chart) } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -475,6 +468,20 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + return new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + /// public override string? GetPrimaryToolTipText(ChartPoint point) { @@ -655,8 +662,34 @@ public override void SoftDeleteOrDispose(IChartView chart) } foreach (var item in toDelete) _ = everFetched.Remove(item); + } + + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureFill(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? Fill; - OnVisibilityChanged(); + return GetMiniaturePaint(paint, zIndex); + } + + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureStroke(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Stroke ?? Stroke; + + return GetMiniaturePaint(paint, zIndex); } private void AlignLabel(TLabel label, double start, double initialRotation, double sweep) @@ -691,4 +724,11 @@ private void AlignLabel(TLabel label, double start, double initialRotation, doub break; } } + + private static SeriesProperties GetProperties(bool isGauge = false, bool isGaugeFill = false) + { + return SeriesProperties.PieSeries | SeriesProperties.Stacked | SeriesProperties.Solid | + (isGauge ? SeriesProperties.Gauge : 0) | + (isGaugeFill ? SeriesProperties.GaugeFill : 0); + } } diff --git a/src/LiveChartsCore/CorePolarAxis.cs b/src/LiveChartsCore/CorePolarAxis.cs index aa9a8e8dc..227723a13 100644 --- a/src/LiveChartsCore/CorePolarAxis.cs +++ b/src/LiveChartsCore/CorePolarAxis.cs @@ -71,7 +71,6 @@ public abstract class CorePolarAxis? _separatorsPaint; private bool _showSeparatorLines = true; - private bool _isVisible = true; private bool _isInverted; private bool _forceStepToMin; private double _labelsAngle; @@ -154,9 +153,6 @@ public abstract class CorePolarAxis public IEnumerable? CustomSeparators { get => _customSeparators; set => SetProperty(ref _customSeparators, value); } - /// - public bool IsVisible { get => _isVisible; set => SetProperty(ref _isVisible, value); } - /// public bool IsInverted { get => _isInverted; set => SetProperty(ref _isInverted, value); } diff --git a/src/LiveChartsCore/CorePolarLineSeries.cs b/src/LiveChartsCore/CorePolarLineSeries.cs index 5d6940fee..53c03b44e 100644 --- a/src/LiveChartsCore/CorePolarLineSeries.cs +++ b/src/LiveChartsCore/CorePolarLineSeries.cs @@ -29,6 +29,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -40,11 +41,13 @@ namespace LiveChartsCore; /// The type of the data label. /// The type of the drawing context. /// The type of the path geometry. -public class CorePolarLineSeries +/// The type of the line geometry +public class CorePolarLineSeries : ChartSeries, IPolarLineSeries, IPolarSeries where TPathGeometry : IVectorGeometry, new() where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() + where TLineGeometry : ILineGeometry, new() where TDrawingContext : DrawingContext { private readonly Dictionary> _fillPathHelperDictionary = []; @@ -64,13 +67,12 @@ public class CorePolarLineSeries, string>? _radiusTooltipLabelFormatter; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// if set to true [is stacked]. - public CorePolarLineSeries(bool isStacked = false) - : base( - SeriesProperties.Polar | SeriesProperties.PolarLine | - (isStacked ? SeriesProperties.Stacked : 0) | SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips) + /// The values. + public CorePolarLineSeries(ICollection? values, bool isStacked = false) + : base(GetProperties(isStacked), values) { DataPadding = new LvcPoint(1f, 1.5f); } @@ -193,7 +195,7 @@ public override void Invalidate(Chart chart) var segments = _enableNullSplitting ? SplitEachNull(points, scaler) - : new ChartPoint[][] { points }; + : [points]; var stacker = (SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked ? polarChart.SeriesContext.GetStackPosition(this, GetStackGroup()) @@ -247,7 +249,7 @@ public override void Invalidate(Chart chart) isCotangent = true; } - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -334,7 +336,7 @@ public override void Invalidate(Chart chart) if (hasSvg) { - var svgVisual = (ISvgPath)visual.Geometry; + var svgVisual = (IVariableSvgPath)visual.Geometry; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -511,6 +513,7 @@ public virtual SeriesBounds GetBounds( } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -527,6 +530,34 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + var noGeometryPaint = GeometryStroke is null && GeometryFill is null; + var usesLine = (GeometrySize < 1 || noGeometryPaint) && Stroke is not null; + + var typedPoint = point is null ? null : ConvertToTypedChartPoint(point); + + return usesLine + ? new LineVisual + { + Stroke = GetMiniaturePaint(Stroke, zindex + 2), + Width = MiniatureShapeSize, + Height = 0, + ClippingMode = ClipMode.None + } + : new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Rotation = typedPoint?.Visual?.RotateTransform ?? 0, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + /// public override string? GetPrimaryToolTipText(ChartPoint point) { @@ -771,14 +802,12 @@ public override void SoftDeleteOrDispose(IChartView chart) if (GeometryFill is not null) canvas.RemovePaintTask(GeometryFill); if (GeometryStroke is not null) canvas.RemovePaintTask(GeometryStroke); - - OnVisibilityChanged(); } /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint }; + return [Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint]; } /// @@ -840,6 +869,34 @@ protected virtual LvcPoint GetLabelPolarPosition( (float)(centerY + Math.Sin(actualAngle) * radius)); } + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureFill(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? GeometryFill; + + return GetMiniaturePaint(paint, zIndex); + } + + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureStroke(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Stroke ?? GeometryStroke; + + return GetMiniaturePaint(paint, zIndex); + } + /// protected override void OnPointerEnter(ChartPoint point) { @@ -868,7 +925,7 @@ private IEnumerable SplitEachNull( foreach (var point in points) { - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (point.Context.Visual is BezierVisualPoint visual) { @@ -896,4 +953,11 @@ private IEnumerable SplitEachNull( if (l.Count > 0) yield return l.ToArray(); } + + private static SeriesProperties GetProperties(bool isStacked = false) + { + return SeriesProperties.Polar | SeriesProperties.PolarLine | + SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips | + (isStacked ? SeriesProperties.Stacked : 0); + } } diff --git a/src/LiveChartsCore/CoreRowSeries.cs b/src/LiveChartsCore/CoreRowSeries.cs index 9a59e9615..6f729e1da 100644 --- a/src/LiveChartsCore/CoreRowSeries.cs +++ b/src/LiveChartsCore/CoreRowSeries.cs @@ -21,6 +21,7 @@ // SOFTWARE. using System; +using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Drawing; @@ -38,21 +39,22 @@ namespace LiveChartsCore; /// The type of the drawing context. /// /// The type of the error geometry. -public class CoreRowSeries : BarSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() - where TErrorGeometry : class, ILineGeometry, new() - where TDrawingContext : DrawingContext +public class CoreRowSeries + : BarSeries + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() + where TErrorGeometry : class, ILineGeometry, new() + where TDrawingContext : DrawingContext { private readonly bool _isRounded = false; /// /// Initializes a new instance of the class. /// - public CoreRowSeries(bool isStacked = false) - : base( - SeriesProperties.Bar | SeriesProperties.PrimaryAxisHorizontalOrientation | - SeriesProperties.Solid | SeriesProperties.PrefersYStrategyTooltips | (isStacked ? SeriesProperties.Stacked : 0)) + /// if set to true [is stacked]. + /// The values. + public CoreRowSeries(ICollection? values, bool isStacked = false) + : base(GetProperties(isStacked), values) { DataPadding = new LvcPoint(1, 0); _isRounded = typeof(IRoundedGeometry).IsAssignableFrom(typeof(TVisual)); @@ -120,7 +122,7 @@ public override void Invalidate(Chart chart) var ry = (float)Ry; var stacker = isStacked ? cartesianChart.SeriesContext.GetStackPosition(this, GetStackGroup()) : null; - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -135,7 +137,7 @@ public override void Invalidate(Chart chart) var secondary = secondaryScale.ToPixels(coordinate.SecondaryValue); var b = Math.Abs(primary - helper.p); - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -208,7 +210,7 @@ public override void Invalidate(Chart chart) if (hasSvg) { - var svgVisual = (ISvgPath)visual; + var svgVisual = (IVariableSvgPath)visual; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -460,4 +462,11 @@ public override SeriesBounds GetBounds(CartesianChart chart, IC return new SeriesBounds(dimensionalBounds, false); } + + private static SeriesProperties GetProperties(bool isStacked) + { + return SeriesProperties.Bar | SeriesProperties.PrimaryAxisHorizontalOrientation | + SeriesProperties.Solid | SeriesProperties.PrefersYStrategyTooltips | + (isStacked ? SeriesProperties.Stacked : 0); + } } diff --git a/src/LiveChartsCore/CoreScatterSeries.cs b/src/LiveChartsCore/CoreScatterSeries.cs index fba7b6bd3..4de288571 100644 --- a/src/LiveChartsCore/CoreScatterSeries.cs +++ b/src/LiveChartsCore/CoreScatterSeries.cs @@ -27,6 +27,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -47,14 +48,17 @@ public class CoreScatterSeries, new() { - private Bounds _weightBounds = new(); private IPaint? _errorPaint; + private int? _stackGroup; + private double _minGeometrySize = 6d; + private double _geometrySize = 24d; /// /// Initializes a new instance of the class. /// - public CoreScatterSeries() - : base(SeriesProperties.Scatter | SeriesProperties.Solid | SeriesProperties.PrefersXYStrategyTooltips) + /// The values. + public CoreScatterSeries(ICollection? values) + : base(GetProperties(), values) { DataPadding = new LvcPoint(1, 1); @@ -78,15 +82,14 @@ public CoreScatterSeries() /// /// The minimum size of the geometry. /// - public double MinGeometrySize { get; set; } = 6d; - + public double MinGeometrySize { get => _minGeometrySize; set => SetProperty(ref _minGeometrySize, value); } /// /// Gets or sets the size of the geometry. /// /// /// The size of the geometry. /// - public double GeometrySize { get; set; } = 24d; + public double GeometrySize { get => _geometrySize; set =>SetProperty(ref _geometrySize, value); } /// /// Gets a value indicating whether the points in this series use weight. @@ -100,6 +103,9 @@ public IPaint? ErrorPaint set => SetPaintProperty(ref _errorPaint, value, true); } + /// + public int? StackGroup { get => _stackGroup; set => SetProperty(ref _stackGroup, value); } + /// public override void Invalidate(Chart chart) { @@ -115,6 +121,9 @@ public override void Invalidate(Chart chart) var actualZIndex = ZIndex == 0 ? ((ISeries)this).SeriesId : ZIndex; var clipping = GetClipRectangle(cartesianChart); + var weightStackIndex = StackGroup ?? ((ISeries)this).SeriesId; + var weightBounds = chart.SeriesContext.GetWeightBounds(weightStackIndex); + if (Fill is not null) { Fill.ZIndex = actualZIndex + 0.1; @@ -146,8 +155,8 @@ public override void Invalidate(Chart chart) var gs = (float)GeometrySize; var hgs = gs / 2f; var sw = Stroke?.StrokeThickness ?? 0; - IsWeighted = _weightBounds.Max - _weightBounds.Min > 0; - var wm = -(GeometrySize - MinGeometrySize) / (_weightBounds.Max - _weightBounds.Min); + IsWeighted = weightBounds.Max - weightBounds.Min > 0; + var wm = -(GeometrySize - MinGeometrySize) / (weightBounds.Max - weightBounds.Min); var uwx = xScale.MeasureInPixels(secondaryAxis.UnitWidth); var uwy = yScale.MeasureInPixels(secondaryAxis.UnitWidth); @@ -156,7 +165,7 @@ public override void Invalidate(Chart chart) uwy = uwy < gs ? gs : uwy; var hy = chart.ControlSize.Height * .5f; - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); @@ -170,7 +179,7 @@ public override void Invalidate(Chart chart) var x = xScale.ToPixels(coordinate.SecondaryValue); var y = yScale.ToPixels(coordinate.PrimaryValue); - if (point.IsEmpty) + if (point.IsEmpty || !IsVisible) { if (visual is not null) { @@ -186,7 +195,7 @@ public override void Invalidate(Chart chart) if (IsWeighted) { - gs = (float)(wm * (_weightBounds.Max - coordinate.TertiaryValue) + GeometrySize); + gs = (float)(wm * (weightBounds.Max - coordinate.TertiaryValue) + GeometrySize); hgs = gs / 2f; } @@ -226,7 +235,7 @@ public override void Invalidate(Chart chart) if (hasSvg) { - var svgVisual = (ISvgPath)visual; + var svgVisual = (IVariableSvgPath)visual; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -308,11 +317,15 @@ public override void Invalidate(Chart chart) public override SeriesBounds GetBounds(CartesianChart chart, ICartesianAxis secondaryAxis, ICartesianAxis primaryAxis) { var seriesBounds = base.GetBounds(chart, secondaryAxis, primaryAxis); - _weightBounds = seriesBounds.Bounds.TertiaryBounds; + + chart.SeriesContext.AppendWeightBounds( + StackGroup ?? ((ISeries)this).SeriesId, seriesBounds.Bounds.TertiaryBounds); + return seriesBounds; } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -326,6 +339,23 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + var typedPoint = point is null ? null : ConvertToTypedChartPoint(point); + + return new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Rotation = typedPoint?.Visual?.RotateTransform ?? 0, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + /// protected override void OnPointerEnter(ChartPoint point) { @@ -417,4 +447,9 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal label.TextSize = 1; label.RemoveOnCompleted = true; } + + private static SeriesProperties GetProperties() + { + return SeriesProperties.Scatter | SeriesProperties.Solid | SeriesProperties.PrefersXYStrategyTooltips; + } } diff --git a/src/LiveChartsCore/CoreStackedAreaSeries.cs b/src/LiveChartsCore/CoreStackedAreaSeries.cs index f2e71cc29..7b270ef4b 100644 --- a/src/LiveChartsCore/CoreStackedAreaSeries.cs +++ b/src/LiveChartsCore/CoreStackedAreaSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Drawing.Segments; @@ -46,8 +47,9 @@ public class CoreStackedAreaSeries /// Initializes a new instance of the class. /// - public CoreStackedAreaSeries() - : base(true) + /// The values. + public CoreStackedAreaSeries(ICollection? values) + : base(values, true) { GeometryFill = null; GeometryStroke = null; diff --git a/src/LiveChartsCore/CoreStackedColumnSeries.cs b/src/LiveChartsCore/CoreStackedColumnSeries.cs index 3366582da..1ffd1a143 100644 --- a/src/LiveChartsCore/CoreStackedColumnSeries.cs +++ b/src/LiveChartsCore/CoreStackedColumnSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel.Sketches; @@ -34,8 +35,12 @@ namespace LiveChartsCore; /// The type of the drawing context. /// The type of the error geometry. /// -public class CoreStackedColumnSeries - : CoreColumnSeries, IStackedBarSeries +/// +/// Initializes a new instance of the class. +/// +/// The values. +public class CoreStackedColumnSeries(ICollection? values) + : CoreColumnSeries(values, true), IStackedBarSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() where TErrorGeometry : class, ILineGeometry, new() @@ -43,12 +48,6 @@ public class CoreStackedColumnSeries - /// Initializes a new instance of the class. - /// - public CoreStackedColumnSeries() : base(true) - { } - /// public int StackGroup { get => _stackGroup; set { _stackGroup = value; OnPropertyChanged(); } } diff --git a/src/LiveChartsCore/CoreStackedRowSeries.cs b/src/LiveChartsCore/CoreStackedRowSeries.cs index 0c3825f5e..a9129504a 100644 --- a/src/LiveChartsCore/CoreStackedRowSeries.cs +++ b/src/LiveChartsCore/CoreStackedRowSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel.Sketches; @@ -33,8 +34,12 @@ namespace LiveChartsCore; /// The type of the label. /// The type of the error geometry. /// The type of the drawing context. -public class CoreStackedRowSeries - : CoreRowSeries, IStackedBarSeries +/// +/// Initializes a new instance of the class. +/// +/// The values. +public class CoreStackedRowSeries(ICollection? values) + : CoreRowSeries(values, true), IStackedBarSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() where TErrorGeometry : class, ILineGeometry, new() @@ -42,12 +47,6 @@ public class CoreStackedRowSeries - /// Initializes a new instance of the class. - /// - public CoreStackedRowSeries() : base(true) - { } - /// public int StackGroup { get => _stackGroup; set { _stackGroup = value; OnPropertyChanged(); } } diff --git a/src/LiveChartsCore/CoreStackedStepAreaSeries.cs b/src/LiveChartsCore/CoreStackedStepAreaSeries.cs index fb09312d6..9988f0da5 100644 --- a/src/LiveChartsCore/CoreStackedStepAreaSeries.cs +++ b/src/LiveChartsCore/CoreStackedStepAreaSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Drawing.Segments; @@ -33,19 +34,22 @@ namespace LiveChartsCore; /// The type of the data label. /// The type of the drawing context. /// The type of the path geometry. -/// -public class CoreStackedStepAreaSeries - : CoreStepLineSeries +/// The type of the line geometry. +/// +public class CoreStackedStepAreaSeries + : CoreStepLineSeries where TPathGeometry : IVectorGeometry, new() where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() + where TLineGeometry : ILineGeometry, new() where TDrawingContext : DrawingContext { /// /// Initializes a new instance of the class. /// - public CoreStackedStepAreaSeries() - : base(true) + /// The values. + public CoreStackedStepAreaSeries(ICollection? values) + : base(values, true) { GeometryFill = null; GeometryStroke = null; diff --git a/src/LiveChartsCore/CoreStepLineSeries.cs b/src/LiveChartsCore/CoreStepLineSeries.cs index 01d55e70e..ea4eaeffc 100644 --- a/src/LiveChartsCore/CoreStepLineSeries.cs +++ b/src/LiveChartsCore/CoreStepLineSeries.cs @@ -30,6 +30,7 @@ using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; @@ -41,11 +42,13 @@ namespace LiveChartsCore; /// The type of the data label. /// The type of the drawing context. /// The type of the path geometry. -public class CoreStepLineSeries +/// The type of the line geometry +public class CoreStepLineSeries : StrokeAndFillCartesianSeries, IStepLineSeries where TPathGeometry : IVectorGeometry, new() where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() + where TLineGeometry: ILineGeometry, new() where TDrawingContext : DrawingContext { private readonly Dictionary> _fillPathHelperDictionary = []; @@ -56,13 +59,12 @@ public class CoreStepLineSeries - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// if set to true [is stacked]. - public CoreStepLineSeries(bool isStacked = false) - : base( - SeriesProperties.StepLine | SeriesProperties.PrimaryAxisVerticalOrientation | - (isStacked ? SeriesProperties.Stacked : 0) | SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips) + /// The values. + public CoreStepLineSeries(ICollection? values, bool isStacked = false) + : base(GetProperties(isStacked), values) { DataPadding = new LvcPoint(0.5f, 1f); } @@ -109,7 +111,7 @@ public override void Invalidate(Chart chart) // see note #240222 var segments = _enableNullSplitting ? Fetch(cartesianChart).SplitByNullGaps(point => DeleteNullPoint(point, secondaryScale, primaryScale)) - : new List>() { Fetch(cartesianChart) }; + : [Fetch(cartesianChart)]; var stacker = (SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked ? cartesianChart.SeriesContext.GetStackPosition(this, GetStackGroup()) @@ -145,71 +147,116 @@ public override void Invalidate(Chart chart) var uwx = secondaryScale.MeasureInPixels(secondaryAxis.UnitWidth); uwx = uwx < gs ? gs : uwx; - var hasSvg = this.HasSvgGeometry(); + var hasSvg = this.HasVariableSvgGeometry(); var isFirstDraw = !chart._drawnSeries.Contains(((ISeries)this).SeriesId); foreach (var segment in segments) { - TPathGeometry fillPath; - TPathGeometry strokePath; - var isNew = false; + var hasPaths = false; + var isSegmentEmpty = true; + VectorManager? strokeVector = null, fillVector = null; - if (segmentI >= fillPathHelperContainer.Count) - { - isNew = true; - fillPath = new TPathGeometry { ClosingMethod = VectorClosingMethod.CloseToPivot }; - strokePath = new TPathGeometry { ClosingMethod = VectorClosingMethod.NotClosed }; - fillPathHelperContainer.Add(fillPath); - strokePathHelperContainer.Add(strokePath); - } - else - { - fillPath = fillPathHelperContainer[segmentI]; - strokePath = strokePathHelperContainer[segmentI]; - } - - var strokeVector = new VectorManager(strokePath); - var fillVector = new VectorManager(fillPath); + double previousPrimary = 0, previousSecondary = 0; - if (Fill is not null) - { - Fill.AddGeometryToPaintTask(cartesianChart.Canvas, fillPath); - cartesianChart.Canvas.AddDrawableTask(Fill); - Fill.ZIndex = actualZIndex + 0.1; - Fill.SetClipRectangle(cartesianChart.Canvas, clipping); - fillPath.Pivot = p; - if (isNew) - { - fillPath.Animate(EasingFunction ?? cartesianChart.EasingFunction, AnimationsSpeed ?? cartesianChart.AnimationsSpeed); - } - } - if (Stroke is not null) + foreach (var point in segment) { - Stroke.AddGeometryToPaintTask(cartesianChart.Canvas, strokePath); - cartesianChart.Canvas.AddDrawableTask(Stroke); - Stroke.ZIndex = actualZIndex + 0.2; - Stroke.SetClipRectangle(cartesianChart.Canvas, clipping); - strokePath.Pivot = p; - if (isNew) + if (!hasPaths) { - strokePath.Animate(EasingFunction ?? cartesianChart.EasingFunction, AnimationsSpeed ?? cartesianChart.AnimationsSpeed); - } - } + hasPaths = true; - double previousPrimary = 0, previousSecondary = 0; + var fillLookup = GetSegmentVisual(segmentI, fillPathHelperContainer, VectorClosingMethod.CloseToPivot); + var strokeLookup = GetSegmentVisual(segmentI, strokePathHelperContainer, VectorClosingMethod.NotClosed); + + if (fillLookup.Path.Commands.Count == 1) + { + Fill?.RemoveGeometryFromPainTask(cartesianChart.Canvas, fillLookup.Path); + fillLookup.Path.Commands.Clear(); + fillPathHelperContainer.RemoveAt(segmentI); + + fillLookup = GetSegmentVisual(segmentI, fillPathHelperContainer, VectorClosingMethod.CloseToPivot); + } + + if (strokeLookup.Path.Commands.Count == 1) + { + Stroke?.RemoveGeometryFromPainTask(cartesianChart.Canvas, strokeLookup.Path); + strokeLookup.Path.Commands.Clear(); + strokePathHelperContainer.RemoveAt(segmentI); + + strokeLookup = GetSegmentVisual(segmentI, strokePathHelperContainer, VectorClosingMethod.NotClosed); + } + + var isNew = fillLookup.IsNew || strokeLookup.IsNew; + var fillPath = fillLookup.Path; + var strokePath = strokeLookup.Path; + + strokeVector = new VectorManager(strokePath); + fillVector = new VectorManager(fillPath); + + if (Fill is not null) + { + Fill.AddGeometryToPaintTask(cartesianChart.Canvas, fillPath); + cartesianChart.Canvas.AddDrawableTask(Fill); + Fill.ZIndex = actualZIndex + 0.1; + Fill.SetClipRectangle(cartesianChart.Canvas, clipping); + fillPath.Pivot = p; + if (isNew) + { + fillPath.Animate(EasingFunction ?? cartesianChart.EasingFunction, AnimationsSpeed ?? cartesianChart.AnimationsSpeed); + } + } + if (Stroke is not null) + { + Stroke.AddGeometryToPaintTask(cartesianChart.Canvas, strokePath); + cartesianChart.Canvas.AddDrawableTask(Stroke); + Stroke.ZIndex = actualZIndex + 0.2; + Stroke.SetClipRectangle(cartesianChart.Canvas, clipping); + strokePath.Pivot = p; + if (isNew) + { + strokePath.Animate(EasingFunction ?? cartesianChart.EasingFunction, AnimationsSpeed ?? cartesianChart.AnimationsSpeed); + } + } + + strokePath.Opacity = IsVisible ? 1 : 0; + fillPath.Opacity = IsVisible ? 1 : 0; + } - foreach (var point in segment) - { var coordinate = point.Coordinate; + isSegmentEmpty = false; var s = 0d; - if (stacker is not null) s = stacker.GetStack(point).Start; + if (stacker is not null) + s = coordinate.PrimaryValue > 0 + ? stacker.GetStack(point).Start + : stacker.GetStack(point).NegativeStart; var visual = (StepLineVisualPoint?)point.Context.AdditionalVisuals; var dp = coordinate.PrimaryValue + s - previousPrimary; var ds = coordinate.SecondaryValue - previousSecondary; + if (!IsVisible) + { + if (visual is not null) + { + visual.Geometry.X = secondaryScale.ToPixels(coordinate.SecondaryValue); + visual.Geometry.Y = p; + visual.Geometry.Opacity = 0; + visual.Geometry.RemoveOnCompleted = true; + + visual.StepSegment.Xi = secondaryScale.ToPixels(coordinate.SecondaryValue - ds); + visual.StepSegment.Xj = secondaryScale.ToPixels(coordinate.SecondaryValue); + visual.StepSegment.Yi = p; + visual.StepSegment.Yj = p; + + point.Context.Visual = null; + } + + pointsCleanup.Clean(point); + + continue; + } + if (visual is null) { var v = new StepLineVisualPoint(); @@ -233,9 +280,11 @@ public override void Invalidate(Chart chart) OnPointCreated(point); } + visual.Geometry.Opacity = 1; + if (hasSvg) { - var svgVisual = (ISvgPath)visual.Geometry; + var svgVisual = (IVariableSvgPath)visual.Geometry; if (_geometrySvgChanged || svgVisual.SVGPath is null) svgVisual.SVGPath = GeometrySvg ?? throw new Exception("svg path is not defined"); } @@ -247,8 +296,8 @@ public override void Invalidate(Chart chart) visual.StepSegment.Id = point.Context.Entity.MetaData!.EntityIndex; - if (Fill is not null) fillVector.AddConsecutiveSegment(visual.StepSegment, !isFirstDraw); - if (Stroke is not null) strokeVector.AddConsecutiveSegment(visual.StepSegment, !isFirstDraw); + if (Fill is not null) fillVector!.AddConsecutiveSegment(visual.StepSegment, !isFirstDraw); + if (Stroke is not null) strokeVector!.AddConsecutiveSegment(visual.StepSegment, !isFirstDraw); visual.StepSegment.Xi = secondaryScale.ToPixels(coordinate.SecondaryValue - ds); visual.StepSegment.Xj = secondaryScale.ToPixels(coordinate.SecondaryValue); @@ -258,16 +307,18 @@ public override void Invalidate(Chart chart) var x = secondaryScale.ToPixels(coordinate.SecondaryValue); var y = primaryScale.ToPixels(coordinate.PrimaryValue + s); - visual.Geometry.MotionProperties[nameof(visual.Geometry.X)].CopyFrom(visual.StepSegment.MotionProperties[nameof(visual.StepSegment.Xj)]); - visual.Geometry.MotionProperties[nameof(visual.Geometry.Y)].CopyFrom(visual.StepSegment.MotionProperties[nameof(visual.StepSegment.Yj)]); + visual.Geometry.MotionProperties[nameof(visual.Geometry.X)] + .CopyFrom(visual.StepSegment.MotionProperties[nameof(visual.StepSegment.Xj)]); + visual.Geometry.MotionProperties[nameof(visual.Geometry.Y)] + .CopyFrom(visual.StepSegment.MotionProperties[nameof(visual.StepSegment.Yj)]); visual.Geometry.TranslateTransform = new LvcPoint(-hgs, -hgs); visual.Geometry.Width = gs; visual.Geometry.Height = gs; visual.Geometry.RemoveOnCompleted = false; - visual.FillPath = fillPath; - visual.StrokePath = strokePath; + visual.FillPath = fillVector!.AreaGeometry; + visual.StrokePath = strokeVector!.AreaGeometry; var hags = gs < 8 ? 8 : gs; @@ -317,12 +368,13 @@ public override void Invalidate(Chart chart) } OnPointMeasured(point); + previousPrimary = coordinate.PrimaryValue + s; previousSecondary = coordinate.SecondaryValue; } - strokeVector.End(); - fillVector.End(); + strokeVector?.End(); + fillVector?.End(); if (GeometryFill is not null) { @@ -336,20 +388,31 @@ public override void Invalidate(Chart chart) GeometryStroke.SetClipRectangle(cartesianChart.Canvas, clipping); GeometryStroke.ZIndex = actualZIndex + 0.4; } - segmentI++; + + if (!isSegmentEmpty) segmentI++; } - while (segmentI > fillPathHelperContainer.Count) + var maxSegment = fillPathHelperContainer.Count > strokePathHelperContainer.Count + ? fillPathHelperContainer.Count + : strokePathHelperContainer.Count; + + for (var i = maxSegment - 1; i >= segmentI; i--) { - var iFill = fillPathHelperContainer.Count - 1; - var fillHelper = fillPathHelperContainer[iFill]; - Fill?.RemoveGeometryFromPainTask(cartesianChart.Canvas, fillHelper); - fillPathHelperContainer.RemoveAt(iFill); - - var iStroke = strokePathHelperContainer.Count - 1; - var strokeHelper = strokePathHelperContainer[iStroke]; - Stroke?.RemoveGeometryFromPainTask(cartesianChart.Canvas, strokeHelper); - strokePathHelperContainer.RemoveAt(iStroke); + if (i < fillPathHelperContainer.Count) + { + var segmentFill = fillPathHelperContainer[i]; + Fill?.RemoveGeometryFromPainTask(cartesianChart.Canvas, segmentFill); + segmentFill.Commands.Clear(); + fillPathHelperContainer.RemoveAt(i); + } + + if (i < strokePathHelperContainer.Count) + { + var segmentStroke = strokePathHelperContainer[i]; + Stroke?.RemoveGeometryFromPainTask(cartesianChart.Canvas, segmentStroke); + segmentStroke.Commands.Clear(); + strokePathHelperContainer.RemoveAt(i); + } } if (DataLabelsPaint is not null) @@ -372,6 +435,7 @@ protected override double GetRequestedGeometrySize() } /// + [Obsolete] public override Sketch GetMiniaturesSketch() { var schedules = new List>(); @@ -388,6 +452,52 @@ public override Sketch GetMiniaturesSketch() }; } + /// "/> + public override VisualElement GetMiniature(ChartPoint? point, int zindex) + { + var noGeometryPaint = GeometryStroke is null && GeometryFill is null; + var usesLine = (GeometrySize < 1 || noGeometryPaint) && Stroke is not null; + + var typedPoint = point is null ? null : ConvertToTypedChartPoint(point); + + return usesLine + ? new LineVisual + { + Stroke = GetMiniaturePaint(Stroke, zindex + 2), + Width = MiniatureShapeSize, + Height = 0, + ClippingMode = ClipMode.None + } + : new GeometryVisual + { + Fill = GetMiniatureFill(point, zindex + 1), + Stroke = GetMiniatureStroke(point, zindex + 2), + Width = MiniatureShapeSize, + Height = MiniatureShapeSize, + Rotation = typedPoint?.Visual?.RotateTransform ?? 0, + Svg = GeometrySvg, + ClippingMode = ClipMode.None + }; + } + + /// + protected override IPaint? GetMiniatureFill(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? GeometryFill; + + return GetMiniaturePaint(paint, zIndex); + } + + /// + protected override IPaint? GetMiniatureStroke(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? GeometryStroke; + + return GetMiniaturePaint(paint, zIndex); + } + /// protected override void OnPointerEnter(ChartPoint point) { @@ -445,6 +555,7 @@ protected internal override void SoftDeleteOrDisposePoint(ChartPoint point, Scal visual.Geometry.Y = y + visual.Geometry.Height * 0.5f; visual.Geometry.Height = 0; visual.Geometry.Width = 0; + visual.Geometry.Opacity = 0; visual.Geometry.RemoveOnCompleted = true; DataFactory.DisposePoint(point); @@ -494,7 +605,7 @@ public override void RemoveFromUI(Chart chart) /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint }; + return [Stroke, Fill, _geometryFill, _geometryStroke, DataLabelsPaint]; } private void DeleteNullPoint(ChartPoint point, Scaler xScale, Scaler yScale) @@ -515,4 +626,37 @@ private void DeleteNullPoint(ChartPoint point, Scaler xScale, Scaler yScale) visual.Geometry.RemoveOnCompleted = true; point.Context.Visual = null; } + + private SegmentVisual GetSegmentVisual(int index, List container, VectorClosingMethod method) + { + var isNew = false; + TPathGeometry? path; + + if (index >= container.Count) + { + isNew = true; + path = new TPathGeometry { ClosingMethod = method }; + container.Add(path); + } + else + { + path = container[index]; + } + + return new SegmentVisual(isNew, path); + } + + private class SegmentVisual(bool isNew, TPathGeometry path) + { + public bool IsNew { get; set; } = isNew; + + public TPathGeometry Path { get; set; } = path; + } + + private static SeriesProperties GetProperties(bool isStacked) + { + return SeriesProperties.StepLine | SeriesProperties.PrimaryAxisVerticalOrientation | + SeriesProperties.Sketch | SeriesProperties.PrefersXStrategyTooltips | + (isStacked ? SeriesProperties.Stacked : 0); + } } diff --git a/src/LiveChartsCore/Drawing/ISvgPath.cs b/src/LiveChartsCore/Drawing/IVariableSvgPath.cs similarity index 94% rename from src/LiveChartsCore/Drawing/ISvgPath.cs rename to src/LiveChartsCore/Drawing/IVariableSvgPath.cs index 8b27f57d0..d40951257 100644 --- a/src/LiveChartsCore/Drawing/ISvgPath.cs +++ b/src/LiveChartsCore/Drawing/IVariableSvgPath.cs @@ -25,7 +25,7 @@ namespace LiveChartsCore.Drawing; /// /// Defines a geometry that is built using from a svg path. /// -public interface ISvgPath : ISizedGeometry +public interface IVariableSvgPath : ISizedGeometry where TDrawingContext : DrawingContext { /// diff --git a/src/LiveChartsCore/Drawing/IVectorGeometry.cs b/src/LiveChartsCore/Drawing/IVectorGeometry.cs index 1ffba786e..d7d5ad901 100644 --- a/src/LiveChartsCore/Drawing/IVectorGeometry.cs +++ b/src/LiveChartsCore/Drawing/IVectorGeometry.cs @@ -30,7 +30,7 @@ namespace LiveChartsCore.Drawing; /// /// /// -public interface IVectorGeometry : IDrawable +public interface IVectorGeometry : IPaintable where TSegment : IConsecutivePathSegment where TDrawingContext : DrawingContext { diff --git a/src/LiveChartsCore/Geo/Maps.cs b/src/LiveChartsCore/Geo/Maps.cs index c80840cb1..d7cc42efc 100644 --- a/src/LiveChartsCore/Geo/Maps.cs +++ b/src/LiveChartsCore/Geo/Maps.cs @@ -103,7 +103,7 @@ public static MapProjector BuildProjector(MapProjection projection, float[] mapS return projection == MapProjection.Default - ? new ControlCoordinatesProjector(mapSize[0], mapSize[1], ox, oy) - : new MercatorProjector(mapSize[0], mapSize[1], ox, oy); + ? new ControlCoordinatesProjector(mapSize[0], mapSize[1], ox, oy) + : new MercatorProjector(mapSize[0], mapSize[1], ox, oy); } } diff --git a/src/LiveChartsCore/GeoMap.cs b/src/LiveChartsCore/GeoMap.cs index 8e76c0d44..14cdb97e5 100644 --- a/src/LiveChartsCore/GeoMap.cs +++ b/src/LiveChartsCore/GeoMap.cs @@ -136,22 +136,37 @@ public void Unload() View.Canvas.Dispose(); } - internal void InvokePointerDown(LvcPoint point) + /// + /// Invokes the pointer down event. + /// + /// The pointer position. + protected internal void InvokePointerDown(LvcPoint point) { PointerDown?.Invoke(point); } - internal void InvokePointerMove(LvcPoint point) + /// + /// Invokes the pointer move event. + /// + /// The pointer position. + protected internal void InvokePointerMove(LvcPoint point) { PointerMove?.Invoke(point); } - internal void InvokePointerUp(LvcPoint point) + /// + /// Invokes the pointer up event. + /// + /// The pointer position. + protected internal void InvokePointerUp(LvcPoint point) { PointerUp?.Invoke(point); } - internal void InvokePointerLeft() + /// + /// Invokes the pointer left event. + /// + protected internal void InvokePointerLeft() { PointerLeft?.Invoke(); } @@ -178,7 +193,7 @@ protected virtual Task UpdateThrottlerUnlocked() /// /// Measures the chart. /// - internal void Measure() + protected internal void Measure() { if (_activeMap is not null && _activeMap != View.ActiveMap) { diff --git a/src/LiveChartsCore/ISeries.cs b/src/LiveChartsCore/ISeries.cs index fad5677b6..7b0c3e4ac 100644 --- a/src/LiveChartsCore/ISeries.cs +++ b/src/LiveChartsCore/ISeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore; /// /// Defines a chart series. /// -public interface ISeries +public interface ISeries : IChartElement { /// /// Gets or sets a series unique identifier, the library handles this id automatically. @@ -62,15 +62,7 @@ public interface ISeries /// /// The values. /// - ICollection? Values { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is visible. - /// - /// - /// true if this instance is visible; otherwise, false. - /// - bool IsVisible { get; set; } + IEnumerable? Values { get; set; } /// /// Gets or sets a value indicating whether this instance will show up in tool tips when the pointer is over a point. @@ -122,7 +114,7 @@ public interface ISeries /// /// Gets or sets the series geometry svg, this property requires the series visual to be - /// an instance. + /// an instance. /// string? GeometrySvg { get; set; } @@ -144,11 +136,6 @@ public interface ISeries /// Func? EasingFunction { get; set; } - /// - /// Occurs when the series property changes. - /// - event Action? VisibilityChanged; - /// /// Gets the tool tip text for a give chart point. /// @@ -214,9 +201,16 @@ public interface ISeries /// Defines a series. /// /// The type of the model. -/// public interface ISeries : ISeries { + /// + /// Gets or sets the values. + /// + /// + /// The values. + /// + new ICollection? Values { get; set; } + /// /// Gets or sets the mapping. /// diff --git a/src/LiveChartsCore/Kernel/ChartElement.cs b/src/LiveChartsCore/Kernel/ChartElement.cs index abc394db5..b8ab6210a 100644 --- a/src/LiveChartsCore/Kernel/ChartElement.cs +++ b/src/LiveChartsCore/Kernel/ChartElement.cs @@ -36,8 +36,9 @@ public abstract class ChartElement : IChartElement _userSets = []; + private bool _isVisible = true; private readonly List> _deletingTasks = []; /// @@ -46,9 +47,16 @@ public abstract class ChartElement : IChartElement public event PropertyChangedEventHandler? PropertyChanged; - /// + /// public object? Tag { get; set; } + /// + public bool IsVisible + { + get => _isVisible; + set => SetProperty(ref _isVisible, value); + } + /// public abstract void Invalidate(Chart chart); @@ -97,6 +105,12 @@ protected virtual void SetPaintProperty( bool isStroke = false, [CallerMemberName] string? propertyName = null) { + // The null check is intentional. + // we need to allow nulls to go further this if + // OnPropertyChanged needs to be called + // to detect whether the user set the null value. + if (value is not null && value == reference) return; + if (propertyName is null) throw new ArgumentNullException(nameof(propertyName)); if (!CanSetProperty(propertyName)) return; @@ -125,6 +139,12 @@ protected virtual void SetProperty( T value, [CallerMemberName] string? propertyName = null) { + // The null check is intentional. + // we need to allow nulls to go further this if + // OnPropertyChanged needs to be called + // to detect whether the user set the null value. + if (value is not null && value.Equals(reference)) return; + if (propertyName is null) throw new ArgumentNullException(nameof(propertyName)); if (!CanSetProperty(propertyName)) return; diff --git a/src/LiveChartsCore/Kernel/ChartPoint.cs b/src/LiveChartsCore/Kernel/ChartPoint.cs index 9e9f9a734..7212a5c4f 100644 --- a/src/LiveChartsCore/Kernel/ChartPoint.cs +++ b/src/LiveChartsCore/Kernel/ChartPoint.cs @@ -20,9 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -// Ignore Spelling: Quinary - -using System; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel.Sketches; @@ -83,71 +80,6 @@ public Coordinate Coordinate /// public bool IsEmpty => Context.Entity.Coordinate.IsEmpty; - /// - /// Gets or sets the primary value. - /// - /// - /// The primary value. - /// - [Obsolete($"Instead set the {nameof(Coordinate)} of the point.")] - public double PrimaryValue - { - get => Context.Entity.Coordinate.PrimaryValue; - set => SetCoordinate(primary: value); - } - - /// - /// Gets or sets the secondary value. - /// - /// - /// The secondary value. - /// - [Obsolete($"Use {nameof(Coordinate)} instead.")] - public double SecondaryValue - { - get => Context.Entity.Coordinate.SecondaryValue; - set => SetCoordinate(secondary: value); - } - - /// - /// Gets or sets the tertiary value. - /// - /// - /// The tertiary value. - /// - [Obsolete($"Use {nameof(Coordinate)} instead.")] - public double TertiaryValue - { - get => Context.Entity.Coordinate.TertiaryValue; - set => SetCoordinate(tertiary: value); - } - - /// - /// Gets or sets the quaternary value. - /// - /// - /// The quaternary value. - /// - [Obsolete($"Use {nameof(Coordinate)} instead.")] - public double QuaternaryValue - { - get => Context.Entity.Coordinate.QuaternaryValue; - set => SetCoordinate(quaternary: value); - } - - /// - /// Gets or sets the quinary value. - /// - /// - /// The quinary value. - /// - [Obsolete($"Use {nameof(Coordinate)} instead.")] - public double QuinaryValue - { - get => Context.Entity.Coordinate.QuinaryValue; - set => SetCoordinate(quinary: value); - } - /// /// Gets or sets the stacked value, if the point do not belongs to a stacked series then this property is null. /// diff --git a/src/LiveChartsCore/Kernel/ChartPointContext.cs b/src/LiveChartsCore/Kernel/ChartPointContext.cs index 3bd65eb9c..f1b1393cd 100644 --- a/src/LiveChartsCore/Kernel/ChartPointContext.cs +++ b/src/LiveChartsCore/Kernel/ChartPointContext.cs @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; using LiveChartsCore.Defaults; using LiveChartsCore.Kernel.Drawing; using LiveChartsCore.Kernel.Sketches; @@ -80,12 +79,6 @@ internal ChartPointContext() /// public object? DataSource { get; internal set; } - /// - /// Gets the position of the point the collection that was used when the point was drawn. - /// - [Obsolete($"use {nameof(ChartPoint)}.{nameof(ChartPoint.Index)} instead")] - public int Index => Entity?.MetaData?.EntityIndex ?? 0; - /// /// Gets the visual. /// diff --git a/src/LiveChartsCore/Kernel/Extensions.cs b/src/LiveChartsCore/Kernel/Extensions.cs index df78ad8de..3c8085064 100644 --- a/src/LiveChartsCore/Kernel/Extensions.cs +++ b/src/LiveChartsCore/Kernel/Extensions.cs @@ -38,8 +38,6 @@ namespace LiveChartsCore.Kernel; /// public static class Extensions { - private const float MinLabelSize = 10; // Assume the label size is at least 10px - private static readonly Type s_nullableType = typeof(Nullable<>); /// @@ -219,13 +217,14 @@ public static AxisTick GetTick(this ICartesianAxis axis, LvcSize controlSize, Bo // modify the size of the label to avoid overlapping // and improve readability. - const float xGrowFactor = 1.10f; - if (axis.Orientation == AxisOrientation.X) w *= xGrowFactor; + var density = 1 + axis.LabelsDensity; - const float yGrowFactor = 1.5f; - if (axis.Orientation == AxisOrientation.Y) h *= yGrowFactor; + if (axis.Orientation == AxisOrientation.X) w *= density / 2f; + if (axis.Orientation == AxisOrientation.Y) h *= density / 2f; } + const float MinLabelSize = 10; // Assume the label size is at least 10px + if (w < MinLabelSize) w = MinLabelSize; if (h < MinLabelSize) h = MinLabelSize; @@ -500,7 +499,7 @@ public static bool IsPieSeries(this ISeries series) /// /// true if [is bar series] [the specified series]; otherwise, false. /// - public static bool HasSvgGeometry(this ISeries series) + public static bool HasVariableSvgGeometry(this ISeries series) { return (series.SeriesProperties & SeriesProperties.IsSVGPath) != 0; } diff --git a/src/LiveChartsCore/Kernel/IChartElement.cs b/src/LiveChartsCore/Kernel/IChartElement.cs index 864a79ed6..e029e71fd 100644 --- a/src/LiveChartsCore/Kernel/IChartElement.cs +++ b/src/LiveChartsCore/Kernel/IChartElement.cs @@ -29,14 +29,25 @@ namespace LiveChartsCore.Kernel; /// /// Defines a visual element in a chart. /// -public interface IChartElement : INotifyPropertyChanged - where TDrawingContext : DrawingContext +public interface IChartElement : INotifyPropertyChanged { /// /// Gets or sets the object that contains data about the control. /// object? Tag { get; set; } + /// + /// Gets or sets a value indicating whether the element is visible. + /// + bool IsVisible { get; set; } +} + +/// +/// Defines a visual element in a chart. +/// +public interface IChartElement : IChartElement + where TDrawingContext : DrawingContext +{ /// /// Invalidates the in the user interface. /// diff --git a/src/LiveChartsCore/Kernel/IGaugeBuilder.cs b/src/LiveChartsCore/Kernel/IGaugeBuilder.cs deleted file mode 100644 index 6624abe4a..000000000 --- a/src/LiveChartsCore/Kernel/IGaugeBuilder.cs +++ /dev/null @@ -1,138 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using LiveChartsCore.Drawing; -using LiveChartsCore.Measure; - -namespace LiveChartsCore.Kernel; - -/// -/// Defines a gauge builder -/// -public interface IGaugeBuilder - where TDrawingContext : DrawingContext -{ - /// - /// Gets or sets the inner radius. - /// - /// - /// The inner radius. - /// - double? InnerRadius { get; set; } - - /// - /// Gets or sets the offset radius, the separation between each gauge if multiple gauges are nested. - /// - /// - /// The relative inner radius. - /// - double? OffsetRadius { get; set; } - - /// - /// Gets or sets the maximum width of the radial column. - /// - /// - /// The maximum width of the radial column. - /// - double? MaxColumnWidth { get; set; } - - /// - /// Gets or sets the corner radius. - /// - /// - /// The corner radius. - /// - double? CornerRadius { get; set; } - - /// - /// Gets or sets the radial align. - /// - /// - /// The radial align. - /// - RadialAlignment? RadialAlign { get; set; } - - /// - /// Gets or sets the background inner radius. - /// - /// - /// The background inner radius. - /// - double? BackgroundInnerRadius { get; set; } - - /// - /// Gets or sets the background offset radius, the separation between each gauge if multiple gauges are nested. - /// - /// - /// The background relative inner radius. - /// - double? BackgroundOffsetRadius { get; set; } - - /// - /// Gets or sets the width of the background maximum radial column. - /// - /// - /// The width of the background maximum radial column. - /// - double? BackgroundMaxRadialColumnWidth { get; set; } - - /// - /// Gets or sets the background corner radius. - /// - /// - /// The background corner radius. - /// - double? BackgroundCornerRadius { get; set; } - - /// - /// Gets or sets the background. - /// - /// - /// The background. - /// - IPaint? Background { get; set; } - - /// - /// Gets or sets the size of the labels. - /// - /// - /// The size of the labels. - /// - double? LabelsSize { get; set; } - - /// - /// Gets or sets the labels position. - /// - /// - /// The labels position. - /// - PolarLabelsPosition? LabelsPosition { get; set; } - - /// - /// Gets or sets the label formatter. - /// - /// - /// The label formatter. - /// - Func LabelFormatter { get; set; } -} diff --git a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs index a440515f3..de5b978b5 100644 --- a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs +++ b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs @@ -46,7 +46,7 @@ public class LiveChartsSettings /// /// The theme identifier. /// - public object CurrentThemeId { get; private set; } = new(); + public object CurrentThemeId { get; set; } = new(); /// /// Gets or sets the default easing function. @@ -185,7 +185,13 @@ public LiveChartsSettings UseRightToLeftSettings() return this; } - internal Func GetMap() + /// + /// Gets the map for a given type. + /// + /// + /// + /// + public Func GetMap() { return !_mappers.TryGetValue(typeof(TModel), out var mapper) ? throw new NotImplementedException( @@ -360,7 +366,6 @@ public LiveChartsSettings RemoveMap() public LiveChartsSettings HasTheme(Action> builder) where TDrawingContext : DrawingContext { - CurrentThemeId = new object(); Theme t; _theme = t = new Theme(); builder(t); diff --git a/src/LiveChartsCore/Kernel/Providers/ChartEngine.cs b/src/LiveChartsCore/Kernel/Providers/ChartEngine.cs index 38496ad74..989e4bd89 100644 --- a/src/LiveChartsCore/Kernel/Providers/ChartEngine.cs +++ b/src/LiveChartsCore/Kernel/Providers/ChartEngine.cs @@ -23,6 +23,7 @@ using LiveChartsCore.Drawing; using LiveChartsCore.Geo; using LiveChartsCore.Kernel.Sketches; +using LiveChartsCore.Motion; namespace LiveChartsCore.Kernel.Providers; @@ -39,9 +40,7 @@ public abstract class ChartEngine /// The type of the model. /// public virtual DataFactory GetDefaultDataFactory() - { - return new DataFactory(); - } + => new(); /// /// Gets a new instance of the default map factory. @@ -66,4 +65,11 @@ public virtual DataFactory GetDefaultDataFactory /// public abstract IPaint GetSolidColorPaint(LvcColor color = new()); + + /// + /// Initializes the zooming section for a cartesian chart in a given canvas. + /// + /// The canvas. + /// The created geometry. + public abstract ISizedGeometry InitializeZoommingSection(MotionCanvas canvas); } diff --git a/src/LiveChartsCore/Kernel/Providers/DataFactory.cs b/src/LiveChartsCore/Kernel/Providers/DataFactory.cs index c7cb1027c..baa6088c4 100644 --- a/src/LiveChartsCore/Kernel/Providers/DataFactory.cs +++ b/src/LiveChartsCore/Kernel/Providers/DataFactory.cs @@ -41,7 +41,7 @@ public class DataFactory { private readonly bool _isTModelChartEntity = false; private readonly Dictionary> _chartIndexEntityMap = []; - private ISeries? _series; + private ISeries? _series; /// /// Gets or sets the previous known bounds. @@ -131,8 +131,6 @@ public virtual SeriesBounds GetCartesianBounds( var yMin = plane2.MinLimit ?? double.MinValue; var yMax = plane2.MaxLimit ?? double.MaxValue; - var hasData = false; - var bounds = new DimensionalBounds(); ChartPoint? previous = null; @@ -189,12 +187,9 @@ public virtual SeriesBounds GetCartesianBounds( } previous = point; - hasData = true; } - return !hasData - ? new SeriesBounds(PreviousKnownBounds, true) - : new SeriesBounds(PreviousKnownBounds = bounds, false); + return new SeriesBounds(bounds, false); } /// diff --git a/src/LiveChartsCore/Kernel/SeriesContext.cs b/src/LiveChartsCore/Kernel/SeriesContext.cs index be8c9e553..b63875fd0 100644 --- a/src/LiveChartsCore/Kernel/SeriesContext.cs +++ b/src/LiveChartsCore/Kernel/SeriesContext.cs @@ -55,6 +55,7 @@ public class SeriesContext(IEnumerable, int> _boxPositions = []; private readonly Dictionary _stackColumnPositions = []; private readonly Dictionary _stackRowsPositions = []; + private readonly Dictionary _weightBounds = []; private readonly Dictionary> _stackers = []; @@ -66,6 +67,8 @@ public class SeriesContext(IEnumerableThe series. public int GetColumnPostion(IChartSeries series) { + if (!series.IsVisible) return ReturnDefault(); + if (_areBarsIndexed) return _columnPositions[series]; IndexBars(); return _columnPositions[series]; @@ -99,6 +102,8 @@ public float GetPieOuterLabelsSpace() /// public int GetRowPosition(IChartSeries series) { + if (!series.IsVisible) return ReturnDefault(); + if (_areBarsIndexed) return _rowPositions[series]; IndexBars(); return _rowPositions[series]; @@ -122,6 +127,8 @@ public int GetRowSeriesCount() /// public int GetBoxPosition(IChartSeries series) { + if (!series.IsVisible) return ReturnDefault(); + if (_areBarsIndexed) return _boxPositions[series]; IndexBars(); return _boxPositions[series]; @@ -145,6 +152,8 @@ public int GetBoxSeriesCount() /// public int GetStackedColumnPostion(IChartSeries series) { + if (!series.IsVisible) return ReturnDefault(); + if (_areBarsIndexed) return _stackColumnPositions[series.GetStackGroup()]; IndexBars(); return _stackColumnPositions[series.GetStackGroup()]; @@ -168,6 +177,8 @@ public int GetStackedColumnSeriesCount() /// public int GetStackedRowPostion(IChartSeries series) { + if (!series.IsVisible) return ReturnDefault(); + if (_areBarsIndexed) return _stackRowsPositions[series.GetStackGroup()]; IndexBars(); return _stackRowsPositions[series.GetStackGroup()]; @@ -311,4 +322,42 @@ private void CalculatePieLabelsOuterSpace() } #endregion + + #region scatter + + /// + /// Gets the weight bounds. + /// + /// + /// + public Bounds GetWeightBounds(int key) + { + if (_weightBounds.TryGetValue(key, out var bounds)) return bounds; + + bounds = new Bounds(); + _weightBounds[key] = bounds; + + return bounds; + } + + /// + /// Appends the weight bounds. + /// + /// + /// + public void AppendWeightBounds(int key, Bounds value) + { + var bounds = GetWeightBounds(key); + + if (value.Max > bounds.Max) bounds.Max = value.Max; + if (value.Min < bounds.Min) bounds.Min = value.Min; + } + + #endregion + + private int ReturnDefault() + // This return 0 for now, but maybe we should cache the last positon and return it. + // this method is normally called when the series visibility changed. + // because the series is ignored in the UI, so no position is assigned. + => 0; } diff --git a/src/LiveChartsCore/Kernel/Sketches/IBarSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IBarSeries.cs index 29288e729..b2586f8d9 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IBarSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IBarSeries.cs @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; using LiveChartsCore.Drawing; namespace LiveChartsCore.Kernel.Sketches; @@ -51,15 +50,6 @@ public interface IBarSeries : /// double Ry { get; set; } - /// - /// Gets or sets the padding for each group of bars that share the same secondary coordinate. - /// - /// - /// The bar group padding. - /// - [Obsolete($"Replace by {nameof(Padding)} property.")] - double GroupPadding { get; set; } - /// /// Gets or sets the padding for each bar in the series. /// @@ -78,7 +68,7 @@ public interface IBarSeries : /// /// Gets or sets a value indicating whether the bar position respects the other bars that share - /// the same . - /// + /// the same Coordinate. + /// bool IgnoresBarPosition { get; set; } } diff --git a/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs b/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs index efac38520..7dd62aab3 100644 --- a/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs +++ b/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs @@ -73,6 +73,14 @@ public interface ICartesianAxis : IPlane, INotifyPropertyChanged /// LvcSize Size { get; set; } + /// + /// Gets or sets the labels density, it is a factor that determines the distance between labels when calculated + /// by the library, 0 is the most dense any value greater than 0 will make the labels to be more separated, + /// values less than 0 will make the labels to overlap (labels rotation could prevent overlapping). + /// Default value is 0.85. + /// + float LabelsDensity { get; set; } + /// /// Gets or sets the min zoom delta, the minimum difference between the max and min visible limits of the axis. /// default is null and null means that the library will calculate this value based on the current data. @@ -129,15 +137,16 @@ public interface ICartesianAxis : IPlane, INotifyPropertyChanged public IEnumerable? SharedWith { get; set; } /// - /// Initializes the axis for the specified orientation. + /// Called when the axis measure starts. /// + /// The chart. /// The orientation. - void Initialize(AxisOrientation orientation); + void OnMeasureStarted(IChart chart, AxisOrientation orientation); /// - /// Occurs when the axis is initialized. + /// Occurs when the axis measure starts. /// - event Action? Initialized; + event Action? MeasureStarted; /// /// Gets the axis limits considering its own and the axes. diff --git a/src/LiveChartsCore/Kernel/Sketches/ICartesianChartView.cs b/src/LiveChartsCore/Kernel/Sketches/ICartesianChartView.cs index 1e3d3167e..ab81c38d1 100644 --- a/src/LiveChartsCore/Kernel/Sketches/ICartesianChartView.cs +++ b/src/LiveChartsCore/Kernel/Sketches/ICartesianChartView.cs @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; @@ -107,16 +106,6 @@ public interface ICartesianChartView : IChartView double ZoomingSpeed { get; set; } - /// - /// Scales a UI point to the chart values scale. - /// - /// The point. - /// Index of the x axis. - /// Index of the y axis. - /// - [Obsolete($"Use {nameof(ScalePixelsToData)} instead.")] - double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0); - /// /// Scales a point in pixels to the chart data scale. /// diff --git a/src/LiveChartsCore/Kernel/Sketches/IChartSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IChartSeries.cs index 5d9a8ff58..63ee573b1 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IChartSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IChartSeries.cs @@ -20,9 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System; using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel.Drawing; +using LiveChartsCore.VisualElements; namespace LiveChartsCore.Kernel.Sketches; @@ -74,14 +76,6 @@ public interface IChartSeries : ISeries, IChartElement double DataLabelsMaxWidth { get; set; } - /// - /// Gets the paint schedule, normally handled internally to display tool tips and legends. - /// - /// - /// The default paint context. - /// - Sketch CanvasSchedule { get; } - /// /// Gets the stack group, normally used internally to handled the stacked series. /// @@ -89,11 +83,19 @@ public interface IChartSeries : ISeries, IChartElement - /// /// /// + [Obsolete($"Replaced by ${nameof(GetMiniature)}")] Sketch GetMiniaturesSketch(); + /// + /// Return the visual element shown in tooltips and legends. + /// + /// The point. + /// The zindex. + /// + VisualElement GetMiniature(ChartPoint? point, int zindex); + /// /// Called when the pointer goes down on a data point or points. /// diff --git a/src/LiveChartsCore/Kernel/Sketches/IHeatSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IHeatSeries.cs index 4c3a2eaf8..a6355f647 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IHeatSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IHeatSeries.cs @@ -52,4 +52,18 @@ public interface IHeatSeries : ICartesianSeries Padding PointPadding { get; set; } + + /// + /// Gets or sets the minimum value in the weight axis, + /// this value will be used to calculate the color of the point. + /// Default is null and means the minimum value in the series. + /// + double? MinValue { get; set; } + + /// + /// Gets or sets the maximum value in the weight axis, + /// this value will be used to calculate the color of the point. + /// Default is null and means the maximum value in the series. + /// + double? MaxValue { get; set; } } diff --git a/src/LiveChartsCore/Kernel/Sketches/IPieChartView.cs b/src/LiveChartsCore/Kernel/Sketches/IPieChartView.cs index bee2e5368..ce3977db9 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IPieChartView.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IPieChartView.cs @@ -67,13 +67,6 @@ public interface IPieChartView : IChartView /// double MaxAngle { get; set; } - /// - /// Gets or sets the total, it is the maximum value a pie slice can represent, when this property is null, the property - /// will be calculated automatically based on the series data. Default value is null. - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - double? Total { get; set; } - /// /// Gets or sets the minimum valu, normally used in gauges to set the minimum value a pie slice can represent, /// default is 0. diff --git a/src/LiveChartsCore/Kernel/Sketches/IPieSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IPieSeries.cs index d7dffe1f4..893546620 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IPieSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IPieSeries.cs @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; @@ -59,15 +58,6 @@ public interface IPieSeries : IChartSeries, IS /// double OuterRadiusOffset { get; set; } - /// - /// Gets or sets the maximum outer radius, the value goes from 0 to 1, where 1 is the full available radius and 0 is none. - /// - /// - /// The maximum outer radius. - /// - [Obsolete($"Replaced by {nameof(OuterRadiusOffset)}")] - double MaxOuterRadius { get; set; } - /// /// Gets or sets the hover push out in pixes, it defines the where the pointer is over the slice. /// diff --git a/src/LiveChartsCore/Kernel/Sketches/IPlane.cs b/src/LiveChartsCore/Kernel/Sketches/IPlane.cs index 7b68d685c..907d609b6 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IPlane.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IPlane.cs @@ -31,7 +31,7 @@ namespace LiveChartsCore.Kernel.Sketches; /// /// Defines a plane for a dimension. /// -public interface IPlane +public interface IPlane : IChartElement { /// /// Gets or sets the axis name. @@ -125,14 +125,6 @@ public interface IPlane /// double? MaxLimit { get; set; } - /// - /// Gets or sets a value indicating whether this instance is visible. - /// - /// - /// true if this instance is visible; otherwise, false. - /// - bool IsVisible { get; set; } - /// /// Gets or sets a value indicating whether the axis is inverted based on the Cartesian coordinate system. /// @@ -192,8 +184,8 @@ public interface IPlane bool ShowSeparatorLines { get; set; } /// - /// Gets or sets the custom separators array, when this property is set (not null) - /// the axis will use the values in this array instead of calculating the separators automatically. + /// Gets or sets the custom separators collection, when this property is set (not null) + /// the axis will use the values in this collection instead of calculating the separators automatically. /// Defalut is null. /// IEnumerable? CustomSeparators { get; set; } diff --git a/src/LiveChartsCore/Kernel/Sketches/IScatterSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IScatterSeries.cs index 9d6639d5c..1cc28d863 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IScatterSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IScatterSeries.cs @@ -48,4 +48,10 @@ public interface IScatterSeries : /// The minimum size of the geometry. /// double MinGeometrySize { get; set; } + + /// + /// Gets or sets and index for the stack group, if multiple weighed series share + /// the same stack group, they will be stacked, defualt is null and means that it is not stacked. + /// + int? StackGroup { get; set; } } diff --git a/src/LiveChartsCore/Kernel/Sketches/IStackedBarSeries.cs b/src/LiveChartsCore/Kernel/Sketches/IStackedBarSeries.cs index c15c804d0..c8ae165e5 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IStackedBarSeries.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IStackedBarSeries.cs @@ -48,14 +48,6 @@ public interface IStackedBarSeries : IChartSeries double Ry { get; set; } - /// - /// Gets or sets the padding for each group of bars that share the same secondary coordinate. - /// - /// - /// The bar group padding. - /// - double GroupPadding { get; set; } - /// /// Gets or sets the maximum width of the bar. /// diff --git a/src/LiveChartsCore/Kernel/StackedValue.cs b/src/LiveChartsCore/Kernel/StackedValue.cs index d6029aa12..24bb628c6 100644 --- a/src/LiveChartsCore/Kernel/StackedValue.cs +++ b/src/LiveChartsCore/Kernel/StackedValue.cs @@ -22,6 +22,7 @@ namespace LiveChartsCore.Kernel; +// ToDo: This should be a struct. /// /// Defines the a stacked value. /// @@ -51,11 +52,6 @@ public class StackedValue /// public double Total { get; set; } - /// - /// Gets the share in the total stack. - /// - public double Share => (End - Start) / Total; - /// /// Gets or sets the start. /// @@ -79,4 +75,13 @@ public class StackedValue /// The total. /// public double NegativeTotal { get; set; } + + /// + /// Gets the share in the total stack. + /// + public double Share => IsNegative + ? (NegativeEnd - NegativeStart) / NegativeTotal + : (End - Start) / Total; + + internal bool IsNegative { get; set; } } diff --git a/src/LiveChartsCore/LiveChartsCore.csproj b/src/LiveChartsCore/LiveChartsCore.csproj index b4f8196ca..479bb6b29 100644 --- a/src/LiveChartsCore/LiveChartsCore.csproj +++ b/src/LiveChartsCore/LiveChartsCore.csproj @@ -11,7 +11,6 @@ $(TargetFrameworks); net462; - net6.0-windows10.0.19041.0; net8.0-windows10.0.19041.0;net8.0-windows10.0.20348.0; @@ -24,7 +23,7 @@ LiveChartsCore LiveChartsCore - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png 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. MIT @@ -67,7 +66,7 @@ + Include="System.Text.Json" Version="8.0.5" /> diff --git a/src/LiveChartsCore/Measure/AxisLimit.cs b/src/LiveChartsCore/Measure/AxisLimit.cs index 37df73eb0..57e9382cc 100644 --- a/src/LiveChartsCore/Measure/AxisLimit.cs +++ b/src/LiveChartsCore/Measure/AxisLimit.cs @@ -67,16 +67,6 @@ internal static void ValidateLimits(ref double min, ref double max) min is double.MaxValue or double.MinValue || max is double.MaxValue or double.MinValue; - // easy workaround to prevent the axis from crashing - // https://github.com/beto-rodriguez/LiveCharts2/issues/1294 - if (min > max) - { - var temp = max; - - max = min; - min = temp; - } - if (!isMax) return; min = 0; diff --git a/src/LiveChartsCore/Measure/DimensionalBounds.cs b/src/LiveChartsCore/Measure/DimensionalBounds.cs index 993e81490..440908734 100644 --- a/src/LiveChartsCore/Measure/DimensionalBounds.cs +++ b/src/LiveChartsCore/Measure/DimensionalBounds.cs @@ -20,9 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using LiveChartsCore.Measure; - -namespace LiveChartsCore.Kernel; +namespace LiveChartsCore.Measure; /// /// Defines bounds for both, X and Y axes. diff --git a/src/LiveChartsCore/Measure/PolarScaler.cs b/src/LiveChartsCore/Measure/PolarScaler.cs index 002c67729..14f0e0816 100644 --- a/src/LiveChartsCore/Measure/PolarScaler.cs +++ b/src/LiveChartsCore/Measure/PolarScaler.cs @@ -75,20 +75,14 @@ public PolarScaler( actualRadiusVisibleBounds = radiusAxis.VisibleDataBounds; } - //var actualAngleBounds = usePreviousScale ? angleAxis.PreviousDataBounds : angleAxis.DataBounds; - //var actualAngleVisibleBounds = usePreviousScale ? angleAxis.PreviousVisibleDataBounds : angleAxis.VisibleDataBounds; - - //var actualRadiusBounds = usePreviousScale ? radiusAxis.PreviousDataBounds : radiusAxis.DataBounds; - //var actualRadiusVisibleBounds = usePreviousScale ? radiusAxis.PreviousVisibleDataBounds : radiusAxis.VisibleDataBounds; - if (actualAngleBounds is null || actualAngleVisibleBounds is null) throw new Exception("angle bounds not found"); if (actualRadiusBounds is null || actualRadiusVisibleBounds is null) throw new Exception("radius bounds not found"); CenterX = drawMarginLocation.X + drawMarginSize.Width * 0.5f; CenterY = drawMarginLocation.Y + drawMarginSize.Height * 0.5f; - MinRadius = radiusAxis.MinLimit ?? actualRadiusVisibleBounds.Min; - MaxRadius = radiusAxis.MaxLimit ?? actualRadiusVisibleBounds.Max; + MinRadius = radiusAxis.IsInverted ? radiusAxis.MaxLimit ?? actualRadiusVisibleBounds.Max : radiusAxis.MinLimit ?? actualRadiusVisibleBounds.Min; + MaxRadius = radiusAxis.IsInverted ? radiusAxis.MinLimit ?? actualRadiusVisibleBounds.Min : radiusAxis.MaxLimit ?? actualRadiusVisibleBounds.Max; _deltaRadius = MaxRadius - MinRadius; var minDimension = drawMarginSize.Width < drawMarginSize.Height ? drawMarginSize.Width : drawMarginSize.Height; @@ -97,8 +91,8 @@ public PolarScaler( _outerRadiusOffset = 0; //drawMagrinLocation.X; // We should also check for the top, right and bottom bounds. _scalableRadius = minDimension * 0.5 - _innerRadiusOffset - _outerRadiusOffset; - MinAngle = angleAxis.MinLimit ?? actualAngleBounds.Min; - MaxAngle = angleAxis.MaxLimit ?? actualAngleBounds.Max; + MinAngle = angleAxis.IsInverted ? angleAxis.MaxLimit ?? actualAngleBounds.Max : angleAxis.MinLimit ?? actualAngleBounds.Min; + MaxAngle = angleAxis.IsInverted ? angleAxis.MinLimit ?? actualAngleBounds.Min : angleAxis.MaxLimit ?? actualAngleBounds.Max; _deltaAngleVal = MaxAngle - MinAngle; _initialRotation = initialRotation; diff --git a/src/LiveChartsCore/Measure/SeriesBounds.cs b/src/LiveChartsCore/Measure/SeriesBounds.cs index deac1f64b..bc1bbe212 100644 --- a/src/LiveChartsCore/Measure/SeriesBounds.cs +++ b/src/LiveChartsCore/Measure/SeriesBounds.cs @@ -20,8 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using LiveChartsCore.Kernel; - namespace LiveChartsCore.Measure; /// diff --git a/src/LiveChartsCore/Measure/StackPosition.cs b/src/LiveChartsCore/Measure/StackPosition.cs index c9ff5890e..7d0f7d7a1 100644 --- a/src/LiveChartsCore/Measure/StackPosition.cs +++ b/src/LiveChartsCore/Measure/StackPosition.cs @@ -65,6 +65,10 @@ public double StackPoint(ChartPoint point) /// public StackedValue GetStack(ChartPoint point) { - return point.StackedValue = Stacker.GetStack(point, Position); + var stack = Stacker.GetStack(point, Position); + stack.IsNegative = point.Coordinate.PrimaryValue < 0; + point.StackedValue = stack; + + return stack; } } diff --git a/src/LiveChartsCore/Motion/MotionCanvas.cs b/src/LiveChartsCore/Motion/MotionCanvas.cs index 0939df793..fd38bbd6c 100644 --- a/src/LiveChartsCore/Motion/MotionCanvas.cs +++ b/src/LiveChartsCore/Motion/MotionCanvas.cs @@ -94,7 +94,7 @@ public void DrawFrame(TDrawingContext context) if (LiveCharts.EnableLogging) Trace.WriteLine( $"[core canvas frame drawn] ".PadRight(60) + - $"tread: {Environment.CurrentManagedThreadId}"); + $"thread: {Environment.CurrentManagedThreadId}"); #endif lock (Sync) diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index f1b592653..925944c16 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -115,7 +115,7 @@ protected internal override void Measure() { Trace.WriteLine( $"[Cartesian chart measured]".PadRight(60) + - $"tread: {Environment.CurrentManagedThreadId}"); + $"thread: {Environment.CurrentManagedThreadId}"); } #endif @@ -148,7 +148,7 @@ protected internal override void Measure() EasingFunction = view.EasingFunction; SeriesContext = new SeriesContext(VisibleSeries, this); - var isNewTheme = LiveCharts.DefaultSettings.CurrentThemeId != ThemeId; + var themeId = LiveCharts.DefaultSettings.CurrentThemeId; var theme = LiveCharts.DefaultSettings.GetTheme(); @@ -162,10 +162,10 @@ protected internal override void Measure() var ce = (ChartElement)series; ce._isInternalSet = true; - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { theme.ApplyStyleToSeries(series); - ce._isThemeSet = true; + ce._theme = themeId; } var seriesBounds = series.GetBounds(this); @@ -225,8 +225,13 @@ protected internal override void Measure() AddVisual(title); } - foreach (var visual in VisualElements) AddVisual(visual); - foreach (var series in VisibleSeries) + // we draw all the series even invisible because it animates the series when hidden. + // Sections and Visuals are not animated when hidden, thus we just skip them. + // it means that invisible series have a performance impact, it should not be a big deal + // but ideally, do not keep invisible series in the chart, instead, add/remove them when needed. + + foreach (var visual in VisualElements.Where(x => x.IsVisible)) AddVisual(visual); + foreach (var series in Series) { AddVisual((ChartElement)series); _drawnSeries.Add(series.SeriesId); @@ -234,10 +239,9 @@ protected internal override void Measure() CollectVisuals(); - if (_isToolTipOpen) DrawToolTip(); + if (_isToolTipOpen) _ = DrawToolTip(); InvokeOnUpdateStarted(); _isFirstDraw = false; - ThemeId = LiveCharts.DefaultSettings.CurrentThemeId; Canvas.Invalidate(); _isFirstDraw = false; diff --git a/src/LiveChartsCore/PolarChart.cs b/src/LiveChartsCore/PolarChart.cs index 95bd96569..a867c8848 100644 --- a/src/LiveChartsCore/PolarChart.cs +++ b/src/LiveChartsCore/PolarChart.cs @@ -135,7 +135,7 @@ protected internal override void Measure() { Trace.WriteLine( $"[Cartesian chart measured]".PadRight(60) + - $"tread: {Environment.CurrentManagedThreadId}"); + $"thread: {Environment.CurrentManagedThreadId}"); } #endif if (!IsLoaded) return; // <- prevents a visual glitch where the visual call the measure method @@ -198,7 +198,7 @@ protected internal override void Measure() #endregion SeriesContext = new SeriesContext(VisibleSeries, this); - var isNewTheme = LiveCharts.DefaultSettings.CurrentThemeId != ThemeId; + var themeId = LiveCharts.DefaultSettings.CurrentThemeId; // restart axes bounds and meta data foreach (var axis in AngleAxes) @@ -206,10 +206,10 @@ protected internal override void Measure() var ce = (ChartElement)axis; ce._isInternalSet = true; axis.Initialize(PolarAxisOrientation.Angle); - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { theme.ApplyStyleToAxis((IPlane)axis); - ce._isThemeSet = true; + ce._theme = themeId; } ce._isInternalSet = false; } @@ -218,10 +218,10 @@ protected internal override void Measure() var ce = (ChartElement)axis; ce._isInternalSet = true; axis.Initialize(PolarAxisOrientation.Radius); - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { theme.ApplyStyleToAxis((IPlane)axis); - ce._isThemeSet = true; + ce._theme = themeId; } ce._isInternalSet = false; } @@ -234,10 +234,10 @@ protected internal override void Measure() var ce = (ChartElement)series; ce._isInternalSet = true; - if (!ce._isThemeSet || isNewTheme) + if (ce._theme != themeId) { theme.ApplyStyleToSeries(series); - ce._isThemeSet = true; + ce._theme = themeId; } var secondaryAxis = AngleAxes[series.ScalesAngleAt]; @@ -247,7 +247,7 @@ protected internal override void Measure() if (seriesBounds.IsEmpty) { - ce._isThemeSet = false; + ce._isInternalSet = false; continue; } @@ -255,7 +255,8 @@ protected internal override void Measure() primaryAxis.DataBounds.AppendValue(seriesBounds.PrimaryBounds); secondaryAxis.VisibleDataBounds.AppendValue(seriesBounds.SecondaryBounds); primaryAxis.VisibleDataBounds.AppendValue(seriesBounds.PrimaryBounds); - ce._isThemeSet = false; + + ce._isInternalSet = false; } #region empty bounds @@ -508,8 +509,13 @@ protected internal override void Measure() // the probable issue is the "IsVisible" property } - foreach (var visual in VisualElements) AddVisual(visual); - foreach (var series in VisibleSeries) + // we draw all the series even invisible because it animates the series when hidden. + // Sections and Visuals are not animated when hidden, thus we just skip them. + // it means that invisible series have a performance impact, it should not be a big deal + // but ideally, do not keep invisible series in the chart, instead, add/remove them when needed. + + foreach (var visual in VisualElements.Where(x => x.IsVisible)) AddVisual(visual); + foreach (var series in Series) { AddVisual((ChartElement)series); _drawnSeries.Add(series.SeriesId); @@ -531,33 +537,11 @@ protected internal override void Measure() if (_isToolTipOpen) DrawToolTip(); _isFirstDraw = false; - ThemeId = LiveCharts.DefaultSettings.CurrentThemeId; Canvas.Invalidate(); _isFirstDraw = false; } - /// - /// Scales the specified point to the UI. - /// - /// The point, where X = angle, Y = radius. - /// Index of the angle axis. - /// Index of the radius axis. - /// - public double[] ScaleUIPoint(LvcPoint point, int angleAxisIndex = 0, int radiusAxisIndex = 0) - { - var angleAxis = AngleAxes[angleAxisIndex]; - var radiusAxis = RadiusAxes[radiusAxisIndex]; - - var scaler = new PolarScaler( - DrawMarginLocation, DrawMarginSize, angleAxis, radiusAxis, - InnerRadius, InitialRotation, TotalAnge); - - var r = scaler.ToChartValues(point.X, point.Y); - - return new double[] { r.X, r.Y }; - } - /// public override void Unload() { diff --git a/src/LiveChartsCore/Section.cs b/src/LiveChartsCore/Section.cs index 317c42a4b..0c7f7b28b 100644 --- a/src/LiveChartsCore/Section.cs +++ b/src/LiveChartsCore/Section.cs @@ -46,7 +46,6 @@ public abstract class Section : ChartElement, private int _scalesXAt; private int _scalesYAt; private int? _zIndex; - private bool _isVisible = true; /// /// Gets or sets the stroke. @@ -84,11 +83,6 @@ public IPaint? LabelPaint set => SetPaintProperty(ref _labelPaint, value); } - /// - /// Gets or sets whether the section is visible or not. - /// - public bool IsVisible { get => _isVisible; set => SetProperty(ref _isVisible, value); } - /// /// Gets or sets the xi, the value where the section starts at the X axis, /// set the property to null to indicate that the section must start at the beginning of the X axis, default is null. diff --git a/src/LiveChartsCore/Series.cs b/src/LiveChartsCore/Series.cs index 14d5c6bd5..f37bc3466 100644 --- a/src/LiveChartsCore/Series.cs +++ b/src/LiveChartsCore/Series.cs @@ -34,6 +34,7 @@ using LiveChartsCore.Kernel.Providers; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; +using LiveChartsCore.VisualElements; namespace LiveChartsCore; /// @@ -94,12 +95,11 @@ public abstract class Series protected bool _geometrySvgChanged = false; private readonly CollectionDeepObserver _observer; - private ICollection? _values; + private ICollection? _values; private string? _name; private Func? _mapping; private int _zIndex; private Func, string> _dataLabelsFormatter = x => x.Coordinate.PrimaryValue.ToString(); - private bool _isVisible = true; private LvcPoint _dataPadding = new(0.5f, 0.5f); private DataFactory? _dataFactory; private bool _isVisibleAtLegend = true; @@ -113,16 +113,19 @@ public abstract class Series /// Initializes a new instance of the class. /// /// The properties. - protected Series(SeriesProperties properties) + /// The values. + protected Series(SeriesProperties properties, ICollection? values) { SeriesProperties = properties; - if (typeof(ISvgPath).IsAssignableFrom(typeof(TVisual))) + if (typeof(IVariableSvgPath).IsAssignableFrom(typeof(TVisual))) SeriesProperties |= SeriesProperties.IsSVGPath; _observer = new CollectionDeepObserver( (sender, e) => NotifySubscribers(), (sender, e) => NotifySubscribers()); + + Values = values; } /// @@ -140,7 +143,7 @@ SeriesProperties IInternalSeries.SeriesProperties /// /// Gets or sets the data set to draw in the chart. /// - public ICollection? Values + public ICollection? Values { get => _values; set @@ -152,6 +155,12 @@ public ICollection? Values } } + IEnumerable? ISeries.Values + { + get => Values; + set => Values = (ICollection?)value; + } + /// public double Pivot { get => pivot; set => SetProperty(ref pivot, (float)value); } @@ -167,10 +176,10 @@ public string? GeometrySvg _geometrySvgChanged = true; SetProperty(ref _geometrySvg, value); - if (!this.HasSvgGeometry()) + if (!this.HasVariableSvgGeometry()) { throw new Exception( - $"You must use a geometry that implements {nameof(ISvgPath)}, " + + $"You must use a geometry that implements {nameof(IVariableSvgPath)}, " + $"{nameof(TVisual)} does not satisfies the constrait."); } } @@ -195,18 +204,6 @@ public string? GeometrySvg /// public event ChartPointsHandler? DataPointerDown; - /// - /// Occurs when the pointer is over a chart point. - /// - [Obsolete($"Renamed to {nameof(ChartPointPointerHover)}")] - public event ChartPointHandler? DataPointerHover; - - /// - /// Occurs when the pointer left a chart point. - /// - [Obsolete($"Renamed to {nameof(ChartPointPointerHoverLost)}")] - public event ChartPointHandler? DataPointerHoverLost; - /// /// Occurs when the pointer is over a chart point. /// @@ -238,14 +235,6 @@ public Func, string> DataLabelsFormatter set => SetProperty(ref _dataLabelsFormatter, value); } - /// - public bool IsVisible - { - get => _isVisible; - set - => SetProperty(ref _isVisible, value); - } - /// public bool IsHoverable { get; set; } = true; @@ -283,19 +272,6 @@ public DataFactory DataFactory /// public Action>? WhenPointMeasured { get; set; } - /// - /// Gets or sets the size of the legend shape. - /// - /// - /// The size of the legend shape. - /// - [Obsolete($"Renamed to {nameof(MiniatureShapeSize)}")] - public double LegendShapeSize - { - get => MiniatureShapeSize; - set => MiniatureShapeSize = value; - } - /// /// Gets or sets the size of the legend shape. /// @@ -308,21 +284,20 @@ public double MiniatureShapeSize set { _miniatureShapeSize = value; - OnMiniatureChanged(); SetProperty(ref _miniatureShapeSize, value); } } - /// + /// + /// Obsolete. + /// + [Obsolete($"Replaced by ${nameof(GetMiniature)}")] public Sketch CanvasSchedule { get => _miniatureSketch; protected set => SetProperty(ref _miniatureSketch, value); } - /// - public event Action? VisibilityChanged; - /// public virtual int GetStackGroup() { @@ -421,8 +396,12 @@ public ChartPoint ConvertToTypedChartPoint(ChartPoint p public abstract void SoftDeleteOrDispose(IChartView chart); /// + [Obsolete($"Replaced by ${nameof(GetMiniature)}")] public abstract Sketch GetMiniaturesSketch(); + /// + public abstract VisualElement GetMiniature(ChartPoint? point, int zindex); + /// /// Builds a paint schedule. /// @@ -478,21 +457,12 @@ protected internal virtual void OnPointCreated(ChartPoint chartPoint) /// protected abstract void SetDefaultPointTransitions(ChartPoint chartPoint); - /// - /// Called when the visibility changes. - /// - protected virtual void OnVisibilityChanged() - { - VisibilityChanged?.Invoke(this); - } - /// /// Called when the pointer enters a point. /// /// The chart point. protected virtual void OnPointerEnter(ChartPoint point) { - DataPointerHover?.Invoke(point.Context.Chart, new ChartPoint(point)); ChartPointPointerHover?.Invoke(point.Context.Chart, new ChartPoint(point)); } @@ -502,7 +472,6 @@ protected virtual void OnPointerEnter(ChartPoint point) /// The chart point. protected virtual void OnPointerLeft(ChartPoint point) { - DataPointerHoverLost?.Invoke(point.Context.Chart, new ChartPoint(point)); ChartPointPointerHoverLost?.Invoke(point.Context.Chart, new ChartPoint(point)); } @@ -510,15 +479,26 @@ protected virtual void OnPointerLeft(ChartPoint point) protected override void OnPaintChanged(string? propertyName) { base.OnPaintChanged(propertyName); - OnMiniatureChanged(); } /// - /// Called when the miniature changes. + /// Gets the miniature paint. /// - protected void OnMiniatureChanged() + /// the base paint. + /// the z index. + /// + protected virtual IPaint? GetMiniaturePaint(IPaint? paint, int zIndex) { - CanvasSchedule = GetMiniaturesSketch(); + if (paint is null) return null; + + var clone = paint.CloneTask(); + clone.ZIndex = zIndex; + + const float MAX_MINIATURE_STROKE_WIDTH = 3.5f; + if (clone.StrokeThickness > MAX_MINIATURE_STROKE_WIDTH) + clone.StrokeThickness = MAX_MINIATURE_STROKE_WIDTH; + + return clone; } private void NotifySubscribers() diff --git a/src/LiveChartsCore/SharedAxes.cs b/src/LiveChartsCore/SharedAxes.cs new file mode 100644 index 000000000..e9d055b96 --- /dev/null +++ b/src/LiveChartsCore/SharedAxes.cs @@ -0,0 +1,60 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// Ignore Spelling: Crosshair Subticks Subseparators + +using System.Collections.Generic; +using System.Linq; +using LiveChartsCore.Drawing; +using LiveChartsCore.Kernel.Sketches; + +namespace LiveChartsCore; + +/// +/// A helper class that configures shared axes. +/// +public static class SharedAxes +{ + /// + /// Sets the specified axes as shared. + /// + /// The type of the drawing context. + /// The axes to share. + public static void Set(params ICartesianAxis[] axes) + where TDrawingContext : DrawingContext + { + var sharedInstance = new HashSet>(); + + foreach (var axis in axes) + { + axis.SharedWith = axes + .Where(x => x != axis) + .ToArray(); + + axis.MeasureStarted += (IChart chart, ICartesianAxis obj) => + { + var cc = (CartesianChart)chart; + cc.SubscribeSharedEvents(sharedInstance); + }; + } + } +} diff --git a/src/LiveChartsCore/StrokeAndFillCartesianSeries.cs b/src/LiveChartsCore/StrokeAndFillCartesianSeries.cs index 6a8c4dc8a..7e59550e3 100644 --- a/src/LiveChartsCore/StrokeAndFillCartesianSeries.cs +++ b/src/LiveChartsCore/StrokeAndFillCartesianSeries.cs @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; +using System.Collections.Generic; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; @@ -33,23 +33,22 @@ namespace LiveChartsCore; /// The type of the visual. /// The type of the label. /// The type of the drawing context. -public abstract class StrokeAndFillCartesianSeries - : CartesianSeries - where TDrawingContext : DrawingContext - where TVisual : class, IGeometry, new() - where TLabel : class, ILabelGeometry, new() +/// +/// Initializes a new instance of the class. +/// +/// The properties. +/// The values. +public abstract class StrokeAndFillCartesianSeries( + SeriesProperties properties, + ICollection? values) + : CartesianSeries(properties, values) + where TDrawingContext : DrawingContext + where TVisual : class, IGeometry, new() + where TLabel : class, ILabelGeometry, new() { private IPaint? _stroke = null; private IPaint? _fill = null; - /// - /// Initializes a new instance of the class. - /// - /// The properties. - protected StrokeAndFillCartesianSeries(SeriesProperties properties) - : base(properties) - { } - /// /// Gets or sets the stroke. /// @@ -77,6 +76,34 @@ public IPaint? Fill /// protected internal override IPaint?[] GetPaintTasks() { - return new[] { _stroke, _fill, DataLabelsPaint }; + return [_stroke, _fill, DataLabelsPaint]; + } + + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureFill(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Fill ?? Fill; + + return GetMiniaturePaint(paint, zIndex); + } + + /// + /// Gets the fill paint for the miniature. + /// + /// the point/ + /// the x index. + /// + protected virtual IPaint? GetMiniatureStroke(ChartPoint? point, int zIndex) + { + var p = point is null ? null : ConvertToTypedChartPoint(point); + var paint = p?.Visual?.Stroke ?? Stroke; + + return GetMiniaturePaint(paint, zIndex); } } diff --git a/src/LiveChartsCore/Themes/LiveChartsStylerExtensions.cs b/src/LiveChartsCore/Themes/LiveChartsStylerExtensions.cs index a06e1557b..2bb7acd0f 100644 --- a/src/LiveChartsCore/Themes/LiveChartsStylerExtensions.cs +++ b/src/LiveChartsCore/Themes/LiveChartsStylerExtensions.cs @@ -22,7 +22,9 @@ using System; using LiveChartsCore.Drawing; +using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Sketches; +using LiveChartsCore.VisualElements; namespace LiveChartsCore.Themes; @@ -382,4 +384,22 @@ public static Theme HasRuleForPolarLineSeries( styler.PolarLineSeriesBuilder.Add(predicate); return styler; } + + /// + /// Defines a style builder for objects. + /// + /// The type of the chart element. + /// The type of the drawing context. + /// the styler. + /// the predicate. + /// + public static Theme HasRuleFor( + this Theme styler, + Action predicate) + where TDrawingContext : DrawingContext + where TChartElement : ChartElement + { + styler.ChartElementElementBuilder.Add(typeof(TChartElement), predicate); + return styler; + } } diff --git a/src/LiveChartsCore/Themes/Theme.cs b/src/LiveChartsCore/Themes/Theme.cs index 20076fadf..e232b60ad 100644 --- a/src/LiveChartsCore/Themes/Theme.cs +++ b/src/LiveChartsCore/Themes/Theme.cs @@ -27,6 +27,7 @@ using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Sketches; +using LiveChartsCore.VisualElements; namespace LiveChartsCore.Themes; @@ -234,6 +235,11 @@ public class Theme /// public List>> BoxSeriesBuilder { get; set; } = []; + /// + /// Gets or sets the visual element builder. + /// + public Dictionary ChartElementElementBuilder { get; set; } = []; + /// /// Applies the theme to an axis. /// @@ -385,6 +391,19 @@ public void ApplyStyleToDrawMargin(DrawMarginFrame drawMarginFr foreach (var rule in DrawMarginFrameBuilder) rule(drawMarginFrame); } + /// + /// Applies the theme to a visual element. + /// + /// The typoe of the chart element. + /// The visual element. + public void ApplyStyleTo(TChartElement visualElement) + where TChartElement : VisualElement + { + if (!ChartElementElementBuilder.TryGetValue(typeof(TChartElement), out var builder)) return; + + ((Action)builder)(visualElement); + } + /// /// Gets the color of a series according to the theme. /// diff --git a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs index 475b216c5..8bc7e03a0 100644 --- a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs +++ b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs @@ -102,26 +102,7 @@ protected internal override void OnInvalidated(Chart chart) if (chart is not PieChart pieChart) throw new Exception("The AngularThicksVisual can only be added to a pie chart"); - _isInternalSet = true; - if (!_isThemeSet) - { - if (CanSetProperty(nameof(Stroke))) - { - Stroke = LiveCharts.DefaultSettings - .GetProvider() - .GetSolidColorPaint(new LvcColor(30, 30, 30, 255)); - } - - if (CanSetProperty(nameof(LabelsPaint))) - { - LabelsPaint = LiveCharts.DefaultSettings - .GetProvider() - .GetSolidColorPaint(new LvcColor(30, 30, 30, 255)); - } - - _isThemeSet = true; - } - _isInternalSet = false; + ApplyTheme>(); var drawLocation = pieChart.DrawMarginLocation; var drawMarginSize = pieChart.DrawMarginSize; diff --git a/src/LiveChartsCore/VisualElements/GeometryVisual.cs b/src/LiveChartsCore/VisualElements/GeometryVisual.cs index 75974b307..3d4dfe876 100644 --- a/src/LiveChartsCore/VisualElements/GeometryVisual.cs +++ b/src/LiveChartsCore/VisualElements/GeometryVisual.cs @@ -54,6 +54,11 @@ public class GeometryVisual : BaseGe /// public double LabelSize { get => _labelSize; set => SetProperty(ref _labelSize, (float)value); } + /// + /// Gets or sets the SVG path. + /// + public string? Svg { get; set; } + /// /// Gets or sets the label paint. /// @@ -86,8 +91,18 @@ protected internal override void OnInvalidated(Chart chart) X = l.X, Y = l.Y, Width = size.Width, - Height = size.Height + Height = size.Height, + RotateTransform = (float)Rotation }; + + if (Svg is not null) + { + var svgGeometry = _geometry as IVariableSvgPath + ?? throw new Exception($"The geometry must be of type {nameof(IVariableSvgPath)}."); + + svgGeometry.SVGPath = Svg; + } + _geometry.Animate(chart); } diff --git a/src/LiveChartsCore/VisualElements/LabelVisual.cs b/src/LiveChartsCore/VisualElements/LabelVisual.cs index 6fc397ea5..89592d7c6 100644 --- a/src/LiveChartsCore/VisualElements/LabelVisual.cs +++ b/src/LiveChartsCore/VisualElements/LabelVisual.cs @@ -165,6 +165,8 @@ protected internal override void SetParent(IGeometry parent) /// public override LvcSize Measure(Chart chart) { + ApplyTheme>(); + InitializeLabel(chart); _labelGeometry!.Text = Text; diff --git a/src/LiveChartsCore/VisualElements/LineVisual.cs b/src/LiveChartsCore/VisualElements/LineVisual.cs new file mode 100644 index 000000000..fee36f93a --- /dev/null +++ b/src/LiveChartsCore/VisualElements/LineVisual.cs @@ -0,0 +1,112 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using LiveChartsCore.Drawing; +using LiveChartsCore.Kernel; +using LiveChartsCore.Measure; + +namespace LiveChartsCore.VisualElements; + +/// +/// Defines a visual element in a chart that draws a sized geometry in the user interface. +/// +/// The type of the geometry. +/// The type of the drawing context. +public class LineVisual : BaseGeometryVisual + where TDrawingContext : DrawingContext + where TGeometry : ILineGeometry, new() +{ + internal TGeometry? _geometry; + + /// + protected internal override IAnimatable?[] GetDrawnGeometries() => [_geometry]; + + /// + protected internal override void OnInvalidated(Chart chart) + { + var l = GetActualCoordinate(); + var size = Measure(chart); + var clipping = Clipping.GetClipRectangle(ClippingMode, chart); + + if (_geometry is null) + { + _geometry = new() + { + X = l.X, + Y = l.Y, + X1 = l.X + size.Width, + Y1 = l.Y + size.Height + }; + _geometry.Animate(chart); + } + + _geometry.X = l.X; + _geometry.Y = l.Y; + _geometry.X1 = l.X + size.Width; + _geometry.Y1 = l.Y + size.Height; + _geometry.RotateTransform = (float)Rotation; + _geometry.TranslateTransform = Translate; + + if (Fill is not null) + { + chart.Canvas.AddDrawableTask(Fill); + Fill.AddGeometryToPaintTask(chart.Canvas, _geometry); + Fill.SetClipRectangle(chart.Canvas, clipping); + } + + if (Stroke is not null) + { + chart.Canvas.AddDrawableTask(Stroke); + Stroke.AddGeometryToPaintTask(chart.Canvas, _geometry); + Stroke.SetClipRectangle(chart.Canvas, clipping); + } + } + + /// + protected internal override void SetParent(IGeometry parent) + { + if (_geometry is null) return; + _geometry.Parent = parent; + } + + /// + public override LvcSize Measure(Chart chart) + { + var w = (float)Width; + var h = (float)Height; + + if (SizeUnit == MeasureUnit.ChartValues) + { + if (PrimaryScaler is null || SecondaryScaler is null) + throw new Exception($"You can not use {MeasureUnit.ChartValues} scale at this element."); + + w = SecondaryScaler.MeasureInPixels(w); + h = PrimaryScaler.MeasureInPixels(h); + } + + return new LvcSize(w, h); + } + + /// + protected internal override IPaint?[] GetPaintTasks() => [Fill, Stroke]; +} diff --git a/src/LiveChartsCore/VisualElements/NeedleVisual.cs b/src/LiveChartsCore/VisualElements/NeedleVisual.cs index 1bb8c1cb8..45770daa6 100644 --- a/src/LiveChartsCore/VisualElements/NeedleVisual.cs +++ b/src/LiveChartsCore/VisualElements/NeedleVisual.cs @@ -59,19 +59,11 @@ public IPaint? Fill /// protected internal override void OnInvalidated(Chart chart) { + ApplyTheme>(); + if (chart is not PieChart pieChart) throw new Exception("The needle visual can only be added to a pie chart"); - _isInternalSet = true; - if (!_isThemeSet && CanSetProperty(nameof(Fill))) - { - _fill = LiveCharts.DefaultSettings - .GetProvider() - .GetSolidColorPaint(new LvcColor(30, 30, 30, 255)); - _isThemeSet = true; - } - _isInternalSet = false; - var drawLocation = pieChart.DrawMarginLocation; var drawMarginSize = pieChart.DrawMarginSize; diff --git a/src/LiveChartsCore/VisualElements/RelativePanel.cs b/src/LiveChartsCore/VisualElements/RelativePanel.cs index c672cc51d..a2e26d0cb 100644 --- a/src/LiveChartsCore/VisualElements/RelativePanel.cs +++ b/src/LiveChartsCore/VisualElements/RelativePanel.cs @@ -117,7 +117,8 @@ protected internal override void SetParent(IGeometry parent) BackgroundGeometry.Parent = parent; } - internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) + /// + protected internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) { var location = GetActualCoordinate(); var size = Measure(chart); diff --git a/src/LiveChartsCore/VisualElements/StackPanel.cs b/src/LiveChartsCore/VisualElements/StackPanel.cs index 1a0f5b8f4..3de0fe9d0 100644 --- a/src/LiveChartsCore/VisualElements/StackPanel.cs +++ b/src/LiveChartsCore/VisualElements/StackPanel.cs @@ -113,7 +113,8 @@ public IPaint? BackgroundPaint return new IAnimatable?[] { BackgroundGeometry }; } - internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) + /// + protected internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) { var location = GetActualCoordinate(); var size = Measure(chart); diff --git a/src/LiveChartsCore/VisualElements/TableLayout.cs b/src/LiveChartsCore/VisualElements/TableLayout.cs index d505f84a6..d0b31d0c0 100644 --- a/src/LiveChartsCore/VisualElements/TableLayout.cs +++ b/src/LiveChartsCore/VisualElements/TableLayout.cs @@ -264,7 +264,8 @@ protected internal override void SetParent(IGeometry parent) return new[] { _backgroundPaint }; } - internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) + /// + protected internal override IEnumerable> IsHitBy(Chart chart, LvcPoint point) { var location = GetActualCoordinate(); var size = Measure(chart); diff --git a/src/LiveChartsCore/VisualElements/VisualElement.cs b/src/LiveChartsCore/VisualElements/VisualElement.cs index 9cd9e689e..9a2ac218e 100644 --- a/src/LiveChartsCore/VisualElements/VisualElement.cs +++ b/src/LiveChartsCore/VisualElements/VisualElement.cs @@ -180,7 +180,13 @@ protected LvcPoint GetActualCoordinate() return new(x, y); } - internal virtual IEnumerable> IsHitBy(Chart chart, LvcPoint point) + /// + /// Determines whether the given point hits visuals in the chart. + /// + /// The chart. + /// The point in the UI. + /// The visual or visuals touched by the point. + protected internal virtual IEnumerable> IsHitBy(Chart chart, LvcPoint point) { var location = GetActualCoordinate(); var size = Measure(chart); @@ -193,7 +199,11 @@ internal virtual IEnumerable> IsHitBy(Chart args) + /// + /// Called when the pointer goes down on the visual. + /// + /// The event arguments. + protected internal void InvokePointerDown(VisualElementEventArgs args) { PointerDown?.Invoke(this, args); } @@ -204,6 +214,22 @@ internal void InvokePointerDown(VisualElementEventArgs args) /// The geometries. protected internal abstract IAnimatable?[] GetDrawnGeometries(); + /// + /// Applies the theme to the visual. + /// + protected virtual void ApplyTheme() + where T : VisualElement + { + _isInternalSet = true; + if (_theme != LiveCharts.DefaultSettings.CurrentThemeId) + { + var theme = LiveCharts.DefaultSettings.GetTheme(); + theme.ApplyStyleTo((T)this); + _theme = LiveCharts.DefaultSettings.CurrentThemeId; + } + _isInternalSet = false; + } + internal virtual void AlignToTopLeftCorner() { // just a workaround to align labels as the rest of the geometries. diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs index 665f7cf79..d288770e2 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs @@ -602,15 +602,6 @@ public ICommand? VisualElementsPointerDownCommand #endregion - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (_core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)_core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -662,21 +653,11 @@ void IChartView.InvokeOnUIThread(Action action) /// protected void InitializeCore() { - var canvas = this.FindControl("canvas"); - - var zoomingSection = new Drawing.Geometries.RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas!.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); + var canvas = this.FindControl("canvas")!; _avaloniaCanvas = canvas; _core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); _core.Measuring += OnCoreMeasuring; _core.UpdateStarted += OnCoreUpdateStarted; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LegendBindingContext.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LegendBindingContext.cs deleted file mode 100644 index 1a1535a2a..000000000 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LegendBindingContext.cs +++ /dev/null @@ -1,89 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; -using System.Linq; -using Avalonia.Media; - -namespace LiveChartsCore.SkiaSharpView.Avalonia; - -/// -/// The legend binding context. -/// -public class LegendBindingContext -{ - /// - /// Gets or sets the series. - /// - /// - /// The series. - /// - public IEnumerable Series { get; set; } = Enumerable.Empty(); - - /// - /// Gets or sets the font family. - /// - /// - /// The font family. - /// - public FontFamily FontFamily { get; set; } = new("Trebuchet MS"); - - /// - /// Gets or sets the size of the font. - /// - /// - /// The size of the font. - /// - public double FontSize { get; set; } - - /// - /// Gets or sets the font weight. - /// - /// - /// The font weight. - /// - public FontWeight FontWeight { get; set; } - - /// - /// Gets or sets the font style. - /// - /// - /// The font style. - /// - public FontStyle FontStyle { get; set; } - - /// - /// Gets or sets the text brush. - /// - /// - /// The text brush. - /// - public IBrush? TextBrush { get; set; } = new SolidColorBrush(Color.FromRgb(35, 35, 35)); - - /// - /// Gets or sets the background. - /// - /// - /// The background. - /// - public IBrush? Background { get; set; } = new SolidColorBrush(Color.FromRgb(250, 250, 250)); -} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj index a6bea82ca..fddedd9ef 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj @@ -8,7 +8,7 @@ LiveChartsCore.SkiaSharpView.Avalonia LiveChartsCore.SkiaSharpView.Avalonia - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for AvaloniaUI. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs index 54d8d9672..fa403fe2c 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs @@ -386,14 +386,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double MinValue { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/AssemblyInfo.cs index ef2b24be4..e88214948 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/AssemblyInfo.cs @@ -20,9 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Windows; + +#if !DEBUG && NET462 using System.Reflection; +[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] +#else using System.Runtime.CompilerServices; -using System.Windows; +[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] +#endif [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located @@ -32,10 +38,3 @@ //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] - -#if !DEBUG -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs index 17d2de249..06ba40d19 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs @@ -293,15 +293,6 @@ public TooltipFindingStrategy TooltipFindingStrategy #endregion - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -351,18 +342,8 @@ protected override void InitializeCore() { if (canvas is null) throw new Exception("canvas not found"); - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj index 0ac2f308b..8aeb7ed47 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj @@ -4,10 +4,14 @@ enable 12.0 true - net462;netcoreapp3.1 + + net462;netcoreapp3.1 LiveChartsCore.SkiaSharpView.WPF LiveChartsCore.SkiaSharpView.WPF - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for WPF. MIT @@ -30,7 +34,7 @@ - + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/PieChart.cs index 727c62c39..fc0ba3c3b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/PieChart.cs @@ -152,14 +152,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double? MaxValue { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/AssemblyInfo.cs index 9f5a39c7a..a21d8a792 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/AssemblyInfo.cs @@ -20,13 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System.Runtime.CompilerServices; -#if !DEBUG +#if !DEBUG && NET462 using System.Reflection; - [assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] #else +using System.Runtime.CompilerServices; + [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] #endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs index 22890b5a1..4248ea62d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs @@ -177,31 +177,13 @@ public DrawMarginFrame? DrawMarginFrame /// protected override void InitializeCore() { - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(motionCanvas.CanvasCore, zoomingSection); - motionCanvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - core = new CartesianChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); + if (((IChartView)this).DesignerMode) return; core.Update(); } - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj index 88308d0d1..761d37c31 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj @@ -7,10 +7,14 @@ WinExe true Library - net462;netcoreapp3.1 + + net462;netcoreapp3.1 LiveChartsCore.SkiaSharpView.WinForms LiveChartsCore.SkiaSharpView.WinForms - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for WindowsForms. MIT @@ -38,7 +42,7 @@ - + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs index 4e35130ae..9cd61a7bb 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs @@ -98,10 +98,6 @@ public IEnumerable Series /// public double MaxAngle { get => _maxAngle; set { _maxAngle = value; OnPropertyChanged(); } } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } - /// public double? MaxValue { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs index 021f08400..abf25e4a3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs @@ -650,15 +650,6 @@ public TimeSpan TooltipCloseInterval #endregion - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -710,18 +701,9 @@ void IChartView.InvokeOnUIThread(Action action) /// protected void InitializeCore() { - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); + core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj index 6193c659b..43a937ec3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj @@ -6,7 +6,7 @@ netstandard2.0; LiveChartsCore.SkiaSharpView.XamarinForms LiveChartsCore.SkiaSharpView.XamarinForms - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for XamarinForms. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs index d4c78dd6c..b7afd84cc 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs @@ -417,14 +417,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double? MaxValue { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/AssemblyInfo.cs index 799ace75a..7c2a68a0c 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/AssemblyInfo.cs @@ -20,13 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System.Runtime.CompilerServices; -#if !DEBUG +#if !DEBUG && NET462 using System.Reflection; [assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] + #else +using System.Runtime.CompilerServices; + [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] [assembly: InternalsVisibleTo("LiveChartsCore.UnitTesting")] + #endif diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs index 25b487bcd..3fdfa94bd 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class BoxSeries : CoreBoxSeries -{ } +public class BoxSeries + : BoxSeries +{ + /// + /// Initializes a new instance of the class. + /// + public BoxSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a box serries series in the user interface. @@ -53,9 +80,35 @@ public class BoxSeries : CoreBoxSeries /// The type of the geometry of every point of the series. /// -public class BoxSeries : CoreBoxSeries - where TVisual : class, IBoxGeometry, new() -{ } +public class BoxSeries + : BoxSeries + where TVisual : class, IBoxGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public BoxSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a box serries series in the user interface. @@ -73,7 +126,33 @@ public class BoxSeries : CoreBoxSeries /// The type of the data label of every point. /// -public class BoxSeries : CoreBoxSeries - where TVisual : class, IBoxGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } +public class BoxSeries + : CoreBoxSeries + where TVisual : class, IBoxGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public BoxSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public BoxSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs index 06d5a33ad..eb3de536e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class CandlesticksSeries : CandlesticksSeries -{ } +public class CandlesticksSeries + : CandlesticksSeries +{ + /// + /// Initializes a new instance of the class. + /// + public CandlesticksSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a candlesticks series in the user interface. @@ -53,9 +80,35 @@ public class CandlesticksSeries : CandlesticksSeries /// The type of the geometry of every point of the series. /// -public class CandlesticksSeries : CandlesticksSeries - where TVisual : class, IFinancialGeometry, new() -{ } +public class CandlesticksSeries + : CandlesticksSeries + where TVisual : class, IFinancialGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public CandlesticksSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a candlesticks series in the user interface. @@ -73,7 +126,33 @@ public class CandlesticksSeries : CandlesticksSeries /// The type of the data label of every point. /// -public class CandlesticksSeries : CoreFinancialSeries - where TVisual : class, IFinancialGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } +public class CandlesticksSeries + : CoreFinancialSeries + where TVisual : class, IFinancialGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public CandlesticksSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public CandlesticksSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs index b8932857f..7bcbbcfc4 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class ColumnSeries : ColumnSeries -{ } +public class ColumnSeries + : ColumnSeries +{ + /// + /// Initializes a new instance of the class. + /// + public ColumnSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a column series in the user interface. @@ -53,9 +80,35 @@ public class ColumnSeries : ColumnSeries /// The type of the geometry of every point of the series. /// -public class ColumnSeries : ColumnSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class ColumnSeries + : ColumnSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public ColumnSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a column series in the user interface. @@ -77,4 +130,29 @@ public class ColumnSeries : CoreColumnSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public ColumnSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ColumnSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/BaseSVGPathGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/BaseSVGPathGeometry.cs new file mode 100644 index 000000000..ac73422a0 --- /dev/null +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/BaseSVGPathGeometry.cs @@ -0,0 +1,108 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using SkiaSharp; + +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; + +/// +/// Defines a geometry that is built from a svg path. +/// +/// +/// +/// Initializes a new instance of the class. +/// +public class BaseSVGPathGeometry : SizedGeometry +{ + /// + /// Initializes a new instance of the class. + /// + public BaseSVGPathGeometry() + { } + + /// + /// Initializes a new instance of the class. + /// + /// + public BaseSVGPathGeometry(SKPath sKPath) + { + Path = sKPath; + } + + /// + /// The SVG path. + /// + public SKPath? Path { get; set; } + + /// + /// Gets or sets whether the path should fit the size of the geometry. + /// + public bool FitToSize { get; set; } = false; + + /// + public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) + { + if (Path is null) return; + + DrawPath(context, paint, Path); + } + + /// + /// Draws the given path to the canvas. + /// + /// The context. + /// The path. + /// The paint + protected void DrawPath(SkiaSharpDrawingContext context, SKPaint paint, SKPath path) + { + _ = context.Canvas.Save(); + + var canvas = context.Canvas; + _ = path.GetTightBounds(out var bounds); + + if (FitToSize) + { + // fit to both axis + canvas.Translate(X + Width / 2f, Y + Height / 2f); + canvas.Scale( + Width / (bounds.Width + paint.StrokeWidth), + Height / (bounds.Height + paint.StrokeWidth)); + canvas.Translate(-bounds.MidX, -bounds.MidY); + } + else + { + // fit to the max dimension + // preserve the corresponding scale in the min axis. + var maxB = bounds.Width < bounds.Height ? bounds.Height : bounds.Width; + + canvas.Translate(X + Width / 2f, Y + Height / 2f); + canvas.Scale( + Width / (maxB + paint.StrokeWidth), + Height / (maxB + paint.StrokeWidth)); + canvas.Translate(-bounds.MidX, -bounds.MidY); + } + + canvas.DrawPath(path, paint); + + context.Canvas.Restore(); + } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/CrossGeometry.cs similarity index 54% rename from src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs rename to src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/CrossGeometry.cs index cca9254c9..fcf0fd4ee 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/CrossGeometry.cs @@ -20,45 +20,22 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System.Collections.Generic; +using LiveChartsCore.Drawing; +using SkiaSharp; -namespace LiveChartsCore.SkiaSharpView.SKCharts.Helpers; +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; -// Maybe we should go for another alternative instead of using this class.. -internal class DoubleDict - where T1 : notnull - where T2 : notnull +/// +/// Defines a cross geometry. +/// +public class CrossGeometry : BaseSVGPathGeometry { - private readonly Dictionary _keys = []; - private readonly Dictionary _values = []; - - public void Add(T1 key, T2 value) - { - _keys.Add(key, value); - _values.Add(value, key); - } - - public bool Remove(T1 key) - { - var r2 = _values.Remove(_keys[key]); - var r1 = _keys.Remove(key); - return r1 & r2; - } - - public bool Remove(T2 value) - { - var r1 = _keys.Remove(_values[value]); - var r2 = _values.Remove(value); - return r1 & r2; - } - - public bool TryGetValue(T1 key, out T2 value) - { - return _keys.TryGetValue(key, out value!); - } - - public bool TryGetValue(T2 key, out T1 value) - { - return _values.TryGetValue(key, out value!); - } + private static readonly SKPath s_sKPath = SKPath.ParseSvgPathData(SVGPoints.Cross); + + /// + /// Initializes a new instance of the class. + /// + public CrossGeometry() + : base(s_sKPath) + { } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/DiamondGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/DiamondGeometry.cs new file mode 100644 index 000000000..40f230164 --- /dev/null +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/DiamondGeometry.cs @@ -0,0 +1,41 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using LiveChartsCore.Drawing; +using SkiaSharp; + +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; + +/// +/// Defines a diamond geometry. +/// +public class DiamondGeometry : BaseSVGPathGeometry +{ + private static readonly SKPath s_sKPath = SKPath.ParseSvgPathData(SVGPoints.Diamond); + + /// + /// Initializes a new instance of the class. + /// + public DiamondGeometry() + : base(s_sKPath) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeartGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeartGeometry.cs new file mode 100644 index 000000000..5289c1b23 --- /dev/null +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeartGeometry.cs @@ -0,0 +1,41 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using LiveChartsCore.Drawing; +using SkiaSharp; + +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; + +/// +/// Defines a heart geometry. +/// +public class HeartGeometry : BaseSVGPathGeometry +{ + private static readonly SKPath s_sKPath = SKPath.ParseSvgPathData(SVGPoints.Heart); + + /// + /// Initializes a new instance of the class. + /// + public HeartGeometry() + : base(s_sKPath) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs index 426ca77b8..0a8985b8f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs @@ -29,6 +29,9 @@ namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; +// THE PATH GEOMETRY CLASS IS OBSOLETE, BUT IT IS USED IN THE HEAT PATH SHAPE CLASS +// ToDo: Update the HeatPathShape class to use the AreaGeometry class instead of the PathGeometry class + /// /// Defines a path geometry with a specified color. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/LineGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/LineGeometry.cs index 8b045a85c..a9bf9d2a0 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/LineGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/LineGeometry.cs @@ -43,10 +43,22 @@ public LineGeometry() } /// - public float X1 { get => _x1.GetMovement(this); set => _x1.SetMovement(value, this); } + public float X1 + { + get => Parent is null + ? _x1.GetMovement(this) + : _x1.GetMovement(this) + Parent.X; + set => _x1.SetMovement(value, this); + } /// - public float Y1 { get => _y1.GetMovement(this); set => _y1.SetMovement(value, this); } + public float Y1 + { + get => Parent is null + ? _y1.GetMovement(this) + : _y1.GetMovement(this) + Parent.Y; + set => _y1.SetMovement(value, this); + } /// public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs index 7ea5ccc6e..7c43a496a 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs @@ -20,143 +20,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -// Ignore Spelling: svg - using System; -using System.Collections.Generic; -using LiveChartsCore.Drawing; -using SkiaSharp; namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; -/// -/// Defines a geometry that is buil from a svg path. -/// -/// -public class SVGPathGeometry : SizedGeometry, ISvgPath -{ - private readonly Func? _pathSource; - private string? _svgPath; - - /// - /// Inieializes a new instance of the class. - /// - public SVGPathGeometry() - { } - - /// - /// Initializes a new instance of the class. - /// - /// The SVG path. - public SVGPathGeometry(SKPath svgPath) - { - Path = svgPath; - } - - /// - /// Initializes a new instance of the class, - /// when is null, The path will be obtained from the function. - /// - /// The path source. - public SVGPathGeometry(Func pathSource) - { - _pathSource = pathSource; - } - - /// - /// Svg paths are cached in this dictionary to prevent parsing multiple times the same path, - /// when you use the class, keep in mind that the parsed paths are living in - /// memory, this has no secondary effects in most of the cases, but if you are parsing a lot of paths - /// (maybe over 500) then you must consider cleaning the cache when you no longer need a path. - /// - public static readonly Dictionary Cache = []; - - /// - /// Gets or sets the path. - /// - public SKPath? Path { get; set; } - - /// - /// Gets or sets whether the path should be fitted to the size of the geometry. - /// - public bool FitToSize { get; set; } = false; - - /// - public string? SVGPath - { - get => _svgPath; - set - { - if (value == _svgPath) return; - - _svgPath = value; - OnPathChanged(value); - } - } - - /// - public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) - { - var path = Path ?? _pathSource?.Invoke(); - if (path is null) return; - - DrawPath(context, paint, path); - } - - private void OnPathChanged(string? path) - { - if (path is null) - { - Path = null; - return; - } - - if (!Cache.TryGetValue(path, out var skPath)) - { - skPath = SKPath.ParseSvgPathData(path); - Cache[path] = skPath; - } - - Path = skPath; - } - - /// - /// Draws the given path to the canvas. - /// - /// The context. - /// The path. - /// The paint - protected void DrawPath(SkiaSharpDrawingContext context, SKPaint paint, SKPath path) - { - _ = context.Canvas.Save(); - - var canvas = context.Canvas; - _ = path.GetTightBounds(out var bounds); - - if (FitToSize) - { - // fit to both axis - canvas.Translate(X + Width / 2f, Y + Height / 2f); - canvas.Scale( - Width / (bounds.Width + paint.StrokeWidth), - Height / (bounds.Height + paint.StrokeWidth)); - canvas.Translate(-bounds.MidX, -bounds.MidY); - } - else - { - // fit to the max dimension - // preserve the corresponding scale in the min axis. - var maxB = bounds.Width < bounds.Height ? bounds.Height : bounds.Width; - - canvas.Translate(X + Width / 2f, Y + Height / 2f); - canvas.Scale( - Width / (maxB + paint.StrokeWidth), - Height / (maxB + paint.StrokeWidth)); - canvas.Translate(-bounds.MidX, -bounds.MidY); - } - - canvas.DrawPath(path, paint); - - context.Canvas.Restore(); - } -} +/// +[Obsolete($"Replaced by {nameof(VariableSVGPathGeometry)}")] +public class SVGPathGeometry : VariableSVGPathGeometry { } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/PaintTask.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/StarGeometry.cs similarity index 73% rename from src/skiasharp/LiveChartsCore.SkiaSharp/Painting/PaintTask.cs rename to src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/StarGeometry.cs index c2b80235c..5c96dbd62 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/PaintTask.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/StarGeometry.cs @@ -20,12 +20,22 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -using System; using LiveChartsCore.Drawing; +using SkiaSharp; -namespace LiveChartsCore.SkiaSharpView.Painting; +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; -/// -[Obsolete("Renamed to Paint")] -public abstract class PaintTask : Paint -{ } +/// +/// Defines a star geometry. +/// +public class StarGeometry : BaseSVGPathGeometry +{ + private static readonly SKPath s_sKPath = SKPath.ParseSvgPathData(SVGPoints.Star); + + /// + /// Initializes a new instance of the class. + /// + public StarGeometry() + : base(s_sKPath) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VariableSVGPathGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VariableSVGPathGeometry.cs new file mode 100644 index 000000000..985d4ef6a --- /dev/null +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VariableSVGPathGeometry.cs @@ -0,0 +1,77 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using LiveChartsCore.Drawing; +using SkiaSharp; + +namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; + +/// +/// Defines a geometry that is built from a svg path, the path can change at runtime, +/// this geometry has a performance penalty, use it only when you need to change the path at runtime, +/// if the geometry is static use any other geometry defined in the library, or inherit from +/// class instead, and set the path in the constructor. +/// +public class VariableSVGPathGeometry : BaseSVGPathGeometry, IVariableSvgPath +{ + private string? _svgPath; + + /// + /// Svg paths are cached in this dictionary to prevent parsing multiple times the same path, + /// when you use the class, keep in mind that the parsed paths are living in + /// memory, this has no secondary effects in most of the cases, but if you are parsing a lot of paths + /// (maybe over 500) then you must consider cleaning the cache when you no longer need a path. + /// + public static readonly Dictionary Cache = []; + + /// + public string? SVGPath + { + get => _svgPath; + set + { + if (value == _svgPath) return; + + _svgPath = value; + OnPathChanged(value); + } + } + + private void OnPathChanged(string? path) + { + if (path is null) + { + Path = null; + return; + } + + if (!Cache.TryGetValue(path, out var skPath)) + { + skPath = SKPath.ParseSvgPathData(path); + Cache[path] = skPath; + } + + Path?.Dispose(); + Path = skPath; + } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VectorGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VectorGeometry.cs index d068df74e..2a2753e49 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VectorGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/VectorGeometry.cs @@ -37,12 +37,15 @@ public abstract class VectorGeometry : Drawable, IVectorGeometry /// Initializes a new instance of the class. /// public VectorGeometry() { _pivotProperty = RegisterMotionProperty(new FloatMotionProperty(nameof(Pivot), 0f)); + _opacityProperty = RegisterMotionProperty(new FloatMotionProperty(nameof(Opacity), 1)); } /// @@ -56,6 +59,15 @@ public VectorGeometry() /// public float Pivot { get => _pivotProperty.GetMovement(this); set => _pivotProperty.SetMovement(value, this); } + /// + public IPaint? Stroke { get; set; } + + /// + public IPaint? Fill { get; set; } + + /// + public float Opacity { get => _opacityProperty.GetMovement(this); set => _opacityProperty.SetMovement(value, this); } + /// public override void CompleteTransition(params string[]? propertyName) { @@ -107,7 +119,18 @@ public override void Draw(SkiaSharpDrawingContext context) if (last is not null) OnClose(context, path, last); - context.Canvas.DrawPath(path, context.Paint); + var hasGeometryOpacity = Opacity < 1; + + if (Fill is null && Stroke is null) + { + if (hasGeometryOpacity) context.PaintTask.ApplyOpacityMask(context, this); + context.Canvas.DrawPath(path, context.Paint); + if (hasGeometryOpacity) context.PaintTask.RestoreOpacityMask(context, this); + } + else + { + throw new System.NotImplementedException($"Fill and strokes per vector is not implemented."); + } if (!isValid) IsValid = false; } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs index 2860fd626..514c65a7d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs @@ -41,7 +41,7 @@ public static class PieChartExtensions /// The type of the model. /// The data source. /// An optional builder. - /// Defines whether the series are treaded as gauge. + /// Defines whether the series are treated as gauge. /// public static ObservableCollection> AsPieSeries( this IEnumerable source, @@ -58,7 +58,7 @@ public static ObservableCollection> AsPieSeries( /// The type of the visual. /// The data source. /// An optional builder. - /// Defines whether the series are treaded as gauge. + /// Defines whether the series are treated as gauge. /// public static ObservableCollection> AsPieSeries( this IEnumerable source, @@ -77,7 +77,7 @@ public static ObservableCollection> AsPieSeriesThe type of the label. /// The data source. /// An optional builder. - /// Defines whether the series are treaded as gauge. + /// Defines whether the series are treated as gauge. /// public static ObservableCollection> AsPieSeries( this IEnumerable source, @@ -96,7 +96,7 @@ public static ObservableCollection> AsPieSeri /// The type of the series. /// The data source. /// An optional builder. - /// Defines whether the series are treaded as gauge. + /// Defines whether the series are treated as gauge. /// public static ObservableCollection AsPieSeries( this IEnumerable source, diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs deleted file mode 100644 index 2b3105bfd..000000000 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs +++ /dev/null @@ -1,520 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using LiveChartsCore.Defaults; -using LiveChartsCore.Drawing; -using LiveChartsCore.Kernel; -using LiveChartsCore.Measure; -using LiveChartsCore.SkiaSharpView.Drawing; -using LiveChartsCore.SkiaSharpView.Extensions; -using LiveChartsCore.SkiaSharpView.Painting; -using SkiaSharp; - -namespace LiveChartsCore.SkiaSharpView; - -/// -/// Defines a helper class to build gauges. -/// -[Obsolete($"Use {nameof(GaugeGenerator)}.{nameof(GaugeGenerator.BuildSolidGauge)} instead.")] -public class GaugeBuilder : IGaugeBuilder -{ - private readonly Dictionary?, IPaint?>> _keyValuePairs = []; - private readonly List?, IPaint?>> _tuples = []; - private List>? _builtSeries; - - private RadialAlignment? _radialAlign = null; - private double? _innerRadius = null; - private double? _offsetRadius = null; - private double? _backgroundInnerRadius = null; - private double? _backgroundOffsetRadius = null; - private double? _backgroundCornerRadius = null; - private double? _cornerRadius = null; - private IPaint? _background = null; - private double? _labelsSize = null; - private PolarLabelsPosition? _labelsPosition = null; - private double? _backgroundMaxRadialColumnWidth = null; - private double? _maxColumnWidth = null; - private Func _labelFormatter = point => point.Coordinate.PrimaryValue.ToString(); - - /// - /// Gets or sets the inner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The inner radius. - /// - public double? InnerRadius { get => _innerRadius; set { _innerRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the inner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - /// - public GaugeBuilder WithInnerRadius(double? value) - { - InnerRadius = value; - return this; - } - - /// - /// Gets or sets the offset radius, the separation between each gauge if multiple gauges are nested, - /// setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The value. - /// - public double? OffsetRadius { get => _offsetRadius; set { _offsetRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the offset radius, the separation between each gauge if multiple gauges are nested, - /// setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - /// - public GaugeBuilder WithOffsetRadius(double? value) - { - OffsetRadius = value; - return this; - } - - /// - /// Gets or sets the maximum width of the radial column, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The maximum width of the radial column. - /// - public double? MaxColumnWidth { get => _maxColumnWidth; set { _maxColumnWidth = value; OnPopertyChanged(); } } - - /// - /// Sets the maximum width of the radial column, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithMaxColumnWidth(double? value) - { - MaxColumnWidth = value; - return this; - } - - /// - /// Gets or sets the corner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The corner radius. - /// - public double? CornerRadius { get => _cornerRadius; set { _cornerRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the corner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithCornerRadius(double? value) - { - CornerRadius = value; - return this; - } - - /// - /// Gets or sets the radial alignment, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The inner radius. - /// - public RadialAlignment? RadialAlign { get => _radialAlign; set { _radialAlign = value; OnPopertyChanged(); } } - - /// - /// Sets the radial alignment, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithRadialAlign(RadialAlignment? value) - { - RadialAlign = value; - return this; - } - - /// - /// Gets or sets the background inner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The background inner radius. - /// - public double? BackgroundInnerRadius { get => _backgroundInnerRadius; set { _backgroundInnerRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the background inner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithBackgroundInnerRadius(double? value) - { - BackgroundInnerRadius = value; - return this; - } - - /// - /// Gets or sets the background offset radius, the separation between each gauge if multiple gauges are nested, - /// setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The background relative inner radius. - /// - public double? BackgroundOffsetRadius { get => _backgroundOffsetRadius; set { _backgroundOffsetRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the background offset radius, the separation between each gauge if multiple gauges are nested, - /// setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithBackgroundOffsetRadius(double? value) - { - BackgroundOffsetRadius = value; - return this; - } - - /// - /// Gets or sets the width of the background maximum radial column, setting this property to null will let the theme - /// decide the value, default is null. - /// - /// - /// The width of the background maximum radial column. - /// - public double? BackgroundMaxRadialColumnWidth - { - get => _backgroundMaxRadialColumnWidth; - set { _backgroundMaxRadialColumnWidth = value; OnPopertyChanged(); } - } - - /// - /// Sets the width of the background maximum radial column, setting this property to null will let the theme - /// decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithBackgroundMaxRadialColumnWidth(double? value) - { - BackgroundMaxRadialColumnWidth = value; - return this; - } - - /// - /// Gets or sets the background corner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The background corner radius. - /// - public double? BackgroundCornerRadius { get => _backgroundCornerRadius; set { _backgroundCornerRadius = value; OnPopertyChanged(); } } - - /// - /// Sets the background corner radius, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithBackgroundCornerRadius(double? value) - { - BackgroundMaxRadialColumnWidth = value; - return this; - } - - /// - /// Gets or sets the background. - /// - /// - /// The background. - /// - public IPaint? Background { get => _background; set { _background = value; OnPopertyChanged(); } } - - /// - /// Sets the background. - /// - /// the value. - public GaugeBuilder WithBackground(IPaint? value) - { - Background = value; - return this; - } - - /// - /// Gets or sets the size of the labels, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The size of the labels. - /// - public double? LabelsSize { get => _labelsSize; set { _labelsSize = value; OnPopertyChanged(); } } - - /// - /// Sets the size of the labels, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithLabelsSize(double value) - { - LabelsSize = value; - return this; - } - - /// - /// Gets or sets the labels position, setting this property to null will let the theme decide the value, default is null. - /// - /// - /// The labels position. - /// - public PolarLabelsPosition? LabelsPosition { get => _labelsPosition; set { _labelsPosition = value; OnPopertyChanged(); } } - - /// - /// Sets the labels position, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithLabelsPosition(PolarLabelsPosition value) - { - LabelsPosition = value; - return this; - } - - /// - /// Gets or sets the label formatter. - /// - /// - /// The label formatter. - /// - public Func LabelFormatter { get => _labelFormatter; set { _labelFormatter = value; OnPopertyChanged(); } } - - /// - /// Sets the labels position, setting this property to null will let the theme decide the value, default is null. - /// - /// the value. - public GaugeBuilder WithLabelFormatter(Func value) - { - LabelFormatter = value; - return this; - } - - /// - /// Adds the value. - /// - /// The value. - /// The series name. - /// The series paint. - /// The labels paint. - /// - public GaugeBuilder AddValue( - ObservableValue value, - string? seriesName, - IPaint? seriesPaint, - IPaint? labelsPaint = null) - { - _tuples.Add( - new Tuple?, IPaint?>( - value, seriesName, seriesPaint, labelsPaint)); - - return this; - } - - /// - /// Adds the value. - /// - /// The value. - /// The series name. - /// Color of the series. - /// Color of the labels. - /// - public GaugeBuilder AddValue(ObservableValue value, string seriesName, SKColor seriesColor, SKColor? labelsColor = null) - { - labelsColor ??= new SKColor(35, 35, 35); - - return AddValue(value, seriesName, new SolidColorPaint(seriesColor), new SolidColorPaint(labelsColor.Value)); - } - - /// - /// Adds the value. - /// - /// The value. - /// The series name. - /// Color of the series. - /// Color of the labels. - /// - public GaugeBuilder AddValue(double value, string seriesName, SKColor seriesColor, SKColor? labelsColor = null) - { - return AddValue(new ObservableValue(value), seriesName, seriesColor, labelsColor); - } - - /// - /// Adds the value. - /// - /// The value. - /// - public GaugeBuilder AddValue(ObservableValue value) - { - return AddValue(value, null, null, null); - } - - /// - /// Adds the value. - /// - /// The value. - /// - public GaugeBuilder AddValue(double value) - { - return AddValue(new ObservableValue(value)); - } - - /// - /// Adds the value. - /// - /// The value. - /// The series name. - /// - public GaugeBuilder AddValue(ObservableValue value, string? seriesName) - { - return AddValue(value, seriesName, null, null); - } - - /// - /// Adds the value. - /// - /// The value. - /// The series name. - /// - public GaugeBuilder AddValue(double value, string? seriesName) - { - return AddValue(new ObservableValue(value), seriesName); - } - - /// - /// Builds the series. - /// - /// - public List> BuildSeries() - { - var series = new List>(); - - var i = 0; - foreach (var item in _tuples) - { - var list = new List(); - while (list.Count < _tuples.Count - 1) - { - list.Add(new ObservableValue(null)); - } - list.Insert(i, item.Item1); - - var sf = new PieSeries(true) - { - ZIndex = i + 1, - Values = list, - Name = item.Item2, - HoverPushout = 0, - //DataLabelsPosition = PolarLabelsPosition.ChartCenter - }; - - if (item.Item3 is not null) sf.Fill = item.Item3; - if (item.Item4 is not null) sf.DataLabelsPaint = item.Item4; - if (LabelFormatter is not null) sf.DataLabelsFormatter = LabelFormatter; - - var a = sf.Stroke; - - ApplyStyles(sf); - series.Add(sf); - _keyValuePairs.Add(sf, item); - - i++; - } - - var fillSeriesValues = new List(); - while (fillSeriesValues.Count < _tuples.Count) fillSeriesValues.Add(new ObservableValue(0)); - - var s = new PieSeries(true, true) - { - ZIndex = -1, - IsFillSeries = true, - Values = fillSeriesValues - }; - ApplyStyles(s); - series.Add(s); - - _builtSeries = series; - - return series; - } - - /// - /// Applies the styles the specified series. - /// - /// The series. - /// - public void ApplyStyles(PieSeries series) - { - if (series.SeriesProperties.HasFlag(SeriesProperties.GaugeFill)) - { - ApplyStylesToFill(series); - return; - } - - ApplyStylesToSeries(series); - } - - /// - /// Applies the styles to fill series. - /// - /// The series. - /// - public void ApplyStylesToFill(PieSeries series) - { - if (Background is not null) series.Fill = Background; - if (BackgroundInnerRadius is not null) series.InnerRadius = BackgroundInnerRadius.Value; - if (BackgroundOffsetRadius is not null) - { - series.RelativeOuterRadius = BackgroundOffsetRadius.Value; - series.RelativeInnerRadius = BackgroundOffsetRadius.Value; - } - if (BackgroundMaxRadialColumnWidth is not null) series.MaxRadialColumnWidth = BackgroundMaxRadialColumnWidth.Value; - if (RadialAlign is not null) series.RadialAlign = RadialAlign.Value; - } - - /// - /// Applies the styles to series. - /// - /// The series. - /// - /// - public void ApplyStylesToSeries(PieSeries series) - { - if (_keyValuePairs.TryGetValue(series, out var t)) if (t.Item3 is not null) series.Fill = t.Item3; - if (LabelsSize is not null) series.DataLabelsSize = LabelsSize.Value; - if (LabelsPosition is not null) series.DataLabelsPosition = LabelsPosition.Value; - if (InnerRadius is not null) series.InnerRadius = InnerRadius.Value; - if (OffsetRadius is not null) - { - series.RelativeInnerRadius = OffsetRadius.Value; - series.RelativeOuterRadius = OffsetRadius.Value; - } - if (MaxColumnWidth is not null) series.MaxRadialColumnWidth = MaxColumnWidth.Value; - if (RadialAlign is not null) series.RadialAlign = RadialAlign.Value; - - series.DataLabelsFormatter = LabelFormatter; - } - - private void OnPopertyChanged() - { - if (_builtSeries is null) return; - - foreach (var item in _builtSeries) - { - ApplyStyles(item); - } - } -} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatLandSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatLandSeries.cs index 6b36910e4..c9a370f24 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatLandSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatLandSeries.cs @@ -20,24 +20,55 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Collections.Generic; using LiveChartsCore.Drawing; +using LiveChartsCore.Geo; using LiveChartsCore.SkiaSharpView.Drawing; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace LiveChartsCore.SkiaSharpView; -/// -public class HeatLandSeries : CoreHeatLandSeries +/// +public class HeatLandSeries : HeatLandSeries +{ } + +/// +public class HeatLandSeries + : CoreHeatLandSeries + where TModel : IWeigthedMapLand { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public HeatLandSeries() + : this(null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The lands. + public HeatLandSeries(ICollection? lands) + : this(lands, [LvcColor.FromArgb(255, 179, 229, 252), LvcColor.FromArgb(255, 2, 136, 209)]) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The lands. + public HeatLandSeries(params TModel[]? lands) + : this(lands, [LvcColor.FromArgb(255, 179, 229, 252), LvcColor.FromArgb(255, 2, 136, 209)]) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The lands. + /// The heat map. + public HeatLandSeries(ICollection? lands, LvcColor[] heatMap) + : base(lands) { - HeatMap = new[] - { - LvcColor.FromArgb(255, 179, 229, 252), // cold (min value) - LvcColor.FromArgb(255, 2, 136, 209) // hot (max value) - }; + HeatMap = heatMap; LiveCharts.Configure(config => config.UseDefaults()); IntitializeSeries(LiveCharts.DefaultSettings.GetProvider().GetSolidColorPaint()); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs index 9ff68a689..54acfeab8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class HeatSeries : HeatSeries -{ } +public class HeatSeries + : HeatSeries +{ + /// + /// Initializes a new instance of the class. + /// + public HeatSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a heat series in the user interface. @@ -53,9 +80,35 @@ public class HeatSeries : HeatSeries /// The type of the geometry of every point of the series. /// -public class HeatSeries : HeatSeries - where TVisual : class, ISizedGeometry, IColoredGeometry, new() -{ } +public class HeatSeries + : HeatSeries + where TVisual : class, ISizedGeometry, IColoredGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public HeatSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a heat series in the user interface. @@ -73,15 +126,33 @@ public class HeatSeries : HeatSeries /// The type of the data label of every point. /// -public class HeatSeries : CoreHeatSeries - where TVisual : class, ISizedGeometry, IColoredGeometry, new() - where TLabel : class, ILabelGeometry, new() +public class HeatSeries + : CoreHeatSeries + where TVisual : class, ISizedGeometry, IColoredGeometry, new() + where TLabel : class, ILabelGeometry, new() { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public HeatSeries() - { - LiveCharts.Configure(config => config.UseDefaults()); - } + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public HeatSeries(params TModel[] values) + : base(values) + { } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs index e74bba48e..8bbd8b2bc 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class LineSeries : LineSeries -{ } +public class LineSeries + : LineSeries +{ + /// + /// Initializes a new instance of the class. + /// + public LineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a line series in the user interface. @@ -53,9 +80,35 @@ public class LineSeries : LineSeries /// The type of the geometry of every point of the series. /// -public class LineSeries : LineSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class LineSeries + : LineSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public LineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a line series in the user interface. @@ -75,6 +128,31 @@ public class LineSeries : LineSeries public class LineSeries : CoreLineSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public LineSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public LineSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj index 43db50e1b..121f0d102 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj @@ -11,7 +11,6 @@ $(TargetFrameworks); net462; - net6.0-windows10.0.19041.0; net8.0-windows10.0.19041.0;net8.0-windows10.0.20348.0; @@ -24,7 +23,7 @@ LiveChartsCore.SkiaSharpView LiveChartsCore.SkiaSharpView - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for .Net, this package contains the SkiaSharp backend. MIT @@ -50,7 +49,7 @@ - + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs index 120cccec7..27bbc5187 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs @@ -23,15 +23,11 @@ // Ignore Spelling: Skia Lvc using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView.Drawing; -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; -using LiveChartsCore.SkiaSharpView.Extensions; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; @@ -116,21 +112,6 @@ public static LvcColor AsLvcColor(this SKColor color) return new LvcColor(color.Red, color.Green, color.Blue, color.Alpha); } - /// - /// Converts an IEnumerable to an ObservableCollection of pie series. - /// - /// The type. - /// The data source. - /// An optional builder. - /// - [Obsolete($"Renamed to {nameof(PieChartExtensions.AsPieSeries)}.")] - public static ObservableCollection> AsLiveChartsPieSeries( - this IEnumerable source, - Action>? builder = null) - { - return PieChartExtensions.AsPieSeries(source, builder); - } - /// /// Calculates the distance in pixels from the target to the given location in the UI. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs index e8c59c842..e8df58b87 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs @@ -35,10 +35,12 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// The sigma x. /// The sigma y. /// The input. -/// The crop rect. -public class Blur(float sigmaX, float sigmaY, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) : ImageFilter +public class Blur( + float sigmaX, + float sigmaY, + SKImageFilter? input = null) + : ImageFilter { - /// /// Clones this instance. /// @@ -46,7 +48,7 @@ public class Blur(float sigmaX, float sigmaY, SKImageFilter? input = null, SKIma /// public override ImageFilter Clone() { - return new Blur(sigmaX, sigmaY, input, cropRect); + return new Blur(sigmaX, sigmaY, input); } /// @@ -56,6 +58,6 @@ public override ImageFilter Clone() /// public override void CreateFilter(SkiaSharpDrawingContext drawingContext) { - SKImageFilter = SKImageFilter.CreateBlur(sigmaX, sigmaY, input, cropRect); + SKImageFilter = SKImageFilter.CreateBlur(sigmaX, sigmaY, input); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs index 5113677a0..163d7e086 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs @@ -38,8 +38,14 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// The sigma y. /// The color. /// The input. -/// The crop rect. -public class DropShadow(float dx, float dy, float sigmaX, float sigmaY, SKColor color, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) : ImageFilter +public class DropShadow( + float dx, + float dy, + float sigmaX, + float sigmaY, + SKColor color, + SKImageFilter? input = null) + : ImageFilter { /// @@ -49,7 +55,7 @@ public class DropShadow(float dx, float dy, float sigmaX, float sigmaY, SKColor /// public override ImageFilter Clone() { - return new DropShadow(dx, dy, sigmaX, sigmaY, color, input, cropRect); + return new DropShadow(dx, dy, sigmaX, sigmaY, color, input); } /// @@ -58,6 +64,6 @@ public override ImageFilter Clone() /// The drawing context. public override void CreateFilter(SkiaSharpDrawingContext drawingContext) { - SKImageFilter = SKImageFilter.CreateDropShadow(dx, dy, sigmaX, sigmaY, color, input, cropRect); + SKImageFilter = SKImageFilter.CreateDropShadow(dx, dy, sigmaX, sigmaY, color, input); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs index 08d674150..51070f888 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs @@ -33,8 +33,7 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// Initializes a new instance of the class. /// /// The image filters. -/// The crop rect. -public class ImageFiltersMergeOperation(ImageFilter[] imageFilters, SKImageFilter.CropRect? cropRect = null) : ImageFilter +public class ImageFiltersMergeOperation(ImageFilter[] imageFilters) : ImageFilter { private readonly ImageFilter[] _filters = imageFilters; @@ -45,7 +44,7 @@ public class ImageFiltersMergeOperation(ImageFilter[] imageFilters, SKImageFilte /// public override ImageFilter Clone() { - return new ImageFiltersMergeOperation(_filters, cropRect); + return new ImageFiltersMergeOperation(_filters); } /// @@ -65,7 +64,7 @@ public override void CreateFilter(SkiaSharpDrawingContext drawingContext) imageFilters[i++] = item.SKImageFilter; } - SKImageFilter = SKImageFilter.CreateMerge(imageFilters, cropRect); + SKImageFilter = SKImageFilter.CreateMerge(imageFilters); } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/SolidColorPaint.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/SolidColorPaint.cs index a2f15518d..edcdf49b3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/SolidColorPaint.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/SolidColorPaint.cs @@ -20,6 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Buffers.Text; using LiveChartsCore.Drawing; using LiveChartsCore.Motion; using LiveChartsCore.SkiaSharpView.Drawing; @@ -135,7 +136,11 @@ public override void ApplyOpacityMask(SkiaSharpDrawingContext context, IPaintabl var baseColor = context.PaintTask.Color; context.Paint.Color = - new SKColor(baseColor.Red, baseColor.Green, baseColor.Blue, (byte)(255 * geometry.Opacity)); + new SKColor( + baseColor.Red, + baseColor.Green, + baseColor.Blue, + (byte)(baseColor.Alpha * geometry.Opacity)); } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs index 7f0344628..f5ea7e656 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,20 +38,39 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class PieSeries : PieSeries +public class PieSeries + : PieSeries { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + public PieSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. /// - public PieSeries() : base(false, false) + /// The values to plot. + public PieSeries(ICollection? values) + : base(values) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class, + /// with a given collection of values. /// - /// - /// - public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, isGaugeFill) + /// The values to plot. + public PieSeries(params TModel[] values) + : base(values) + { } + + /// + /// Initializes a new instance of the class. + /// + public PieSeries(bool isGauge = false, bool isGaugeFill = false) + : base(isGauge, isGaugeFill) { } } @@ -67,21 +87,40 @@ public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, /// /// The type of the geometry of every point of the series. /// -public class PieSeries : PieSeries - where TVisual : class, IDoughnutGeometry, new() +public class PieSeries + : PieSeries + where TVisual : class, IDoughnutGeometry, new() { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + public PieSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. /// - public PieSeries() : base(false, false) + /// The values to plot. + public PieSeries(ICollection? values) + : base(values) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class, + /// with a given collection of values. /// - /// - /// - public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, isGaugeFill) + /// The values to plot. + public PieSeries(params TModel[] values) + : base(values) + { } + + /// + /// Initializes a new instance of the class. + /// + public PieSeries(bool isGauge = false, bool isGaugeFill = false) + : base(isGauge, isGaugeFill) { } } @@ -101,21 +140,40 @@ public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, /// /// The type of the data label of every point. /// -public class PieSeries : CorePieSeries - where TVisual : class, IDoughnutGeometry, new() - where TLabel : class, ILabelGeometry, new() +public class PieSeries + : CorePieSeries + where TVisual : class, IDoughnutGeometry, new() + where TLabel : class, ILabelGeometry, new() { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + public PieSeries() + : base(null, false, false) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PieSeries(ICollection? values) + : base(values, false, false) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. /// - public PieSeries() : base(false, false) + /// The values to plot. + public PieSeries(params TModel[] values) + : base(values, false, false) { } /// /// Initializes a new instance of the class. /// - /// - /// - public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, isGaugeFill) + public PieSeries(bool isGauge = false, bool isGaugeFill = false) + : base(null, isGauge, isGaugeFill) { } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs index 72db1c6bc..5554e947b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class PolarLineSeries : PolarLineSeries -{ } +public class PolarLineSeries + : PolarLineSeries +{ + /// + /// Initializes a new instance of the class. + /// + public PolarLineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a polar line series in the user interface. @@ -53,9 +80,35 @@ public class PolarLineSeries : PolarLineSeries /// The type of the geometry of every point of the series. /// -public class PolarLineSeries : PolarLineSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class PolarLineSeries + : PolarLineSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public PolarLineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a polar line series in the user interface. @@ -74,7 +127,32 @@ public class PolarLineSeries : PolarLineSeries public class PolarLineSeries - : CorePolarLineSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } + : CorePolarLineSeries + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public PolarLineSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public PolarLineSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs index 3c7fe24fe..06d34deea 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// data label of every point. -public class RowSeries : RowSeries -{ } +public class RowSeries + : RowSeries +{ + /// + /// Initializes a new instance of the class. + /// + public RowSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a row series in the user interface. @@ -53,9 +80,35 @@ public class RowSeries : RowSeries /// The type of the geometry of every point of the series. /// -public class RowSeries : RowSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class RowSeries + : RowSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public RowSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a row series in the user interface. @@ -77,4 +130,29 @@ public class RowSeries : CoreRowSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public RowSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public RowSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs index dda1cfd7a..72275edc3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs @@ -29,7 +29,6 @@ using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView.Drawing; -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.VisualElements; using SkiaSharp; @@ -49,8 +48,7 @@ public SKCartesianChart() { LiveCharts.Configure(config => config.UseDefaults()); - Core = new CartesianChart( - this, config => config.UseDefaults(), CoreCanvas, new RectangleGeometry()); + Core = new CartesianChart(this, config => config.UseDefaults(), CoreCanvas); Core.Measuring += OnCoreMeasuring; Core.UpdateStarted += OnCoreUpdateStarted; Core.UpdateFinished += OnCoreUpdateFinished; @@ -189,13 +187,6 @@ LvcColor IChartView.BackColor /// public event VisualElementsHandler? VisualElementsPointerDown; - /// - [Obsolete($"Use {nameof(ScalePixelsToData)} instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - throw new NotImplementedException(); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultLegend.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultLegend.cs index b1a0919f8..17524df10 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultLegend.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultLegend.cs @@ -143,13 +143,13 @@ private void BuildLayout(Chart chart) HorizontalAlignment = Align.Middle, Children = { - series.GetMiniaturesSketch().AsDrawnControl(s_zIndex), + series.GetMiniature(null, s_zIndex), new LabelVisual { Text = series.Name ?? string.Empty, Paint = FontPaint, TextSize = TextSize, - Padding = new Padding(8, 0, 0, 0), + Padding = new Padding(8, 2, 0, 2), MaxWidth = (float)LiveCharts.DefaultSettings.MaxTooltipsAndLegendsLabelsWidth, VerticalAlignment = Align.Start, HorizontalAlignment = Align.Start, diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultTooltip.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultTooltip.cs index 1f76de782..0d753372f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultTooltip.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKDefaultTooltip.cs @@ -163,7 +163,7 @@ public void Show(IEnumerable foundPoints, Chart foundPoints, Chart view) : this() /// public double MaxAngle { get; set; } = 360; - /// - [Obsolete($"Renamed to {nameof(MaxValue)}")] - public double? Total { get => MaxValue; set => MaxValue = value; } - /// public double? MaxValue { get; set; } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs index 4ebcf32e8..1260d5b2b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class ScatterSeries : ScatterSeries -{ } +public class ScatterSeries + : ScatterSeries +{ + /// + /// Initializes a new instance of the class. + /// + public ScatterSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a scatter series in the user interface. @@ -53,9 +80,35 @@ public class ScatterSeries : ScatterSeries /// The type of the geometry of every point of the series. /// -public class ScatterSeries : ScatterSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class ScatterSeries + : ScatterSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public ScatterSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a scatter series in the user interface. @@ -73,7 +126,33 @@ public class ScatterSeries : ScatterSeries /// The type of the data label of every point. /// -public class ScatterSeries : CoreScatterSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } +public class ScatterSeries + : CoreScatterSeries + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public ScatterSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public ScatterSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SkiaSharpProvider.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SkiaSharpProvider.cs index fa3912ad0..998d852d3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SkiaSharpProvider.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SkiaSharpProvider.cs @@ -24,7 +24,9 @@ using LiveChartsCore.Geo; using LiveChartsCore.Kernel.Providers; using LiveChartsCore.Kernel.Sketches; +using LiveChartsCore.Motion; using LiveChartsCore.SkiaSharpView.Drawing; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; @@ -35,25 +37,35 @@ public class SkiaSharpProvider : ChartEngine { /// public override IMapFactory GetDefaultMapFactory() - { - return new MapFactory(); - } + => new MapFactory(); /// public override ICartesianAxis GetDefaultCartesianAxis() - { - return new Axis(); - } + => new Axis(); /// public override IPolarAxis GetDefaultPolarAxis() - { - return new PolarAxis(); - } + => new PolarAxis(); /// public override IPaint GetSolidColorPaint(LvcColor color) + => new SolidColorPaint(new SKColor(color.R, color.G, color.B, color.A)); + + /// + public override ISizedGeometry InitializeZoommingSection(MotionCanvas canvas) { - return new SolidColorPaint(new SKColor(color.R, color.G, color.B, color.A)); + var rectangle = new RectangleGeometry(); + + var zoomingSectionPaint = new SolidColorPaint + { + IsFill = true, + Color = new SKColor(33, 150, 243, 50), + ZIndex = int.MaxValue + }; + + zoomingSectionPaint.AddGeometryToPaintTask(canvas, rectangle); + canvas.AddDrawableTask(zoomingSectionPaint); + + return rectangle; } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs index b09cacfba..119351d50 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class StackedAreaSeries : StackedAreaSeries -{ } +public class StackedAreaSeries + : StackedAreaSeries +{ + /// + /// Initializes a new instance of the class. + /// + public StackedAreaSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked area series in the user interface. @@ -53,9 +80,35 @@ public class StackedAreaSeries : StackedAreaSeries /// The type of the geometry of every point of the series. /// -public class StackedAreaSeries : StackedAreaSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class StackedAreaSeries + : StackedAreaSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedAreaSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked area series in the user interface. @@ -75,6 +128,31 @@ public class StackedAreaSeries : StackedAreaSeries public class StackedAreaSeries : CoreStackedAreaSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedAreaSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedAreaSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs index da6cd82e7..a73ed7654 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class StackedColumnSeries : StackedColumnSeries -{ } +public class StackedColumnSeries + : StackedColumnSeries +{ + /// + /// Initializes a new instance of the class. + /// + public StackedColumnSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked column series in the user interface. @@ -53,9 +80,35 @@ public class StackedColumnSeries : StackedColumnSeries /// The type of the geometry of every point of the series. /// -public class StackedColumnSeries : StackedColumnSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class StackedColumnSeries + : StackedColumnSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedColumnSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked column series in the user interface. @@ -77,4 +130,29 @@ public class StackedColumnSeries : CoreStackedColumnSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public StackedColumnSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedColumnSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs index 5d2e5f417..e62349e30 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -37,8 +38,34 @@ namespace LiveChartsCore.SkiaSharpView; /// or at the series level /// (). /// -public class StackedRowSeries : StackedRowSeries -{ } +public class StackedRowSeries + : StackedRowSeries +{ + /// + /// Initializes a new instance of the class. + /// + public StackedRowSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked row series in the user interface. @@ -53,9 +80,35 @@ public class StackedRowSeries : StackedRowSeries /// The type of the geometry of every point of the series. /// -public class StackedRowSeries : StackedRowSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class StackedRowSeries + : StackedRowSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedRowSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked row series in the user interface. @@ -77,4 +130,29 @@ public class StackedRowSeries : CoreStackedRowSeries where TVisual : class, ISizedGeometry, new() where TLabel : class, ILabelGeometry, new() -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public StackedRowSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedRowSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs index 8dac0ef75..f81b21540 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -39,7 +40,32 @@ namespace LiveChartsCore.SkiaSharpView; /// public class StackedStepAreaSeries : StackedStepAreaSeries -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public StackedStepAreaSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked area series in the user interface. @@ -56,8 +82,33 @@ public class StackedStepAreaSeries /// public class StackedStepAreaSeries : StackedStepAreaSeries - where TVisual : class, ISizedGeometry, new() -{ } + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedStepAreaSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stacked area series in the user interface. @@ -76,7 +127,32 @@ public class StackedStepAreaSeries /// The type of the data label of every point. /// public class StackedStepAreaSeries - : CoreStackedStepAreaSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } + : CoreStackedStepAreaSeries + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StackedStepAreaSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StackedStepAreaSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs index 09409ccac..b50caa9af 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs @@ -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 LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView.Drawing; @@ -38,7 +39,32 @@ namespace LiveChartsCore.SkiaSharpView; /// (). /// public class StepLineSeries : StepLineSeries -{ } +{ + /// + /// Initializes a new instance of the class. + /// + public StepLineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stepline series in the user interface. @@ -53,9 +79,35 @@ public class StepLineSeries : StepLineSeries /// The type of the geometry of every point of the series. /// -public class StepLineSeries : StepLineSeries - where TVisual : class, ISizedGeometry, new() -{ } +public class StepLineSeries + : StepLineSeries + where TVisual : class, ISizedGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StepLineSeries() + : base() + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(params TModel[] values) + : base(values) + { } +} /// /// Defines a stepline series in the user interface. @@ -74,7 +126,32 @@ public class StepLineSeries : StepLineSeries public class StepLineSeries - : CoreStepLineSeries - where TVisual : class, ISizedGeometry, new() - where TLabel : class, ILabelGeometry, new() -{ } + : CoreStepLineSeries + where TVisual : class, ISizedGeometry, new() + where TLabel : class, ILabelGeometry, new() +{ + /// + /// Initializes a new instance of the class. + /// + public StepLineSeries() + : base(null) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(ICollection? values) + : base(values) + { } + + /// + /// Initializes a new instance of the class, + /// with a given collection of values. + /// + /// The values to plot. + public StepLineSeries(params TModel[] values) + : base(values) + { } +} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/ThemesExtensions.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/ThemesExtensions.cs index d9e02dd42..4914eb668 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/ThemesExtensions.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/ThemesExtensions.cs @@ -26,8 +26,10 @@ using LiveChartsCore.Kernel.Sketches; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView.Drawing; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; using LiveChartsCore.Themes; +using LiveChartsCore.VisualElements; using SkiaSharp; namespace LiveChartsCore.SkiaSharpView; @@ -37,6 +39,9 @@ namespace LiveChartsCore.SkiaSharpView; /// public static class ThemesExtensions { + private static readonly object s_lightThemeKey = new(); + private static readonly object s_darkThemeKey = new(); + /// /// Adds the light theme. /// @@ -47,6 +52,7 @@ public static LiveChartsSettings AddLightTheme( this LiveChartsSettings settings, Action>? additionalStyles = null) { LiveCharts.HasTheme = true; + settings.CurrentThemeId = s_lightThemeKey; return settings .HasTheme((Theme theme) => @@ -71,6 +77,11 @@ public static LiveChartsSettings AddLightTheme( : new SolidColorPaint(new SKColor(235, 235, 235)); cartesian.Padding = new Padding(12); } + else if (axis is IPolarAxis polar) + { + polar.LabelsBackground = new LvcColor(255, 255, 255); + axis.SeparatorsPaint = new SolidColorPaint(new SKColor(235, 235, 235)); + } else { axis.SeparatorsPaint = new SolidColorPaint(new SKColor(235, 235, 235)); @@ -193,6 +204,19 @@ public static LiveChartsSettings AddLightTheme( .HasRuleForGaugeFillSeries(gaugeFill => { gaugeFill.Fill = new SolidColorPaint(new SKColor(30, 30, 30, 10)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(label => + { + label.Paint = new SolidColorPaint(new SKColor(30, 30, 30)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(needle => + { + needle.Fill = new SolidColorPaint(new SKColor(30, 30, 30)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(ticks => + { + ticks.Stroke = new SolidColorPaint(new SKColor(30, 30, 30)); + ticks.LabelsPaint = new SolidColorPaint(new SKColor(30, 30, 30)); }); additionalStyles?.Invoke(theme); @@ -209,6 +233,7 @@ public static LiveChartsSettings AddDarkTheme( this LiveChartsSettings settings, Action>? additionalStyles = null) { LiveCharts.HasTheme = true; + settings.CurrentThemeId = s_darkThemeKey; return settings .HasTheme((Theme theme) => @@ -217,7 +242,8 @@ public static LiveChartsSettings AddDarkTheme( .WithAnimationsSpeed(TimeSpan.FromMilliseconds(800)) .WithEasingFunction(EasingFunctions.ExponentialOut) .WithTooltipBackgroundPaint(new SolidColorPaint(new SKColor(45, 45, 45))) - .WithTooltipTextPaint(new SolidColorPaint(new SKColor(245, 245, 245))); + .WithTooltipTextPaint(new SolidColorPaint(new SKColor(245, 245, 245))) + .WithLegendTextPaint(new SolidColorPaint(new SKColor(245, 245, 245))); theme.Colors = ColorPalletes.MaterialDesign200; @@ -228,6 +254,7 @@ public static LiveChartsSettings AddDarkTheme( axis.ShowSeparatorLines = true; axis.NamePaint = new SolidColorPaint(new SKColor(235, 235, 235)); axis.LabelsPaint = new SolidColorPaint(new SKColor(200, 200, 200)); + if (axis is ICartesianAxis cartesian) { axis.SeparatorsPaint = cartesian.Orientation == AxisOrientation.X @@ -235,6 +262,11 @@ public static LiveChartsSettings AddDarkTheme( : new SolidColorPaint(new SKColor(90, 90, 90)); cartesian.Padding = new Padding(12); } + else if (axis is IPolarAxis polar) + { + polar.LabelsBackground = new LvcColor(0, 0, 0); + axis.SeparatorsPaint = new SolidColorPaint(new SKColor(90, 90, 90)); + } else { axis.SeparatorsPaint = new SolidColorPaint(new SKColor(90, 90, 90)); @@ -292,6 +324,13 @@ public static LiveChartsSettings AddDarkTheme( stackedBarSeries.Rx = 0; stackedBarSeries.Ry = 0; }) + .HasRuleForScatterSeries(scatterSeries => + { + var color = theme.GetSeriesColor(scatterSeries).AsSKColor(); + + scatterSeries.Stroke = null; + scatterSeries.Fill = new SolidColorPaint(color.WithAlpha(200)); + }) .HasRuleForPieSeries(pieSeries => { var color = theme.GetSeriesColor(pieSeries).AsSKColor(); @@ -334,7 +373,7 @@ public static LiveChartsSettings AddDarkTheme( polarLine.GeometrySize = 12; polarLine.GeometryStroke = new SolidColorPaint(color, 4); - polarLine.GeometryFill = new SolidColorPaint(new SKColor()); + polarLine.GeometryFill = new SolidColorPaint(new SKColor(30, 30, 30)); polarLine.Stroke = new SolidColorPaint(color, 4); polarLine.Fill = new SolidColorPaint(color.WithAlpha(50)); }) @@ -344,11 +383,25 @@ public static LiveChartsSettings AddDarkTheme( gaugeSeries.Stroke = null; gaugeSeries.Fill = new SolidColorPaint(color); + gaugeSeries.DataLabelsPosition = PolarLabelsPosition.ChartCenter; gaugeSeries.DataLabelsPaint = new SolidColorPaint(new SKColor(200, 200, 200)); }) .HasRuleForGaugeFillSeries(gaugeFill => { gaugeFill.Fill = new SolidColorPaint(new SKColor(255, 255, 255, 30)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(label => + { + label.Paint = new SolidColorPaint(new SKColor(200, 200, 200)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(needle => + { + needle.Fill = new SolidColorPaint(new SKColor(200, 200, 200)); + }) + .HasRuleFor, SkiaSharpDrawingContext>(ticks => + { + ticks.Stroke = new SolidColorPaint(new SKColor(200, 200, 200)); + ticks.LabelsPaint = new SolidColorPaint(new SKColor(200, 200, 200)); }); additionalStyles?.Invoke(theme); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/SVGVisual.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/SVGVisual.cs index c935b7967..f067ce47e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/SVGVisual.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/SVGVisual.cs @@ -32,7 +32,7 @@ namespace LiveChartsCore.SkiaSharpView.VisualElements; /// /// Defines a visual element in a chart that draws a svg geometry in the user interface. /// -public class SVGVisual : GeometryVisual +public class SVGVisual : GeometryVisual { private SKPath? _path; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VisualElementsExtensions.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VisualElementsExtensions.cs index 2d9d1e4a9..886d38566 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VisualElementsExtensions.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VisualElementsExtensions.cs @@ -57,7 +57,7 @@ public static RelativePanel AsDrawnC ClippingMode = Measure.ClipMode.None }; - if (g is ISvgPath svgGeometry) + if (g is IVariableSvgPath svgGeometry) { svgGeometry.SVGPath = sketch.Svg ?? throw new NullReferenceException("sketch.Svg can not be null at this point."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/CartesianChart.razor.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/CartesianChart.razor.cs index 291fdbb08..b200d3d5e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/CartesianChart.razor.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/CartesianChart.razor.cs @@ -173,15 +173,6 @@ public TooltipFindingStrategy TooltipFindingStrategy } } - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -227,18 +218,9 @@ protected override void InitializeCore() { if (motionCanvas is null) throw new Exception("MotionCanvas component was not found"); - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(motionCanvas.CanvasCore, zoomingSection); - motionCanvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - core = new CartesianChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); + if (((IChartView)this).DesignerMode) return; core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsBlazor.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsBlazor.cs deleted file mode 100644 index 199db6f6d..000000000 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsBlazor.cs +++ /dev/null @@ -1,67 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.Kernel; -using LiveChartsCore.Kernel.Drawing; -using LiveChartsCore.Kernel.Sketches; -using LiveChartsCore.SkiaSharpView.Drawing; - -namespace LiveChartsCore.SkiaSharpView.Blazor; - -/// -/// The LiveCharts-Blazor config. -/// -public static class LiveChartsBlazor -{ - /// - /// Gets the given series as miniatures paint tasks. - /// - /// - /// - public static List> GetSeriesAsMiniaturePaints(ISeries series) - { - var skSeries = (IChartSeries)series; - return skSeries.CanvasSchedule.PaintSchedules; - } - - /// - /// Gets the given series as minitaures style. - /// - /// - /// - public static string GetSeriesMiniatureStyle(ISeries series) - { - var skSeries = (IChartSeries)series; - return $"width: {skSeries.CanvasSchedule.Width}px; height: {skSeries.CanvasSchedule.Height}px"; - } - - /// - /// Gets the given series as miniatures data. - /// - /// - /// - public static Sketch GetSeriesMiniatureData(ISeries series) - { - var skSeries = (IChartSeries)series; - return skSeries.CanvasSchedule; - } -} diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj index 0d002213c..62db6c3e3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj @@ -7,7 +7,7 @@ net6.0;net8.0 enable - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for Blazor. MIT @@ -56,7 +56,7 @@ - + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/PieChart.razor.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/PieChart.razor.cs index c0c6fd8ea..6ea1a89d8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/PieChart.razor.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/PieChart.razor.cs @@ -85,11 +85,6 @@ public IEnumerable Series [Parameter] public double MaxAngle { get => _maxAngle; set { _maxAngle = value; OnPropertyChanged(); } } - /// - [Parameter] - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } - /// [Parameter] public double? MaxValue { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/CartesianChart.cs index 35b432db8..82225994a 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/CartesianChart.cs @@ -168,18 +168,9 @@ public DrawMarginFrame? DrawMarginFrame /// protected override void InitializeCore() { - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(motionCanvas.CanvasCore, zoomingSection); - motionCanvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - core = new CartesianChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); + core.Update(); } @@ -197,15 +188,6 @@ protected override void OnUnloading() _sectionsObserver = null!; } - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj index 35e7b0059..2cc3a4033 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj @@ -7,7 +7,7 @@ netstandard2.0;netstandard2.1; LiveChartsCore.SkiaSharpView.Eto LiveChartsCore.SkiaSharpView.Eto - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for Eto.Forms. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs index 16c476e8f..e05f4652d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs @@ -92,10 +92,6 @@ public IEnumerable Series /// public double MaxAngle { get => _maxAngle; set { _maxAngle = value; OnPropertyChanged(); } } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } - /// public double? MaxValue { get => _maxValue; set { _maxValue = value; OnPropertyChanged(); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/CartesianChart.xaml.cs index ff9af2d4a..a059bc732 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/CartesianChart.xaml.cs @@ -293,7 +293,7 @@ public CartesianChart() /// public static readonly BindableProperty LegendTextSizeProperty = BindableProperty.Create( - nameof(LegendTextSize), typeof(double?), typeof(CartesianChart), + nameof(LegendTextSize), typeof(object), typeof(CartesianChart), LiveCharts.DefaultSettings.LegendTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -333,7 +333,7 @@ public CartesianChart() /// public static readonly BindableProperty TooltipTextSizeProperty = BindableProperty.Create( - nameof(TooltipTextSize), typeof(double?), typeof(CartesianChart), + nameof(TooltipTextSize), typeof(object), typeof(CartesianChart), LiveCharts.DefaultSettings.TooltipTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -609,16 +609,6 @@ public ICommand? UpdateStartedCommand set => SetValue(UpdateStartedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the users taped the chart. - /// - [Obsolete($"Replaced by {nameof(PressedCommand)} and {nameof(ReleasedCommand)}")] - public ICommand? TappedCommand - { - get => (ICommand?)GetValue(ReleasedCommandProperty); - set => SetValue(ReleasedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the prressed the chart. /// @@ -646,16 +636,6 @@ public ICommand? MovedCommand set => SetValue(MovedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the pointer moves over the chart. - /// - [Obsolete($"Use {nameof(MovedCommand)} instead.")] - public ICommand? PointerMoveCommand - { - get => (ICommand?)GetValue(MovedCommandProperty); - set => SetValue(MovedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the pointer goes down on a data or data points. /// @@ -685,15 +665,6 @@ public ICommand? VisualElementsPointerDownCommand #endregion - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (_core is null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)_core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -745,18 +716,9 @@ void IChartView.InvokeOnUIThread(Action action) /// protected void InitializeCore() { - var zoomingSection = new RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas!.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - _core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); + _core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj index c0cb953d9..bf49f857d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj @@ -24,7 +24,7 @@ win-x86;win-x64;win-arm64 - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for Maui. MIT @@ -43,8 +43,8 @@ - - + + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/MotionCanvas.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/MotionCanvas.xaml.cs index 3c989d658..dc142bbb1 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/MotionCanvas.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/MotionCanvas.xaml.cs @@ -44,6 +44,7 @@ public partial class MotionCanvas : ContentView { private bool _isDrawingLoopRunning = false; private bool _isLoaded = true; + private double _density = 1; /// /// Initializes a new instance of the class. @@ -57,6 +58,9 @@ public MotionCanvas() $"SkiaElement not found. This was probably caused because the control {nameof(MotionCanvas)} template was overridden, " + $"If you override the template please add an {nameof(SKCanvasView)} to the template and name it 'skiaElement'"); + _density = DeviceDisplay.MainDisplayInfo.Density; + + DeviceDisplay.MainDisplayInfoChanged += MainDisplayInfoChanged; skiaElement.PaintSurface += OnCanvasViewPaintSurface; CanvasCore.Invalidated += OnCanvasCoreInvalidated; Unloaded += MotionCanvas_Unloaded; @@ -129,8 +133,7 @@ protected override void OnParentSet() private void OnCanvasViewPaintSurface(object? sender, SKPaintSurfaceEventArgs args) { - var scale = DeviceDisplay.MainDisplayInfo.Density; - args.Surface.Canvas.Scale((float)scale, (float)scale); + args.Surface.Canvas.Scale((float)_density, (float)_density); CanvasCore.DrawFrame(new SkiaSharpDrawingContext(CanvasCore, args.Info, args.Surface, args.Surface.Canvas)); } @@ -179,4 +182,9 @@ private void MotionCanvas_Unloaded(object? sender, EventArgs e) { _isLoaded = false; } + + private void MainDisplayInfoChanged(object? sender, EventArgs e) + { + _density = DeviceDisplay.MainDisplayInfo.Density; + } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PieChart.xaml.cs index 7f8779ea6..6bbb8a55f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PieChart.xaml.cs @@ -177,7 +177,7 @@ public PieChart() /// public static readonly BindableProperty MaxValueProperty = BindableProperty.Create( - nameof(MaxValue), typeof(double?), typeof(PieChart), null, BindingMode.Default, null, OnBindablePropertyChanged); + nameof(MaxValue), typeof(object), typeof(PieChart), null, BindingMode.Default, null, OnBindablePropertyChanged); /// /// The start property @@ -236,7 +236,7 @@ public PieChart() /// public static readonly BindableProperty LegendTextSizeProperty = BindableProperty.Create( - nameof(LegendTextSize), typeof(double?), typeof(PieChart), + nameof(LegendTextSize), typeof(object), typeof(PieChart), LiveCharts.DefaultSettings.LegendTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -268,7 +268,7 @@ public PieChart() /// public static readonly BindableProperty TooltipTextSizeProperty = BindableProperty.Create( - nameof(TooltipTextSize), typeof(double?), typeof(PieChart), + nameof(TooltipTextSize), typeof(object), typeof(PieChart), LiveCharts.DefaultSettings.TooltipTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -426,14 +426,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double? MaxValue { @@ -539,16 +531,6 @@ public ICommand? UpdateStartedCommand set => SetValue(UpdateStartedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the users taped the chart. - /// - [Obsolete($"Replaced by {nameof(PressedCommand)} and {nameof(ReleasedCommand)}")] - public ICommand? TappedCommand - { - get => (ICommand?)GetValue(ReleasedCommandProperty); - set => SetValue(ReleasedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the pressed the chart. /// @@ -576,16 +558,6 @@ public ICommand? MovedCommand set => SetValue(MovedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the pointer moves over the chart. - /// - [Obsolete($"Use {nameof(MovedCommand)} instead.")] - public ICommand? PointerMoveCommand - { - get => (ICommand?)GetValue(MovedCommandProperty); - set => SetValue(MovedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the pointer goes down on a data or data points. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PolarChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PolarChart.xaml.cs index 5413ec4bd..3ce963909 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PolarChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/PolarChart.xaml.cs @@ -268,7 +268,7 @@ public PolarChart() /// public static readonly BindableProperty LegendTextSizeProperty = BindableProperty.Create( - nameof(LegendTextSize), typeof(double?), typeof(PolarChart), + nameof(LegendTextSize), typeof(object), typeof(PolarChart), LiveCharts.DefaultSettings.LegendTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -310,7 +310,7 @@ public PolarChart() /// public static readonly BindableProperty TooltipTextSizeProperty = BindableProperty.Create( - nameof(TooltipTextSize), typeof(double?), typeof(PolarChart), + nameof(TooltipTextSize), typeof(object), typeof(PolarChart), LiveCharts.DefaultSettings.TooltipTextSize, propertyChanged: OnBindablePropertyChanged); /// @@ -579,16 +579,6 @@ public ICommand? UpdateStartedCommand set => SetValue(UpdateStartedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the users taped the chart. - /// - [Obsolete($"Replaced by {nameof(PressedCommand)} and {nameof(ReleasedCommand)}")] - public ICommand? TappedCommand - { - get => (ICommand?)GetValue(ReleasedCommandProperty); - set => SetValue(ReleasedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the pressed the chart. /// @@ -616,16 +606,6 @@ public ICommand? MovedCommand set => SetValue(MovedCommandProperty, value); } - /// - /// Gets or sets a command to execute when the pointer moves over the chart. - /// - [Obsolete($"Use {nameof(MovedCommand)} instead.")] - public ICommand? PointerMoveCommand - { - get => (ICommand?)GetValue(MovedCommandProperty); - set => SetValue(MovedCommandProperty, value); - } - /// /// Gets or sets a command to execute when the pointer goes down on a data or data points. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/CartesianChart.xaml.cs index e2cbf3060..af16cf0d0 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/CartesianChart.xaml.cs @@ -283,7 +283,7 @@ public CartesianChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(CartesianChart), + nameof(LegendTextSize), typeof(object), typeof(CartesianChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -315,7 +315,7 @@ public CartesianChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(CartesianChart), + nameof(TooltipTextSize), typeof(object), typeof(CartesianChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// @@ -688,14 +688,6 @@ public ICommand? VisualElementsPointerDownCommand #endregion - /// - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (_core == null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)_core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -749,18 +741,8 @@ private void OnLoaded(object sender, RoutedEventArgs e) if (_core is null) { - var zoomingSection = new Drawing.Geometries.RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - _core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); if (SyncContext != null) _motionCanvas.CanvasCore.Sync = SyncContext; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj index a971f01bd..fc5b0c798 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj @@ -8,6 +8,7 @@ $(TargetFrameworks); + net6.0-windows10.0.19041.0; net8.0-windows10.0.19041.0 @@ -25,7 +26,7 @@ true - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for Uno.WinUI. MIT @@ -48,22 +49,22 @@ - + - + - + - - + + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PieChart.xaml.cs index e299023c1..9ef8b3b02 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PieChart.xaml.cs @@ -157,7 +157,7 @@ public PieChart() /// public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register( - nameof(MaxValue), typeof(double?), typeof(PieChart), new PropertyMetadata(null, OnDependencyPropertyChanged)); + nameof(MaxValue), typeof(object), typeof(PieChart), new PropertyMetadata(null, OnDependencyPropertyChanged)); /// /// The start property @@ -218,7 +218,7 @@ public PieChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(PieChart), + nameof(LegendTextSize), typeof(object), typeof(PieChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -250,7 +250,7 @@ public PieChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(PieChart), + nameof(TooltipTextSize), typeof(object), typeof(PieChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// @@ -398,14 +398,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double? MaxValue { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PolarChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PolarChart.xaml.cs index fde88a405..51fca1f8e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PolarChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/PolarChart.xaml.cs @@ -259,7 +259,7 @@ public PolarChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(PolarChart), + nameof(LegendTextSize), typeof(object), typeof(PolarChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -291,7 +291,7 @@ public PolarChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(PolarChart), + nameof(TooltipTextSize), typeof(object), typeof(PolarChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/AssemblyInfo.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/AssemblyInfo.cs index 9f5a39c7a..74c554c92 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/AssemblyInfo.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/AssemblyInfo.cs @@ -21,12 +21,5 @@ // SOFTWARE. using System.Runtime.CompilerServices; -#if !DEBUG -using System.Reflection; -[assembly: AssemblyKeyFile("./../../../LiveCharts.snk")] -[assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d53791eaa0d98b405ca858f39169be6af36ceb7a1bca3ca76c6905fd22fddf8c5e4ef2778a5d7a77ad12f08da711fecfc44795c7923739a2acac946b3f1719a6dfc238695bc69cf5d959b3fb6bc4d18d57a97ff8ed897e6b22a6b8155401ee368d77431e74178104b4adca73520b058b9be28d4ec129beb54871778167afa5ce")] -#else [assembly: InternalsVisibleTo("LiveChartsCore.BackersPackage")] -#endif - diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/CartesianChart.xaml.cs index a7d6165c8..a233074a4 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/CartesianChart.xaml.cs @@ -278,7 +278,7 @@ public CartesianChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(CartesianChart), + nameof(LegendTextSize), typeof(object), typeof(CartesianChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -310,7 +310,7 @@ public CartesianChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(CartesianChart), + nameof(TooltipTextSize), typeof(object), typeof(CartesianChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// @@ -677,15 +677,6 @@ public ICommand? VisualElementsPointerDownCommand #endregion - /// - [Obsolete("Use the ScalePixelsToData method instead.")] - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - if (_core == null) throw new Exception("core not found"); - var cartesianCore = (CartesianChart)_core; - return cartesianCore.ScaleUIPoint(point, xAxisIndex, yAxisIndex); - } - /// public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) { @@ -741,18 +732,8 @@ private void OnLoaded(object sender, RoutedEventArgs e) if (_core is null) { - var zoomingSection = new Drawing.Geometries.RectangleGeometry(); - var zoomingSectionPaint = new SolidColorPaint - { - IsFill = true, - Color = new SkiaSharp.SKColor(33, 150, 243, 50), - ZIndex = int.MaxValue - }; - zoomingSectionPaint.AddGeometryToPaintTask(canvas.CanvasCore, zoomingSection); - canvas.CanvasCore.AddDrawableTask(zoomingSectionPaint); - _core = new CartesianChart( - this, config => config.UseDefaults(), canvas.CanvasCore, zoomingSection); + this, config => config.UseDefaults(), canvas.CanvasCore); if (SyncContext != null) _canvas.CanvasCore.Sync = SyncContext; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj index 14515f3a9..fb44e3880 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj @@ -5,17 +5,17 @@ net6.0-windows10.0.19041.0; - net8.0-windows10.0.19041.0;net8.0-windows10.0.20348.0; + net8.0-windows10.0.19041.0; 10.0.17763.0 true - win-x86;win-x64;win-arm64 + win-x86;win-x64;win-arm64 true - + LiveChartsCore.SkiaSharpView.WinUI - 2.0.0-rc3.3 + 2.0.0-rc4 icon.png Simple, flexible, interactive and powerful data visualization for WindowsAppSDK. MIT @@ -48,9 +48,9 @@ - - - + + + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PieChart.xaml.cs index ed873aefb..a6d02ac47 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PieChart.xaml.cs @@ -155,7 +155,7 @@ public PieChart() /// public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register( - nameof(MaxValue), typeof(double?), typeof(PieChart), new PropertyMetadata(null, OnDependencyPropertyChanged)); + nameof(MaxValue), typeof(object), typeof(PieChart), new PropertyMetadata(null, OnDependencyPropertyChanged)); /// /// The start property @@ -216,7 +216,7 @@ public PieChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(PieChart), + nameof(LegendTextSize), typeof(object), typeof(PieChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -248,7 +248,7 @@ public PieChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(PieChart), + nameof(TooltipTextSize), typeof(object), typeof(PieChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// @@ -396,14 +396,6 @@ public double MaxAngle set => SetValue(MaxAngleProperty, value); } - /// - [Obsolete($"Use {nameof(MaxValue)} instead.")] - public double? Total - { - get => (double?)GetValue(MaxValueProperty); - set => SetValue(MaxValueProperty, value); - } - /// public double? MaxValue { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PolarChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PolarChart.xaml.cs index 77681b194..80e3a986c 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PolarChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/PolarChart.xaml.cs @@ -251,7 +251,7 @@ public PolarChart() /// public static readonly DependencyProperty LegendTextSizeProperty = DependencyProperty.Register( - nameof(LegendTextSize), typeof(double?), typeof(PolarChart), + nameof(LegendTextSize), typeof(object), typeof(PolarChart), new PropertyMetadata(LiveCharts.DefaultSettings.LegendTextSize, OnDependencyPropertyChanged)); /// @@ -283,7 +283,7 @@ public PolarChart() /// public static readonly DependencyProperty TooltipTextSizeProperty = DependencyProperty.Register( - nameof(TooltipTextSize), typeof(double?), typeof(PolarChart), + nameof(TooltipTextSize), typeof(object), typeof(PolarChart), new PropertyMetadata(LiveCharts.DefaultSettings.TooltipTextSize, OnDependencyPropertyChanged)); /// diff --git a/tests/LiveChartsCore.UnitTesting/ChartTests/ChartTests.cs b/tests/LiveChartsCore.UnitTesting/ChartTests/ChartTests.cs index d7e7795a6..df42af977 100644 --- a/tests/LiveChartsCore.UnitTesting/ChartTests/ChartTests.cs +++ b/tests/LiveChartsCore.UnitTesting/ChartTests/ChartTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.SkiaSharpView.SKCharts; +using LiveChartsCore.SkiaSharpView.SKCharts; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace LiveChartsCore.UnitTesting.ChartTests; diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ActionThrottler.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ActionThrottler.cs index 63f58c305..a2881afc3 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ActionThrottler.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ActionThrottler.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Threading; using System.Threading.Tasks; using LiveChartsCore.Kernel; diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ChangingPaintTasks.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ChangingPaintTasks.cs index 2af13ef28..5845363f2 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ChangingPaintTasks.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ChangingPaintTasks.cs @@ -1,31 +1,10 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - +using System; using System.Collections.Generic; -using LiveChartsCore.Kernel; +using System.Threading.Tasks; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing; using LiveChartsCore.SkiaSharpView.Painting; -using LiveChartsCore.UnitTesting.MockedObjects; +using LiveChartsCore.SkiaSharpView.SKCharts; using Microsoft.VisualStudio.TestTools.UnitTesting; using SkiaSharp; @@ -34,6 +13,44 @@ namespace LiveChartsCore.UnitTesting.CoreObjectsTests; [TestClass] public class ChangingPaintTasks { + [TestMethod] + public async Task EnsureChartIsMeasured() + { + var chart = new SKCartesianChart + { + Series = [new LineSeries([1, 2, 3])] + }; + + var measureCount = 0; + chart.Measuring += c => measureCount++; + + var frames = DrawChart(chart, false); + + await Task.Delay(1000); + + Assert.IsTrue(measureCount == 1 && frames == 1); + } + + [TestMethod] + public async Task EnsureChartIsAnimated() + { + var chart = new SKCartesianChart + { + AnimationsSpeed = TimeSpan.FromSeconds(1), + EasingFunction = EasingFunctions.Lineal, + Series = [new LineSeries([1, 2, 3])] + }; + + var measureCount = 0; + chart.Measuring += c => measureCount++; + + var frames = DrawChart(chart, true); + + await Task.Delay(1000); + + Assert.IsTrue(measureCount == 1 && frames > 1); + } + [TestMethod] public void DrawableSeriesFillChanged() { @@ -42,7 +59,7 @@ public void DrawableSeriesFillChanged() Values = new List { 1, 6, 4, 2 } }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { series }, XAxes = new[] { new Axis() }, @@ -51,19 +68,7 @@ public void DrawableSeriesFillChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); @@ -71,8 +76,7 @@ void DrawChart() // on changing the fill task, the previous instance should be removed. series.Fill = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -87,7 +91,7 @@ public void DrawableSeriesStrokeChanged() Values = new List { 1, 6, 4, 2 } }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { series }, XAxes = new[] { new Axis() }, @@ -96,27 +100,14 @@ public void DrawableSeriesStrokeChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); series.Stroke = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -131,7 +122,7 @@ public void LineSeriesGeometryPaintsChanged() Values = new List { 1, 6, 4, 2 } }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { series }, XAxes = new[] { new Axis() }, @@ -140,19 +131,7 @@ public void LineSeriesGeometryPaintsChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); @@ -160,8 +139,7 @@ void DrawChart() series.GeometryFill = new SolidColorPaint(); series.GeometryStroke = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -175,7 +153,7 @@ public void SeriesRemoved() var seriesCollection = new List { series }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = seriesCollection, XAxes = new[] { new Axis() }, @@ -184,30 +162,16 @@ public void SeriesRemoved() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); seriesCollection.Add(new LineSeries { Values = new List { 1, 6, 4, 2 } }); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); seriesCollection.RemoveAt(0); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -221,7 +185,7 @@ public void SeriesCollectionInstanceChanged() var seriesCollection = new List { series }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = seriesCollection, XAxes = new[] { new Axis() }, @@ -230,30 +194,17 @@ public void SeriesCollectionInstanceChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); chart.Series = new List - { - new LineSeries { Values = new List { 1, 6, 4, 2 } } - }; + { + new LineSeries { Values = new List { 1, 6, 4, 2 } } + }; - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -265,7 +216,7 @@ public void AxisTextBrushChanged() { var axis = new Axis(); - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { @@ -277,27 +228,14 @@ public void AxisTextBrushChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); axis.LabelsPaint = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -309,7 +247,7 @@ public void AxisSeparatorBrushChanged() { var axis = new Axis(); - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { @@ -321,27 +259,14 @@ public void AxisSeparatorBrushChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); axis.SeparatorsPaint = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -351,7 +276,7 @@ void DrawChart() [TestMethod] public void AxisCollectionInstanceChanged() { - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { @@ -363,27 +288,14 @@ public void AxisCollectionInstanceChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); chart.XAxes = new[] { new Axis() }; - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -398,7 +310,7 @@ public void SectionBrushChanged() Fill = new SolidColorPaint() }; - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { @@ -411,27 +323,14 @@ public void SectionBrushChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); section.Fill = new SolidColorPaint(); - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && @@ -441,7 +340,7 @@ void DrawChart() [TestMethod] public void SectionsInstanceChanged() { - var chart = new TestCartesianChartView + var chart = new SKCartesianChart { Series = new List { @@ -454,30 +353,43 @@ public void SectionsInstanceChanged() var canvas = chart.CoreCanvas; - void DrawChart() - { - while (!canvas.IsValid) - canvas.DrawFrame( - new SkiaSharpDrawingContext( - canvas, - new SKImageInfo(100, 100), - SKSurface.CreateNull(100, 100), - new SKCanvas(new SKBitmap()))); - } - - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); var drawables = canvas.DrawablesCount; var geometries = canvas.CountGeometries(); chart.Sections = new[] { new RectangularSection() }; - chart.Core.Update(new ChartUpdateParams { Throttling = false }); - DrawChart(); + _ = DrawChart(chart); Assert.IsTrue( drawables == canvas.DrawablesCount && geometries == canvas.CountGeometries()); } + + public static int DrawChart(InMemorySkiaSharpChart chart, bool animated = false) + { + var coreChart = (Chart)chart.CoreChart; + + coreChart.IsLoaded = true; + coreChart._isFirstDraw = true; + coreChart.Measure(); + + var canvas = chart.CoreCanvas; + canvas.DisableAnimations = !animated; + var frames = 0; + + while (!canvas.IsValid) + { + frames++; + canvas.DrawFrame( + new SkiaSharpDrawingContext( + canvas, + new SKImageInfo(100, 100), + SKSurface.CreateNull(100, 100), + new SKCanvas(new SKBitmap()))); + } + + return frames; + } } diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/CollectionDeepObservererTesting.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/CollectionDeepObservererTesting.cs index 528e7e802..01455f858 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/CollectionDeepObservererTesting.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/CollectionDeepObservererTesting.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; using LiveChartsCore.UnitTesting.MockedObjects; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ColorTesting.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ColorTesting.cs index 8296e5030..121b04fd3 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ColorTesting.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/ColorTesting.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.Drawing; +using LiveChartsCore.Drawing; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace LiveChartsCore.UnitTesting.CoreObjectsTests; diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/LabelerTesting.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/LabelerTesting.cs index f9c668303..cfb541f0e 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/LabelerTesting.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/LabelerTesting.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Globalization; +using System.Globalization; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace LiveChartsCore.UnitTesting.CoreObjectsTests; diff --git a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/TransitionsTesting.cs b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/TransitionsTesting.cs index 577579ad4..6fad9f059 100644 --- a/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/TransitionsTesting.cs +++ b/tests/LiveChartsCore.UnitTesting/CoreObjectsTests/TransitionsTesting.cs @@ -1,25 +1,3 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - using System; using LiveChartsCore.Drawing; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; diff --git a/tests/LiveChartsCore.UnitTesting/LayoutTests/RelativePanelTest.cs b/tests/LiveChartsCore.UnitTesting/LayoutTests/RelativePanelTest.cs index db11f1068..2cf344454 100644 --- a/tests/LiveChartsCore.UnitTesting/LayoutTests/RelativePanelTest.cs +++ b/tests/LiveChartsCore.UnitTesting/LayoutTests/RelativePanelTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; diff --git a/tests/LiveChartsCore.UnitTesting/LayoutTests/StackPanelTest.cs b/tests/LiveChartsCore.UnitTesting/LayoutTests/StackPanelTest.cs index 8c294888e..39df87030 100644 --- a/tests/LiveChartsCore.UnitTesting/LayoutTests/StackPanelTest.cs +++ b/tests/LiveChartsCore.UnitTesting/LayoutTests/StackPanelTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; diff --git a/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs b/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs index 9ae7f4a45..252a888b2 100644 --- a/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs +++ b/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Drawing; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; using LiveChartsCore.SkiaSharpView.Painting; diff --git a/tests/LiveChartsCore.UnitTesting/MockedObjects/PropertyChangedObject.cs b/tests/LiveChartsCore.UnitTesting/MockedObjects/PropertyChangedObject.cs index 7e1291562..9e378e799 100644 --- a/tests/LiveChartsCore.UnitTesting/MockedObjects/PropertyChangedObject.cs +++ b/tests/LiveChartsCore.UnitTesting/MockedObjects/PropertyChangedObject.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.ComponentModel; +using System.ComponentModel; namespace LiveChartsCore.UnitTesting.MockedObjects; diff --git a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs deleted file mode 100644 index c66b9a7e2..000000000 --- a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs +++ /dev/null @@ -1,172 +0,0 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using LiveChartsCore.Drawing; -using LiveChartsCore.Kernel; -using LiveChartsCore.Kernel.Events; -using LiveChartsCore.Kernel.Sketches; -using LiveChartsCore.Measure; -using LiveChartsCore.Motion; -using LiveChartsCore.SkiaSharpView; -using LiveChartsCore.SkiaSharpView.Drawing; -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; -using LiveChartsCore.SkiaSharpView.SKCharts; -using LiveChartsCore.VisualElements; - -namespace LiveChartsCore.UnitTesting.MockedObjects; - -[Obsolete($"We now support in-memory charts, please use {nameof(SKCartesianChart)} instead.")] -public class TestCartesianChartView : ICartesianChartView -{ - public TestCartesianChartView() - { - LiveCharts.Configure(config => config.UseDefaults()); - - Core = new CartesianChart( - this, config => config.UseDefaults(), CoreCanvas, new RectangleGeometry()); - } - - public bool DesignerMode => false; - - public bool IsInVisualTree => true; - - IChart IChartView.CoreChart => Core; - - public CartesianChart Core { get; } - - public IEnumerable XAxes { get; set; } - - public IEnumerable YAxes { get; set; } - - public IEnumerable Series { get; set; } - - public ZoomAndPanMode ZoomMode { get; set; } - - public double ZoomingSpeed { get; set; } - - public MotionCanvas CoreCanvas { get; } = new(); - - public IChartLegend Legend => null; - - public IChartTooltip Tooltip => null; - - public LvcSize ControlSize => new(100, 100); - - public Margin DrawMargin { get; set; } - - public TimeSpan AnimationsSpeed { get; set; } = TimeSpan.FromMilliseconds(1); - - public Func EasingFunction { get; set; } = EasingFunctions.Lineal; - - public LegendPosition LegendPosition { get; set; } - - public LegendOrientation LegendOrientation { get; set; } - - public TooltipPosition TooltipPosition { get; set; } - - public TooltipFindingStrategy TooltipFindingStrategy { get; set; } - - public LvcColor BackColor { get; set; } - public bool AutoUpdateEnabled { get; set; } = true; - public TimeSpan UpdaterThrottler { get; set; } - public DrawMarginFrame DrawMarginFrame { get; set; } - public IEnumerable> Sections { get; set; } - public object SyncContext { get; set; } - public IEnumerable> VisualElements { get; set; } - public VisualElement Title { get; set; } - public IPaint LegendTextPaint { get; set; } - public IPaint LegendBackgroundPaint { get; set; } - public double? LegendTextSize { get; set; } - public IPaint TooltipTextPaint { get; set; } - public IPaint TooltipBackgroundPaint { get; set; } - public double? TooltipTextSize { get; set; } - IChartLegend IChartView.Legend { get; set; } - IChartTooltip IChartView.Tooltip { get; set; } - - public event ChartEventHandler Measuring; - public event ChartEventHandler UpdateStarted; - public event ChartEventHandler UpdateFinished; - public event ChartPointsHandler DataPointerDown; - public event ChartPointHandler ChartPointPointerDown; - public event VisualElementsHandler VisualElementsPointerDown; - - public void DummyRaiseEvents() - { - Measuring?.Invoke(this); - UpdateStarted?.Invoke(this); - UpdateFinished?.Invoke(this); - } - - public double[] ScaleUIPoint(LvcPoint point, int xAxisIndex = 0, int yAxisIndex = 0) - { - return new double[2]; - } - - public void SetTooltipStyle(LvcColor background, LvcColor textColor) { } - - public void InvokeOnUIThread(Action action) - { - action(); - } - - public void SyncAction(Action action) - { - action(); - } - - public void OnDataPointerDown(IEnumerable points, LvcPoint ponter) - { - throw new NotImplementedException(); - } - - public void Invalidate() - { - throw new NotImplementedException(); - } - - public void OnVisualElementPointerDown(IEnumerable> visualElements, LvcPoint pointer) - { - throw new NotImplementedException(); - } - - public LvcPointD ScalePixelsToData(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) - { - throw new NotImplementedException(); - } - - public LvcPointD ScaleDataToPixels(LvcPointD point, int xAxisIndex = 0, int yAxisIndex = 0) - { - throw new NotImplementedException(); - } - - public IEnumerable GetPointsAt(LvcPoint point, TooltipFindingStrategy strategy = TooltipFindingStrategy.Automatic) - { - throw new NotImplementedException(); - } - - public IEnumerable> GetVisualsAt(LvcPoint point) - { - throw new NotImplementedException(); - } -} diff --git a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestLabel.cs b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestLabel.cs index f690b78c5..2004e4924 100644 --- a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestLabel.cs +++ b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestLabel.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; +using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace LiveChartsCore.UnitTesting.MockedObjects; diff --git a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestObserver.cs b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestObserver.cs index e3f5c7b7c..9c4ff4f7a 100644 --- a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestObserver.cs +++ b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestObserver.cs @@ -1,29 +1,6 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Collections.Generic; using LiveChartsCore.Kernel; -using LiveChartsCore.SkiaSharpView.Drawing.Geometries; namespace LiveChartsCore.UnitTesting.MockedObjects; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/AxisTesting.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/AxisTesting.cs index a80276547..ec37338a7 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/AxisTesting.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/AxisTesting.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Painting; @@ -29,6 +7,7 @@ using SkiaSharp; using LiveChartsCore.Defaults; using System.Diagnostics; +using LiveChartsCore.UnitTesting.CoreObjectsTests; namespace LiveChartsCore.UnitTesting.OtherTests; @@ -180,4 +159,41 @@ public void DoublePrecisionPossibleError() _ = chart.GetImage(); Assert.IsTrue(sw.ElapsedMilliseconds < 1000); } + + [TestMethod] + public void InvertedAxis() + { + var x1 = new Axis { MaxLimit = 10, MinLimit = 0 }; + var y1 = new Axis { MaxLimit = 10, MinLimit = 0 }; + var chart1 = new SKCartesianChart + { + Width = 1000, + Height = 1000, + Series = [new LineSeries([1, 2, 3])], + XAxes = [x1], + YAxes = [y1] + }; + + var x2 = new Axis { MinLimit = 0, MaxLimit = 10, IsInverted = true }; + var y2 = new Axis { MinLimit = 0, MaxLimit = 10, IsInverted = true }; + var chart2 = new SKCartesianChart + { + Width = 1000, + Height = 1000, + Series = [new LineSeries([1, 2, 3])], + XAxes = [x2], + YAxes = [y2] + }; + + _ = ChangingPaintTasks.DrawChart(chart1); + _ = ChangingPaintTasks.DrawChart(chart2); + + Assert.IsTrue(x1._size.Width > 0 && x2._size.Height > 0); + Assert.IsTrue(x1._size == x2._size); + Assert.IsTrue(x1.activeSeparators.Count == x2.activeSeparators.Count); + + Assert.IsTrue(y1._size.Width > 0 && y2._size.Height > 0); + Assert.IsTrue(y1._size == y2._size); + Assert.IsTrue(y1.activeSeparators.Count == y2.activeSeparators.Count); + } } diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs index bd31d06ba..a779feb50 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Kernel; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/DrawMarginAndLegendsTests.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/DrawMarginAndLegendsTests.cs index dc3d00ac3..023c63536 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/DrawMarginAndLegendsTests.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/DrawMarginAndLegendsTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/EventsTests.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/EventsTests.cs index 9accb7fe5..d40760742 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/EventsTests.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/EventsTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Linq; +using System.Linq; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs index d75bb5f33..103cbabf5 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Collections.Generic; using System.Linq; using LiveChartsCore.Kernel; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/ScaleFunctionsTests.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/ScaleFunctionsTests.cs index 6446009f4..74d851433 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/ScaleFunctionsTests.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/ScaleFunctionsTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/VisualElementsTests.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/VisualElementsTests.cs index fcebc9ab7..14c183768 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/VisualElementsTests.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/VisualElementsTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; +using System.Collections.Generic; using LiveChartsCore.SkiaSharpView.Painting; using LiveChartsCore.SkiaSharpView.Drawing; using LiveChartsCore.SkiaSharpView.Drawing.Geometries; @@ -60,7 +38,7 @@ public void Dispose() { Width = 1000, Height = 1000, - Total = 100 + MaxValue = 100 }; void Draw() diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs index bf10792ae..65ab1af91 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs index 046afd303..940051663 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs index a83c6f419..163d7abd1 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Kernel; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs index 91bb18ccb..0b04dee4d 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs index 255255317..5a8171736 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Collections.ObjectModel; using System.Linq; using LiveChartsCore.Defaults; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs index 6e50c3bc7..8408c24a1 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/PieSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/PieSeriesTest.cs index b77e9089f..def2b0693 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/PieSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/PieSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/PolarLineSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/PolarLineSeriesTest.cs index bc0484af1..e91d193a3 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/PolarLineSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/PolarLineSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; @@ -83,7 +61,7 @@ public void ShouldScaleProperly() foreach (var sutPoint in toCompareGuys) { var sutHyp = Math.Sqrt(Math.Pow(sutPoint.Visual.X - 150, 2) + Math.Pow(sutPoint.Visual.Y - 150, 2)); - Assert.IsTrue(Math.Abs(uHyp * (1 + sutPoint.Context.Index) - sutHyp) < 0.0001); + Assert.IsTrue(Math.Abs(uHyp * (1 + sutPoint.Index) - sutHyp) < 0.0001); } } diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/RowSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/RowSeriesTest.cs index 15c8a4009..d1fc9f826 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/RowSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/RowSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.SKCharts; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs index 334a660d1..2a600f976 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs index 0917f00ed..c139da683 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs index 97c742ce3..1c6d9d786 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedRowSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedRowSeriesTest.cs index 8b2da3649..cdd4ea46b 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedRowSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedRowSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.SKCharts; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs index 6a009ace0..c7e8bca88 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs index b19f7da9a..ea57d95f3 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs @@ -1,26 +1,4 @@ -// The MIT License(MIT) -// -// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; +using System; using System.Linq; using LiveChartsCore.Drawing; using LiveChartsCore.Measure; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/_MemoryTests.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/_MemoryTests.cs new file mode 100644 index 000000000..09d312294 --- /dev/null +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/_MemoryTests.cs @@ -0,0 +1,412 @@ +using System; +using System.Collections; +using System.Collections.ObjectModel; +using LiveChartsCore.Defaults; +using LiveChartsCore.SkiaSharpView; +using LiveChartsCore.SkiaSharpView.SKCharts; +using LiveChartsCore.UnitTesting.CoreObjectsTests; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace LiveChartsCore.UnitTesting.SeriesTests; + +[TestClass] +public class _MemoryTests +{ + [TestMethod] + public void ObservableValuesChangingTest() + { + // here series.values is of type ObservableCollection + // we add, remove, clear, and change the visibility of the series multiple times + // the memory and geometries count should not increase significantly. + + TestObservablesChanging(new CartesianSut(new BoxSeries(), "box")); + TestObservablesChanging(new CartesianSut(new ColumnSeries(), "colum")); + TestObservablesChanging(new CartesianSut(new CandlesticksSeries(), "candle")); + TestObservablesChanging(new CartesianSut(new HeatSeries(), "heat")); + TestObservablesChanging(new CartesianSut(new LineSeries(), "line")); + TestObservablesChanging(new CartesianSut(new RowSeries(), "row")); + TestObservablesChanging(new CartesianSut(new ScatterSeries(), "scatter")); + TestObservablesChanging(new CartesianSut(new StepLineSeries(), "step line")); + TestObservablesChanging(new PieSut(new PieSeries(), "pie")); + TestObservablesChanging(new PolarSut(new PolarLineSeries(), "polar")); + + // stacked series are irrelevant for this test because they inherit from some type above. + } + + [TestMethod] + public void PrimitiveValuesInstanceChangedTest() + { + // here series.values is of type int[] + // we change the instance of the values array multiple times + // the memory and geometries count should not increase significantly. + + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new BoxSeries(), "box")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new ColumnSeries(), "colum")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new CandlesticksSeries(), "candle")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new HeatSeries(), "heat")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new LineSeries(), "line")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new RowSeries(), "row")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new ScatterSeries(), "scatter")); + TestValuesInstanceChangedPrimitiveMapped(new CartesianSutInt(new StepLineSeries(), "step line")); + TestValuesInstanceChangedPrimitiveMapped(new PieSutInt(new PieSeries(), "pie")); + TestValuesInstanceChangedPrimitiveMapped(new PolarSutInt(new PolarLineSeries(), "polar")); + + // stacked series are irrelevant for this test because they inherit from some type above. + } + + [TestMethod] + public void ObservableValuesInstanceChangedTest() + { + // here series.values is of type ObservableCollection + // we change the instance of the values array multiple times + // the memory and geometries count should not increase significantly. + + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new BoxSeries(), "box")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new ColumnSeries(), "colum")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new CandlesticksSeries(), "candle")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new HeatSeries(), "heat")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new LineSeries(), "line")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new RowSeries(), "row")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new ScatterSeries(), "scatter")); + TestValuesInstanceChangedObservableIChartEntities(new CartesianSut(new StepLineSeries(), "step line")); + TestValuesInstanceChangedObservableIChartEntities(new PieSut(new PieSeries(), "pie")); + TestValuesInstanceChangedObservableIChartEntities(new PolarSut(new PolarLineSeries(), "polar")); + + // stacked series are irrelevant for this test because they inherit from some type above. + } + + private static void TestObservablesChanging(ChartSut sut) + where T : IList + { + // this test replaces the values of the series with a new collection of 5,000 elements + // values is of type ObservableCollection + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + var initialMemory = GC.GetTotalMemory(true); + + _ = ChangingPaintTasks.DrawChart(sut.Chart, true); + + var canvas = sut.Chart.CoreCanvas; + var geometries = canvas.CountGeometries(); + var deltas = 0; + var totalFramesDrawn = 0; + + for (var i = 0; i < 100; i++) + { + sut.Series.IsVisible = false; + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + sut.Series.IsVisible = true; + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + for (var j = 0; j < 5000; j++) + _ = sut.Values.Add(new ObservableValue(2)); + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + sut.Values.RemoveAt(0); + sut.Values.RemoveAt(0); + sut.Values.RemoveAt(0); + sut.Values.RemoveAt(0); + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + sut.Values.Clear(); + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + var newCount = canvas.CountGeometries(); + if (newCount > geometries) + { + deltas++; + geometries = newCount; + } + } + + Assert.IsTrue(deltas <= 1); + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + // Assert that there is no significant increase in memory usage + var finalMemory = GC.GetTotalMemory(true); + + // 2MB is a reasonable threshold for this test + // it adds 5,000 points 100 times, which is 500,000 points + // removes 4 points 100 times, which is 400 points + // clears the collection and changes visibility 100 times + + // this test also simulates the chart animation, it makes a change, + // then enters a loop until animations finish. + + Assert.IsTrue( + finalMemory - initialMemory < 2 * 1024 * 1024, + $"[{sut.Series.Name} series] Potential memory leak detected {(finalMemory - initialMemory) / (1024d * 1024):N2}MB, " + + $"{totalFramesDrawn} frames drawn."); + } + + private void TestValuesInstanceChangedPrimitiveMapped(ChartSut sut) + where T : IEnumerable + { + // this test replaces the values of the series with a new array of 5,000 elements + // values is of type int[] + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + var initialMemory = 0L; + + _ = ChangingPaintTasks.DrawChart(sut.Chart, true); + + var canvas = sut.Chart.CoreCanvas; + var geometries = canvas.CountGeometries(); + var deltas = 0; + var totalFramesDrawn = 0; + + int[] values; + + for (var i = 0; i < 100; i++) + { + values = new int[5000]; + for (var j = 0; j < 5000; j++) + values[j] = 2; + + sut.Series.Values = values; + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + // we wait for the first frame to be drawn to measure the initial memory + // not sure why, but the first draw consumes about 12mb in this case + // but no matter the number or runs, it stays at those 12 mb all the time. + // so if we ignore the first call, we satisfy the 2mb threashold. + // in this test, it only happens in the HeatSeries. + if (i == 0) initialMemory = GC.GetTotalMemory(true); + + var newCount = canvas.CountGeometries(); + if (newCount > geometries) + { + deltas++; + geometries = newCount; + } + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + } + + sut.Series.Values = Array.Empty(); + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + values = null; + + Assert.IsTrue(deltas <= 1); + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + // Assert that there is no significant increase in memory usage + var finalMemory = GC.GetTotalMemory(true); + + // 2MB is a reasonable threshold for this test + // it changes 100 times, the instance of the values array to a new array of 5,000 elements + + Assert.IsTrue( + finalMemory - initialMemory < 2 * 1024 * 1024, + $"[{sut.Series.Name} series] Potential memory leak detected {(finalMemory - initialMemory) / (1024d * 1024):N2}MB, " + + $"{totalFramesDrawn} frames drawn."); + } + + private void TestValuesInstanceChangedObservableIChartEntities(ChartSut sut) + where T : IEnumerable + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + var initialMemory = 0L; + + _ = ChangingPaintTasks.DrawChart(sut.Chart, true); + + var canvas = sut.Chart.CoreCanvas; + var geometries = canvas.CountGeometries(); + var deltas = 0; + var totalFramesDrawn = 0; + + ObservableCollection values; + + for (var i = 0; i < 100; i++) + { + var newValues = new ObservableValue[5000]; + for (var j = 0; j < 5000; j++) + newValues[j] = new(2); + + values = new(newValues); + + sut.Series.Values = values; + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + // we wait for the first frame to be drawn to measure the initial memory + // not sure why, but the first draw consumes about 12mb in this case + // but no matter the number or runs, it stays at those 12 mb all the time. + // so if we ignore the first call, we satisfy the 2mb threashold. + if (i == 0) initialMemory = GC.GetTotalMemory(true); + + var newCount = canvas.CountGeometries(); + if (newCount > geometries) + { + deltas++; + geometries = newCount; + } + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + } + + sut.Series.Values = null; + totalFramesDrawn += ChangingPaintTasks.DrawChart(sut.Chart, true); + + values = null; + + Assert.IsTrue(deltas <= 1); + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + // Assert that there is no significant increase in memory usage + var finalMemory = GC.GetTotalMemory(true); + + // 2MB is a reasonable threshold for this test + // it changes 100 times, the instance of the values array to a new array of 5,000 elements + + var mb = (finalMemory - initialMemory) / (1024d * 1024); + + Assert.IsTrue( + finalMemory - initialMemory < 2 * 1024 * 1024, + $"[{sut.Series.Name} series] Potential memory leak detected {mb:N2}MB, " + + $"{totalFramesDrawn} frames drawn."); + } + + #region helper classes + + private abstract class ChartSut + where T : IEnumerable + { + public InMemorySkiaSharpChart Chart { get; set; } + public ISeries Series { get; set; } + public T Values { get; set; } + + protected ChartSut( + InMemorySkiaSharpChart chart, + ISeries series, + string name, + T initialValues) + { + series.Name = name; + series.Values = Values = initialValues; + Series = series; + Chart = chart; + } + } + + private class CartesianSut( + ISeries series, + string name) + : ChartSut>(new SKCartesianChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + private class PieSut( + ISeries series, + string name) + : ChartSut>(new SKPieChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + private class PolarSut( + ISeries series, + string name) + : ChartSut>(new SKPolarChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + private class CartesianSutInt( + ISeries series, + string name) + : ChartSut(new SKCartesianChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + private class PieSutInt( + ISeries series, + string name) + : ChartSut(new SKPieChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + private class PolarSutInt( + ISeries series, + string name) + : ChartSut(new SKPolarChart + { + Series = [series], + AnimationsSpeed = TimeSpan.FromMilliseconds(10), + EasingFunction = EasingFunctions.Lineal, + Width = 1000, + Height = 1000 + }, + series, + name, + []) + { } + + #endregion +}