Back to Devexpress

Lesson 3 - Create a Chart Using a Series Template

aspnetmvc-114653-components-charting-getting-started-lesson-3-create-a-chart-using-a-series-template.md

latest7.4 KB
Original Source

Lesson 3 - Create a Chart Using a Series Template

  • Sep 30, 2023
  • 8 minutes to read

This lesson goes over the steps needed to build a chart bound to data in Visual Studio using a series template.

Step 1. Create a New Project

In this step, do the following preparatory work.

  • Create a new ASP.NET MVC project integrated with DevExpress ASP.NET MVC Extensions.
  • Add a new empty ChartController to the project.
  • Add a new empty Chart | Index View to the project.

To learn how to do this, refer to Lesson 1.

Now the blank project is ready for further customization.

Step 2. Add a Data Model

In this step, a data model used to provide data to the View will be added to the project.

  • In the Solution Explorer , right-click the Models folder. In the invoked menu, click Add | New Item….

  • In the invoked Add New Item dialog, select the Class group and then select the Class item. Set the Class name to Gdp and click Add.

  • Then, create a new GdpProvider class as was done in the previous steps and add the following code to it.

  • Find the GDPofG7.xml file shipped with the DevExpress DemoCenter and copy it to the App_Data directory within the project directory.

  • Add the following code to the ChartController class definition.

Now, the Model preparation is finished and data can be provided to a Chart.

Step 3. Create a Chart

In this step, a Chart is added to the View and the series bound to the Model is added to the Chart.

The chart is created. If you run the application now, it will look as follows.

Required data is provided to the Chart. In the next step, let’s customize the chart appearance.

Step 4. Customize the Chart

In this step, the appearance of chart and series is improved and the chart title and axis titles are added.

Result