Getting Started with ASP.NET Core Bullet Charts Control

23 Jul 20266 minutes to read

This section briefly explains how to include the ASP.NET Core Bullet Charts control in your ASP.NET Core application using Visual Studio.

Create an ASP.NET Core Web App with Razor Pages

Create an ASP.NET Core Web App using Visual Studio via Microsoft Templates or the Syncfusion® ASP.NET Core Extension. For detailed instructions, refer to the ASP.NET Core Web App Getting Started documentation.

Install the required ASP.NET Core package

To add ASP.NET Core Bullet Charts control in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for and install the Syncfusion.AspNetCore.BulletChart package. All Syncfusion ASP.NET Core packages are available in nuget.org. See the NuGet packages topic for details.

Alternatively, you can install the same package using the Package Manager Console with the following command.

Install-Package Syncfusion.AspNetCore.BulletChart -Version 34.1.29

Add the ASP.NET Core Tag Helpers

After the package is installed, open the ~/Pages/_ViewImports.cshtml file and import the Syncfusion.AspNetCore.Base and Syncfusion.AspNetCore.Charts Tag Helpers.

@addTagHelper *, Syncfusion.AspNetCore.Base
@addTagHelper *, Syncfusion.AspNetCore.Charts

Add script resource

Include the script reference inside the <head> of ~/Pages/Shared/_Layout.cshtml.

<head>
    ...
    <!-- ASP.NET Core controls scripts -->
    <script src="_content/Syncfusion.AspNetCore.BulletChart/scripts/sf-bullet-chart.min.js"></script>
</head>

Register the script manager

Open the ~/Pages/Shared/_Layout.cshtml file and register the script manager <ejs-scripts> at the end of the <body> element as follows.

<body>
    ...
    <!-- ASP.NET Core Script Manager -->
    <ejs-scripts></ejs-scripts>
</body>

Add ASP.NET Core Bullet Charts control

Add the ASP.NET Core Bullet Charts control in the ~/Pages/Index.cshtml file.

<ejs-bulletchart id="container"></ejs-bulletchart>

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. The ASP.NET Core Bullet Charts will render in your default web browser.

ASP.NET Core Bullet Charts Control

Bullet Charts With Data

Now, assign the data to dataSource property. value and target values should be mapped with valueField and targetField respectively.

@{
    List<DefaultBulletData> bulletData = new List<DefaultBulletData>
    {
        new DefaultBulletData { value = 270, target = 250}
    };
}

<ejs-bulletchart id="bulletgraph" minimum="0" maximum="300" interval="50" valueField="value" targetField="target" dataSource="bulletData">
</ejs-bulletchart>
public class DefaultBulletData
{
    public double value;
    public double target;
}

Add Bullet Charts Title

You can add a title using title property to the Bullet Charts to provide quick information to the user about the data plotted in the Bullet Charts.

@{
    List<DefaultBulletData> bulletData = new List<DefaultBulletData>
    {
        new DefaultBulletData { value = 270, target = 250}
    };
}

<ejs-bulletchart id="bulletgraph" title="Revenue" minimum="0" maximum="300" interval="50" valueField="value" targetField="target" dataSource="bulletData">
</ejs-bulletchart>
public class DefaultBulletData
{
    public double value;
    public double target;
}

ASP.NET Core Bullet Chart with Title

Ranges

You can add a range using e-bullet-range of the e-bullet-range-collection.

@{
    List<DefaultBulletData> bulletData = new List<DefaultBulletData>
    {
        new DefaultBulletData { value = 270, target = 250}
    };
}

<ejs-bulletchart id="bulletgraph" minimum="0" maximum="300" interval="50" valueField="value" targetField="target" dataSource="bulletData">
        <e-bullet-range-collection>
            <e-bullet-range end="150"></e-bullet-range>
            <e-bullet-range end="250"></e-bullet-range>
            <e-bullet-range end="300"></e-bullet-range>
        </e-bullet-range-collection>
</ejs-bulletchart>
public class DefaultBulletData
{
    public double value;
    public double target;
}

Tooltip

You can use tooltip for the Bullet Charts by setting the enable property to true in e-bulletchart-tooltipsettings.

@{
    List<DefaultBulletData> bulletData = new List<DefaultBulletData>
    {
        new DefaultBulletData { value = 270, target = 250}
    };
}

<ejs-bulletchart id="bulletgraph" minimum="0" maximum="300" interval="50" valueField="value" targetField="target" dataSource="bulletData">
        <e-bulletchart-tooltipsettings enable="true"></e-bulletchart-tooltipsettings>
        <e-bullet-range-collection>
            <e-bullet-range end="150"></e-bullet-range>
            <e-bullet-range end="250"></e-bullet-range>
            <e-bullet-range end="300"></e-bullet-range>
        </e-bullet-range-collection>
</ejs-bulletchart>
public class DefaultBulletData
{
    public double value;
    public double target;
}

ASP.NET Core Bullet Charts with Tooltip

NOTE

View Sample in GitHub.

See also

  1. Getting Started with ASP.NET Core using Razor Pages
  2. Getting Started with ASP.NET Core MVC using Tag Helper