Hello Community!
Currently I am working in syncfusion bar chart layout and I'm trying to changes the color of the Data Series, percentage tick mark and change the legend icon however it wasn't changing I am new in this component and I would appreciate if you guide me. The attachment below are my sample codes and layout. Thank you
|
@Html.EJS().Chart("container").Series(
sr =>
{
sr.Fill("orange").ColumnSpacing(0.1).Marker(mr => mr.DataLabel(dl => dl.Visible(true))). LegendShape(Syncfusion.EJ2.Charts.LegendShape.Rectangle).Add();
}).PrimaryXAxis(
xAxis => { xAxis.MajorTickLines(mt=>mt.Width(0)).MajorGridLines(mg=>mg.Width(0)); })
.PrimaryYAxis(
yAxis=>yAxis.LineStyle(ls=>ls.Width(0)).MajorTickLines(mt => mt.Width(0)).MajorGridLines(mg => mg.Width(0)).LabelFormat("{value}%"))
.LegendSettings(ls=>ls.ShapeHeight(5).ShapeWidth(20))
.Render() |
Hello,
Now im working in syncfusion pie chart bind in Sql Server in asp.net mvc. I tried to use the Controller code of Bar Chart in creating a Pie Chart however it doesn't work. What should be the problem.
Controller:
List
string connectionString = null;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet dataset = new DataSet();
connectionString = @"Data Source=LAPTOP-V3QJAMBF\SQLEXPRESS;Initial Catalog=My_Database;Integrated Security=True;";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string command2 = "SELECT * FROM [myTable] WHERE Item_ID < 10";
SqlCommand cmd1 = new SqlCommand(command2, con);
adapter.SelectCommand = cmd1;
adapter.Fill(dataset);
for (var i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
int x1 = (int)Convert.ToInt32(dataset.Tables[0].Rows[i]["this.Item_ID"]);
int y1 = (int)Convert.ToInt32(dataset.Tables[0].Rows[i]["Item_Score"]);
data.Add(new ChartSqlData(x1, y1));
}
ViewBag.dataSource = data;
return View();
}
[Serializable]
public class ChartSqlData
{
public ChartSqlData(int xvalue, int yvalue1)
{
this.Item_ID = xvalue;
this.Item_Score = yvalue1;
}
public int Item_ID {
get;
set;
}
public int Item_Score{
get;
set;
}
CSHTML
@(Html.EJS().AccumulationChart("container")
.Series(sr =>
{
sr.Type(Syncfusion.EJ2.Charts.AccumulationType.Pie)
.XName("Item_ID")
.YName("Item_Score")
.Name("Item_ID")
.Explode(true)
.DataLabel(dl => dl.Visible(true).Name("Item_ID").Position(Syncfusion.EJ2.Charts.AccumulationLabelPosition.Outside).ConnectorStyle(cs => cs.Type(Syncfusion.EJ2.Charts.ConnectorType.Line).Length("5 %")).Font(ft => ft.Size("14px")))
.Animation(animate => animate.Enable(true))
.Radius("70%")
.StartAngle(0)
.EndAngle(360)
.InnerRadius("0%")
.GroupTo("9")
.GroupMode(Syncfusion.EJ2.Charts.GroupModes.Point)
.DataSource(ViewBag.dataSource).Add();
})
|
@(Html.EJS().AccumulationChart("container").Render()) |