ChartJSCore

[删除(380066935@qq.com或微信通知)]

ChartJSCore v3.2.0

mattosaurus/ChartJSCore:Chart.js实现,用于.NET Core。 (github.com)

Chart.js的实现,用于 .NET Core。此库允许在 MVC 控制器中从 .NET 对象生成图表.js代码,并将其注入到所需的视图中。

Implementation of Chart.js for use with .NET Core. This library allows Chart.js code to be generated in an MVC controller from a .NET object and injected into the desired view.

Build status

This library has been updated to work with v3 of Chart.js, I have done minimal testing so there are likely to be bugs. If something doesn't work as expected please open a new issue with an example of the failing code and alink to the relevant Chart.js documentation.

Installation

To use ChartJSCore in your C# project, you can either download the ChartJSCore C# .NET libraries directly from the Github repository or, if you have the NuGet package manager installed, you can grab them automatically.

PM> Install-Package ChartJSCore

Once you have the ChartJSCore libraries properly referenced in your project, you can include calls to them in your code.

Add the following namespaces to use the library:

using ChartJSCore.Models;

Dependencies

This produces code for generating chart using Chart.js so Chart.js is required to render them, Chart.js also uses require.js so this is also needed. To install Chart.js using Bower on Visual Studio it is needed to update the registry in .bowerrc file, because the old heroku repository is deprecated as stated in here. Otherwise you can download it directly to the project root folder wwwroot\lib\Chart.js.

This package has been created and tested with version 2.4.0 of Chart.js, earlier versions may well be incompatible.

Require.js isn't available in the Bower package manager but can be added by directly updating the bower.json file.

{
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "bootstrap": "3.3.7",
    "jquery": "3.1.1",
    "jquery-validation": "1.16.0",
    "jquery-validation-unobtrusive": "3.2.6",
    "requirejs": "2.3.3",
    "chart.js": "2.5.0"
  }
}

Demo

This project can be seen in action on the demo site here.