- Vertical chart
- Binding data with series
- Empty points
- Events
- See Also
Contact Support
Vertical Chart in ASP.NET CORE Charts Component
8 Oct 202422 minutes to read
Vertical chart
To draw a chart in a vertical manner, change the orientation of the axis using the isTransposed
property, which is supported by all series types.
<ejs-chart id="container" isTransposed="true">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= 26 },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= 35 },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Binding data with series
You can bind data to the chart using the dataSource
property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName
and yName
properties.
<ejs-chart id="container" isTransposed="true">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= 26 },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= 35 },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Empty points
Data points with null or undefined values are considered empty. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.
<ejs-chart id="container" isTransposed="true">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-emptypointSettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero"></e-series-emptypointSettings>
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= null },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= null },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Fill
Use the fill
property to customize the fill color of empty points in the series.
<ejs-chart id="container" isTransposed="true">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-emptypointSettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero" fill="red"></e-series-emptypointSettings>
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= null },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= null },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Border
Use the border
property to customize the width and color of the border for empty points.
<ejs-chart id="container" isTransposed="true">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-emptypointSettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero">
<e-emptypointSettings-border width="2" color="red"></e-emptypointSettings-border>
</e-series-emptypointSettings>
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= null },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= null },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
<ejs-chart id="container" isTransposed="true" seriesRender="changeColor">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
<script>
function changeColor(args) {
args.fill = '#ff6347';
}
</script>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= 26 },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= 35 },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
<ejs-chart id="container" isTransposed="true" pointRender="changeColor">
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Spline">
<e-series-marker visible="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
<script>
function changeColor(args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
</script>
public ActionResult Index()
{
List<VerticalData> chartData = new List<VerticalData>
{
new VerticalData{ x= 2005, y= 28 },
new VerticalData{ x= 2006, y= 25 },
new VerticalData{ x= 2007, y= 26 },
new VerticalData{ x= 2008, y= 27 },
new VerticalData{ x= 2009, y= 32 },
new VerticalData{ x= 2010, y= 35 },
new VerticalData{ x= 2011, y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class VerticalData
{
public double x;
public double y;
}