Canvas.Views.Web 1.7.1-prerelease

This is a prerelease version of Canvas.Views.Web.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Canvas.Views.Web --version 1.7.1-prerelease
                    
NuGet\Install-Package Canvas.Views.Web -Version 1.7.1-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.Views.Web" Version="1.7.1-prerelease" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Canvas.Views.Web" Version="1.7.1-prerelease" />
                    
Directory.Packages.props
<PackageReference Include="Canvas.Views.Web" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Canvas.Views.Web --version 1.7.1-prerelease
                    
#r "nuget: Canvas.Views.Web, 1.7.1-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.
#:package Canvas.Views.Web@1.7.1-prerelease
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Canvas.Views.Web&version=1.7.1-prerelease&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Canvas.Views.Web&version=1.7.1-prerelease&prerelease
                    
Install as a Cake Tool

Canvas - Financial Charts

The fastest charting web control targeting primarily Blazor, both Server Side and Web Assembly, and to some extent 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 real-time charting tool for financial applications that require frequent updates, 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.

  • Samples are here
  • Example of usage in real life is a trading terminal here

Status

Install-Package Canvas.Views.Web

GitHub Workflow Status (with event) GitHub GitHub

Implementations

Currently available controls.

  • Engine - base control exposing drawing context for 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, the library supports the following chart types.

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

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

Sample

The simplest data format is a list of IShape models with a X and Y properties.


<CanvasView @ref="View"></CanvasView>

@code
{
  public CanvasView View { get; set; }

  protected override async Task OnAfterRenderAsync(bool setup)
  {
    if (setup)
    {
      var generator = new Random();
      var points = Enumerable.Range(1, 1000).Select(i => new BarShape 
      { 
        X = i, 
        Y = generator.Next(-5000, 5000) 
     
     }).ToList();
      
      var composer = new Composer
      {
        Name = "Demo",
        Items = points
      };

      await View.Create<CanvasEngine>(engine => composer);

      composer.Update();
    }

    await base.OnAfterRenderAsync(setup);
  }
}

By default, the axis X is used as an index that picks data points from the source list and axis Y is a value that represents the actual value of each data point on the vertical scale.

Synchronization

To simplify synchronization, you can use IGroupShape model instead of simple IShape. This model allows groupping series for each chart by single timestamp, so you could display candles, lines, and other series on the same chart.

Item = new 
{
  Groups = new GroupShape
  {
    ["Price Area"] = new Dictionary<string, GroupShape>
    {
      Groups = new GroupShape
      {
        ["Price Series"] = new CandleShape(),
        ["Arrow Series"] = new ArrowShape()
      }
    },
    ["Indicator Area"] = new Dictionary<string, GroupShape>
    {
      Groups = new GroupShape
      { 
        ["Bar Series"] = new BarShape() 
      }
    }
  }
}

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

Roadmap

To increase performance, the chart is split into pieces and each piece is using its own thread, so UI is never blocked even while rendering 100K samples. To increase performance even further, downsampling could be implemented, e.g. when number of points is greater that width of the screen in pixels, because all points wouldn't fit on the screen anyway.

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.6.9 203 5/8/2025
5.6.8 154 5/7/2025
5.6.7 162 5/7/2025
5.6.6 163 5/7/2025
5.6.5 145 2/4/2025
5.6.3 138 1/28/2025
5.6.2 132 1/20/2025
5.6.1 116 1/17/2025
5.6.0 105 1/17/2025
5.5.0 116 1/8/2025
5.0.0 140 12/27/2024
4.5.6 132 12/10/2024
4.5.5 232 10/26/2024
4.5.4 112 10/26/2024
4.5.3 143 10/25/2024
4.5.2 115 10/24/2024
4.5.1 125 10/24/2024
4.5.0 118 10/24/2024
4.0.0 143 10/9/2024
3.3.0 131 10/6/2024
3.2.9 140 9/28/2024
3.2.8 132 9/25/2024
3.2.7 123 9/25/2024
3.2.6 125 9/25/2024
3.2.5 122 9/24/2024
3.2.4 175 8/27/2024
3.2.3 145 8/24/2024
3.2.2 155 8/19/2024
3.2.1 155 8/18/2024
3.2.0 150 8/16/2024
3.1.5 154 6/24/2024
3.1.4 171 6/2/2024
3.1.3 146 5/29/2024
3.1.2 145 5/26/2024
3.1.1 135 5/23/2024
3.1.0 171 5/21/2024
3.0.9 140 5/21/2024
3.0.8 176 3/25/2024
3.0.7 152 3/24/2024
3.0.6 141 3/20/2024
3.0.5 165 3/18/2024
3.0.4 141 3/18/2024
3.0.3 149 3/18/2024
3.0.1 148 3/17/2024
3.0.0 151 3/15/2024
2.0.7 152 3/14/2024
2.0.6 154 3/14/2024
2.0.5 132 3/7/2024
2.0.3 168 3/3/2024
2.0.2 147 3/3/2024
2.0.1 147 3/1/2024
2.0.0 144 2/26/2024
1.9.9 131 2/25/2024
1.9.8 141 2/24/2024
1.9.6 153 2/17/2024
1.9.5 145 2/17/2024
1.9.4 148 2/15/2024
1.9.3 178 2/11/2024
1.9.2 147 2/11/2024
1.9.1 134 2/11/2024
1.9.0 147 2/9/2024
1.8.9 167 2/8/2024
1.8.8 162 2/8/2024
1.8.7 144 2/5/2024
1.8.6 155 2/5/2024
1.8.5 163 1/28/2024
1.8.4 157 1/26/2024
1.8.3 136 1/26/2024
1.8.2 137 1/25/2024
1.8.1 171 1/18/2024
1.8.0 292 5/29/2023
1.7.9-prerelease 192 3/12/2023
1.7.8-prerelease 204 3/5/2023
1.7.7-prerelease 190 2/24/2023
1.7.6-prerelease 207 2/20/2023
1.7.5-prerelease 188 2/14/2023
1.7.1-prerelease 203 2/9/2023
1.7.0-prerelease 193 2/5/2023
1.6.7-prerelease 207 2/4/2023
1.6.6-prerelease 226 2/1/2023
1.6.5-prerelease 270 1/12/2023
1.6.4-prerelease 199 1/8/2023
1.6.3-prerelease 219 12/18/2022
1.6.2-prerelease 204 12/4/2022
1.6.1-prerelease 223 11/24/2022
1.6.0-prerelease 216 11/19/2022
1.5.9-prerelease 217 11/6/2022
1.5.6-prerelease 226 11/3/2022
1.5.5-prerelease 198 11/2/2022
1.5.3-prerelease 204 10/29/2022
1.5.2-prerelease 216 10/2/2022
1.5.1-prerelease 228 10/2/2022
1.5.0-prerelease 220 9/21/2022
1.4.0-prerelease 227 8/7/2022
1.3.9-prerelease 250 8/7/2022
1.3.8-prerelease 256 8/7/2022
1.3.7-prerelease 224 8/2/2022
1.3.6-prerelease 210 8/1/2022
1.3.5-prerelease 216 8/1/2022
1.3.4-prerelease 217 8/1/2022
1.3.3-prerelease 212 8/1/2022
1.3.2-prerelease 230 7/29/2022
1.3.1-prerelease 248 7/21/2022
1.3.0-prerelease 239 7/13/2022
1.2.9-prerelease 250 7/11/2022
1.2.8-prerelease 224 7/9/2022
1.2.7-prerelease 231 7/9/2022
1.2.6-prerelease 248 7/7/2022
1.2.5-prerelease 236 7/1/2022
1.2.4-prerelease 265 5/8/2022
1.2.3-prerelease 250 4/18/2022
1.2.2-prerelease 237 4/17/2022
1.2.1-prerelease 260 4/16/2022
1.2.0-prerelease 247 4/16/2022
1.1.9-prerelease 260 4/15/2022
1.1.8-prerelease 245 4/15/2022
1.1.7-prerelease 248 4/14/2022
1.1.6-prerelease 259 4/12/2022
1.1.5-prerelease 245 4/9/2022
1.1.4-prerelease 238 4/7/2022
1.1.3-prerelease 270 4/6/2022
1.1.2-prerelease 219 4/5/2022
1.1.1-prerelease 230 4/4/2022
1.1.0-prerelease 246 4/3/2022
1.0.9-prerelease 246 4/3/2022
1.0.8-prerelease 256 4/3/2022
1.0.7-prerelease 240 4/3/2022
1.0.6-prerelease 252 4/3/2022
1.0.5-prerelease 254 3/26/2022
1.0.0-prerelease 253 3/24/2022