ASP.NET Core MVC Controls | ComponentOne
Working with Controls / FlexChart / Work with FlexChart / Customize Appearance
In This Topic
    Customize Appearance
    In This Topic

    FlexChart allows you to customize the appearance of the data points based on their values using ItemFormatter property of the FlexChart class. The ItemFormatter property lets you customize the UI of the control using a JavaScript function.

    The image below shows the how the chart appears on customization.

    The following code examples demonstrate how to customize the appearance of the data points in FlexChart.

    To accomplish this, follow these steps:

    1. Create an MVC application
    2. Create a data source for FlexChart
    3. Add FlexChart and customize its appearance
    4. Build and run the project

    Step 1: Create an MVC application

    Create a new MVC application using the ComponentOne or VisualStudio templates. For more information about creating an MVC application, see Configuring your MVC Application topic.

    Back to Top

    Step 2: Create a data source for FlexChart

    1. Add a new class to the folder Models (for example: Dot.cs). See Adding controls to know how to add a new model.
    2. Add the following code to the new model to define the class that serve as a data source for the FlexChart control.
      C#
      Copy Code
      public class Dot
          {
              public double X { get; set; }
              public double Y { get; set; }
              public double Size { get; set; }
          }
      
    Back to Top

    Step 3: Add FlexChart and customize its appearance

    1. In the Solution Explorer, right click the folder Controllers.
    2. From the context menu, select Add | Controller. The Add Scaffold dialog appears.
    3. Complete the following steps in the Add Scaffold dialog:
      1. Select Empty MVC Controller template.
      2. Set name of the controller (for example: FlexChartController).
      3. Click Add.

    Add a View for the Controller

    1. From the Solution Explorer, expand the folder Controllers and double click the controller FlexChartController to open it.
    2. Place the cursor inside the Index() method.
    3. Right click and select Add View. The Add View dialog appears.
    4. In the Add View dialog, verify that the view name is Index and View engine is Razor (CSHTML).
    5. Click Add. A view is added for the controller.
    6. Replace the code in the Index.cshtml file with the following.
      cshtml
      Copy Code
      <c1-flex-chart chart-type="LineSymbols" 
                     legend-position="None"
                     item-formatter="itemFormatter">
          <c1-flex-chart-series binding-x="X" binding="Y" name="cos(x)">
              <c1-items-source source-collection="cos"></c1-items-source>
          </c1-flex-chart-series>
      </c1-flex-chart>
      
    Back to Top

    Step 4: Build and Run the Project

    1. Click Build | Build Solution to build the project.
    2. Press F5 to run the project.
      Append the folder name and view name to the generated URL (for example: http://localhost:1234/FlexChart/Index) in the address bar of the browser to see the view.
    Back to Top