Canvas.Core 1.1.4-prerelease

This is a prerelease version of Canvas.Core.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Canvas.Core --version 1.1.4-prerelease
NuGet\Install-Package Canvas.Core -Version 1.1.4-prerelease
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Canvas.Core" Version="1.1.4-prerelease" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Canvas.Core --version 1.1.4-prerelease
#r "nuget: Canvas.Core, 1.1.4-prerelease"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Canvas.Core as a Cake Addin
#addin nuget:?package=Canvas.Core&version=1.1.4-prerelease&prerelease

// Install Canvas.Core as a Cake Tool
#tool nuget:?package=Canvas.Core&version=1.1.4-prerelease&prerelease

Canvas and Open GL Stock and Financial Charts

The fastest charting web control targeting primarily Blazor, both Server Side and Web Assembly, and even ASP.NET MVC. This charting library was designed for Web, but it can also be used in Desktop apps via Web View. The main purpose of this library is to be used as a charting tool for real-time financial applications, e.g. backtesters for trading strategies. Here is the most comprehensive guide dedicated to charting in .NET that I have seen so far. Nevertheless, trying various options from that guide I wasn't able to find anything fast and flexible enough for my needs, so created my own.

  • Examples can be found here
  • Possible application of this library is here

Nuget

Install-Package Canvas.Views.Web

Drawing Methods

Currently available controls.

  • Engine - abstract base Canvas control exposing drawing context of various frameworks, like GDI or SkiaSharp
  • CanvasEngine - a wrapper around SkiaSharp and Open GL

To add different view types, e.g. GDI+, Direct 2D, Win UI, Open GL, implement IEngine interface.

Chart Types

At the moment, there are four built-in chart types.

  • Line - line
  • Bar - polygon
  • Area - polygon
  • Arrow - polygon
  • Candle - OHLC box, a mix of a line and a rectangle polygon

To add new chart types, e.g. Error Bars or Bubbles, implement IGroupModel interface.

Pan and Zoom

The chart is data-centric, thus in order to scale the chart you need to change the data source. By default, the chart displays last 100 data points, as defined in IndexCount property.

MinIndex = Items.Count - IndexCount
MaxIndex = Items.Count

To pan the chart to the left, subtract arbitrary value from both MinIndex and MaxIndex.

MinIndex -= 1
MaxIndex -= 1

To pan the chart to the right, do the opposite.

MinIndex += 1
MaxIndex += 1

To zoom in, increase MinIndex and decrease MaxIndex to decrease number of visible points.

MinIndex += 1
MaxIndex -= 1

To zoom out, do the opposite.

MinIndex -= 1
MaxIndex += 1

Data source structure

The simplest format used by the library is a list of models with a single Point property.


<CanvasWebView @ref="ViewControl"></CanvasWebView>

@code
{
  public CanvasWebView ViewControl { get; set; }

  protected override async Task OnAfterRenderAsync(bool setup)
  {
    var points = Enumerable.Range(1, 100).Select(i => new BarGroupModel
    {
      Index = i,
      Value = new Model { ["Point"] = new Random().Next(-5000, 5000) }
    } as IPointModel);

    ViewControl.Composer = new Composer
    {
      Name = name,
      Points = points.ToList(),
      Engine = new CanvasEngine(1000, 500)
    };

    ViewControl.Create();
    ViewControl.Update();
  }
}

In case when charts have to be synchronized or overlapped within the same viewport, data source should have format of a list where each entry point has a time stamp and a set of Areas and Series that will be rendered in the relevant viewport.

[
  DateTime
  {
    Area A
    {
      Line Series => double,
      Candle Series => OHLC
    },
    Area B 
    {
      Line Series => double,
      Line Series => double
    },
    Area C 
    {
      Bar Series => double
    }
  }, 
  DateTime { ... },
  DateTime { ... },
  DateTime { ... }
]

  • Area is a viewport, an actual chart, each viewport can show several types of series, e.g. a mix of candles and lines.
  • Series is a single chart type to be displayed in the viewport, e.g. lines.
  • Model is a data point of dynamic type, can accept different type of inputs, e.g. double or OHLC box.

At this moment, Canvas supports only horizontal orientation, so the axis X is used as an index scale that picks data points from the source list and axis Y is a value scale that represents the actual value of each data point.

Roadmap

The current version is already the fastest .NET charting library, but it can be even faster if instead of rerendering HTML elements Blazor will simply show or hide them using CSS.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Canvas.Core:

Package Downloads
Canvas.Views.Web

Generic real-time charts for Web and Desktop apps with built-in pan and zoom support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.8 115 3/25/2024
3.0.7 90 3/24/2024
3.0.6 90 3/20/2024
3.0.5 103 3/18/2024
3.0.4 101 3/18/2024
3.0.3 96 3/18/2024
3.0.1 99 3/17/2024
3.0.0 98 3/15/2024
2.0.7 97 3/14/2024
2.0.6 103 3/14/2024
2.0.5 101 3/7/2024
2.0.3 106 3/3/2024
2.0.2 89 3/3/2024
2.0.1 104 3/1/2024
2.0.0 104 2/26/2024
1.9.9 98 2/25/2024
1.9.8 89 2/24/2024
1.9.6 103 2/17/2024
1.9.5 92 2/17/2024
1.9.4 93 2/15/2024
1.9.3 108 2/11/2024
1.9.2 92 2/11/2024
1.9.1 94 2/11/2024
1.9.0 99 2/9/2024
1.8.9 100 2/8/2024
1.8.8 100 2/8/2024
1.8.7 85 2/5/2024
1.8.6 82 2/5/2024
1.8.5 102 1/28/2024
1.8.3 94 1/26/2024
1.8.2 81 1/25/2024
1.8.1 107 1/18/2024
1.8.0 210 5/29/2023
1.7.9-prerelease 136 3/12/2023
1.7.8-prerelease 128 3/5/2023
1.7.7-prerelease 123 2/24/2023
1.7.6-prerelease 125 2/20/2023
1.7.5-prerelease 115 2/14/2023
1.7.1-prerelease 139 2/9/2023
1.7.0-prerelease 149 2/5/2023
1.6.7-prerelease 137 2/4/2023
1.6.6-prerelease 153 2/1/2023
1.6.5-prerelease 191 1/12/2023
1.6.4-prerelease 138 1/8/2023
1.6.3-prerelease 139 12/18/2022
1.6.2-prerelease 137 12/4/2022
1.6.1-prerelease 133 11/24/2022
1.6.0-prerelease 152 11/19/2022
1.5.9-prerelease 136 11/6/2022
1.5.6-prerelease 150 11/3/2022
1.5.5-prerelease 136 11/2/2022
1.5.3-prerelease 143 10/29/2022
1.5.2-prerelease 138 10/2/2022
1.5.1-prerelease 148 10/2/2022
1.5.0-prerelease 150 9/21/2022
1.3.2-prerelease 130 8/7/2022
1.3.1-prerelease 125 8/7/2022
1.3.0-prerelease 126 8/7/2022
1.2.9-prerelease 118 8/2/2022
1.2.8-prerelease 106 8/1/2022
1.2.7-prerelease 113 8/1/2022
1.2.6-prerelease 108 8/1/2022
1.2.5-prerelease 113 8/1/2022
1.2.4-prerelease 123 7/29/2022
1.2.3-prerelease 124 7/21/2022
1.2.2-prerelease 125 7/13/2022
1.1.7-prerelease 146 5/8/2022
1.1.6-prerelease 131 4/18/2022
1.1.5-prerelease 144 4/16/2022
1.1.4-prerelease 154 4/15/2022
1.1.3-prerelease 138 4/14/2022
1.1.2-prerelease 138 4/9/2022
1.1.1-prerelease 145 4/4/2022