Polar in ASP.NET MVC Charts Component
8 Oct 202424 minutes to read
Polar
To render a polar series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
Type
as Polar in your chart configuration. This indicates that the data should be represented as a polar chart, which is ideal for plotting data points on a circular graph.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
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.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Draw types
Use the DrawType
property to change the series plotting type in a Polar chart to line, column, area, range column, spline, scatter, stacking area, spline area, or stacking column. The default value of DrawType
is Line.
Line
To render a line draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as Line in your chart configuration. This indicates that the data should be represented as a polar line chart, with lines connecting each data point.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Spline
To render a spline draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as Spline in your chart configuration. This indicates that the data should be represented as a polar spline chart, with smooth, curved lines connecting each data point.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Spline)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Area
To render an area draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as Area in your chart configuration. This indicates that the data should be represented as a polar area chart, with filled areas below the lines connecting each data point.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Area)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Stacked Area
To render a stacked area draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as StackingArea in your chart configuration. This indicates that the data should be represented as a polar stacked area chart, with areas stacked on top of each other, displaying the cumulative value of multiple series.
@Html.EJS().Chart("container")
.Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingArea)
.Name("2013")
.XName("x")
.YName("y")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingArea)
.Name("2014")
.XName("x")
.YName("y1")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingArea)
.Name("2015")
.XName("x")
.YName("y2")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
})
.PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.Coefficient(100)
).Title("GDP, Current Prices (in Billions)").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2000, y= 0.61, y1= 0.03, y2= 0.48},
new PolarData{ x=2001, y= 0.81, y1= 0.05, y2= 0.53 },
new PolarData{ x=2002, y= 0.91, y1= 0.06, y2= 0.57 },
new PolarData{ x=2003, y= 1, y1= 0.09, y2= 0.61 },
new PolarData{ x=2004, y= 1.19, y1= 0.14, y2= 0.63 },
new PolarData{ x=2005, y= 1.47, y1= 0.20, y2= 0.64 },
new PolarData{ x=2006, y= 1.74, y1= 0.29, y2= 0.66 },
new PolarData{ x=2007, y= 1.98, y1= 0.46, y2= 0.76 },
new PolarData{ x=2008, y= 1.99, y1= 0.64, y2= 0.77 },
new PolarData{ x=2009, y= 1.70, y1= 0.75, y2= 0.55 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
public double y1;
public double y2;
}
Column
To render a column draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as Column in your chart configuration. This indicates that the data should be represented as a polar column chart, allowing for the comparison of values across categories.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Column)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x="2005", y= 28 },
new PolarData{ x="2006", y= 25 },
new PolarData{ x="2007", y= 26 },
new PolarData{ x="2008", y= 27 },
new PolarData{ x="2009", y= 32 },
new PolarData{ x="2010", y= 35 },
new PolarData{ x="2011", y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public string x;
public double y;
}
Stacked Column
To render a stacked column draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as StackingColumn in your chart configuration. This indicates that the data should be represented as a polar stacked column chart, with each column consisting of multiple segments stacked on top of each other.
@Html.EJS().Chart("container")
.Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingColumn)
.Name("2013")
.XName("x")
.YName("y")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingColumn)
.Name("2014")
.XName("x")
.YName("y1")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.StackingColumn)
.Name("2015")
.XName("x")
.YName("y2")
.Width(2)
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.Coefficient(100)
).Title("GDP, Current Prices (in Billions)").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2000, y= 0.61, y1= 0.03, y2= 0.48},
new PolarData{ x=2001, y= 0.81, y1= 0.05, y2= 0.53 },
new PolarData{ x=2002, y= 0.91, y1= 0.06, y2= 0.57 },
new PolarData{ x=2003, y= 1, y1= 0.09, y2= 0.61 },
new PolarData{ x=2004, y= 1.19, y1= 0.14, y2= 0.63 },
new PolarData{ x=2005, y= 1.47, y1= 0.20, y2= 0.64 },
new PolarData{ x=2006, y= 1.74, y1= 0.29, y2= 0.66 },
new PolarData{ x=2007, y= 1.98, y1= 0.46, y2= 0.76 },
new PolarData{ x=2008, y= 1.99, y1= 0.64, y2= 0.77 },
new PolarData{ x=2009, y= 1.70, y1= 0.75, y2= 0.55 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
public double y1;
public double y2;
}
Range Column
To render a range column draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as RangeColumn in your chart configuration. This indicates that the data should be represented as a polar range column chart, where each column spans a range of values.
@Html.EJS().Chart("container")
.Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.RangeColumn)
.Name("Germany")
.XName("x")
.High("high")
.Low("low")
.Width(2)
.Border(ViewBag.border)
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.Interval(1)
.Coefficient(100)
.StartAngle(90)
).Title("Maximum and Minimum Temperature").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x="Jan", low= 0.7, high= 6.1 },
new PolarData{ x="Feb", low=1.3, high=6.3 },
new PolarData{ x="Mar", low= 1.9, high= 8.5 },
new PolarData{ x= "Apr", low= 3.1, high= 10.8 },
new PolarData{ x="May", low= 5.7, high= 14.40 },
new PolarData { x= "Jun", low= 8.4, high= 16.90 },
new PolarData { x= "Jul", low= 10.6,high= 19.20 },
new PolarData { x= "Aug", low= 10.5,high= 18.9 },
new PolarData { x= "Sep", low= 8.5, high= 16.1 },
new PolarData { x= "Oct", low= 6.0, high= 12.5 },
new PolarData { x= "Nov", low= 1.5, high= 6.9 },
new PolarData { x= "Dec", low= 5.1, high= 12.1 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public string x;
public double low;
public double high;
}
Scatter
To render a scatter draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as Scatter in your chart configuration. This indicates that the data should be represented as a polar scatter chart.
@(Html.EJS().Chart("container")
.Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Scatter)
.Name("2015")
.XName("x")
.YName("y")
.Width(2)
.Marker(ViewBag.marker1)
.DataSource(ViewBag.dataSource).Add();
})
.PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.LabelPlacement(Syncfusion.EJ2.Charts.LabelPlacement.OnTicks)
.Interval(1)
.Coefficient(100)
)
.PrimaryYAxis(yaxis =>
yaxis.Interval(2)
.Minimum(0)
.Maximum(8)
)
.Title("Real GDP Growth")
.Tooltip(tp => tp.Enable(true))
.Load("load").Render()
)
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x="2005", y= 28 },
new PolarData{ x="2006", y= 25 },
new PolarData{ x="2007", y= 26 },
new PolarData{ x="2008", y= 27 },
new PolarData{ x="2009", y= 32 },
new PolarData{ x="2010", y= 35 },
new PolarData{ x="2011", y= 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public string x;
public double y;
}
Spline area
To render an spline area draw type, you need to follow a few steps to configure it correctly.
Set the series type: Define the series DrawType
as SplineArea in your chart configuration. This indicates that the data should be represented as a polar spline area chart, where the series is drawn with smooth, curved lines connecting each data point, and the area beneath the line is filled with color.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.SplineArea)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Series customization
Start Angle
You can customize the start angle of the polar series using startAngle property. By default, StartAngle
is 0 degree.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).StartAngle(120)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}
Radius
You can customize the radius of the polar series using Coefficient
property. By default, Coefficient
is 100.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).Coefficient(80)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
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.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.EmptyPointSettings(empty => empty.Mode(EmptyPointMode.Zero))
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = null },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = null },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double? y;
}
Fill
Use the Fill
property to customize the fill color of empty points in the series.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.EmptyPointSettings(empty => empty.Mode(EmptyPointMode.Zero).Fill("red"))
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = null },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = null },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double? y;
}
Border
Use the Border
property to customize the width and color of the border for empty points.
@Html.EJS().Chart("container").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.EmptyPointSettings(empty => empty.Mode(EmptyPointMode.Zero).Border(border => border.Width(2).Color("green")))
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = null },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = null },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
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.
@Html.EJS().Chart("container").SeriesRender("changeColor").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
<script>
function changeColor(args) {
args.fill = '#ff6347';
}
</script>
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
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.
@Html.EJS().Chart("container").PointRender("changeColor").Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Polar)
.DrawType(Syncfusion.EJ2.Charts.ChartDrawType.Line)
.Name("Warmest")
.XName("x")
.YName("y")
.Width(2)
.Marker(marker => marker.Visible(true).IsFilled(true))
.DataSource(ViewBag.dataSource).Add();
}).PrimaryXAxis(xaxis =>
xaxis.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).Title("Alaska Weather Statistics - 2016").Render()
<script>
function changeColor(args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
</script>
public IActionResult Index()
{
List<PolarData> chartData = new List<PolarData>
{
new PolarData{ x=2005, y = 28 },
new PolarData{ x=2006, y = 25 },
new PolarData{ x=2007, y = 26 },
new PolarData{ x=2008, y = 27 },
new PolarData{ x=2009, y = 32 },
new PolarData{ x=2010, y = 35 },
new PolarData{ x=2011, y = 30 }
};
ViewBag.dataSource = chartData;
return View();
}
public class PolarData
{
public double x;
public double y;
}