[]
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:
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.
Add a new class to the folder Models (for example: Dot.cs
). See Adding controls to know how to add a new model.
Add the following code to the new model to define the class that serve as a data source for the FlexChart control.
public class Dot
{
public double X { get; set; }
public double Y { get; set; }
public double Size { get; set; }
}
FlexChartController
).Add a View for the Controller
From the Solution Explorer, expand the folder Controllers and double click the controller FlexChartController
to open it.
Place the cursor inside the Index()
method.
Right click and select Add View. The Add View dialog appears.
In the Add View dialog, verify that the view name is Index and View engine is Razor (CSHTML).
Click Add. A view is added for the controller.
Replace the code in the Index.cshtml file with the following.
<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>
type=note
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.