[Chartjs]-How do I use NuGet to install ChartJS?

1👍

How do I use NuGet to install ChartJS?

You should use npm or bower to install Chart.js package (Not the ChartJS). That because the usage of NuGet for css/javascript libraries is discouraged.

When you open the project site of the Chart.js package, it also recommend you to get the chart.js via npm or bower:

enter image description here

Detail to get it via npm or bower:

Select project and add a new file to the project root. While in the template manager (Add->New File...), search for “Bower Configuration File” or “npm Configuration file”.

Then edit the file and add your dependency, i.e.

package.json (npm):

{
    "dependencies:" {
        "chart.js": "2.7.2"
    }
}

bower.json (bower):

{
    "dependencies:" {
        "chart.js": "2.7.2"
    }
}

Once you save, the file will be downloaded in a directory named node_modules (npm) or bower_components (bower) in your project file .csproj folder, then you can use it by script, like:

<script src="path/to/chartjs/dist/Chart.js"></script>

Besides, when you open the nuget package Chart.js with nuget package explorer, you will find it only includes a Content\Scripts directory inside its NuGet package which contains a Chart.js and Chart.min.js. So if you want to get Chart.bundle.js and utils.js, please try to get it by nmp or bower.

Hope this helps.

Leave a comment