I am very new in Syncfusion and I need help to connect the Bar Chart in SQL database on ASP.NET MVC
From the your documentation I followed it but still not working even it's not connected to database.
|
List<ChartSqlData> data = new List<ChartSqlData>();
string connectionString = null;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet dataset = new DataSet();
connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string command2 = "SELECT * FROM [Products] WHERE UnitPrice < 10";
SqlCommand cmd1 = new SqlCommand(command2, con);
adapter.SelectCommand = cmd1;
adapter.Fill(dataset);
for (var i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
string x1 = Convert.ToString(dataset.Tables[0].Rows[i]["ProductName"]);
double y1 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitPrice"]);
double y2 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitsInStock"]);
data.Add(new ChartSqlData(x1, y1, y2));
}
ViewBag.dataSource = data; |
I got a problem in connection string. I tried to Connect to SQL SERVER - Network related or Instance in SQl Server Configuration Manager and allow other apps in firewall but still not working.
Error:
System.Data.SqlClient.SqlException HResult=0x80131904 Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid. ) Source=.Net SqlClient Data Provider StackTrace:
Hello! I tried to make integrate the code to my system and there is no data display even it's the same algorithm. I wonder what would the the problem. Here the my code and output
|
<ej:Chart ID="Chart1" OnClientLoad="onChartLoad"></ej:Chart>
<script>
function onChartLoad(args) {
var points = args.model.series[0].dataSource;
console.log(points);
}
</script> |
Hello! Could you guide me I am very new. What would be the problem my bar chart is at the bottom, I can't find the html code of Syncfusion chart component html and css and where I could edit the css of Syncfusion components. Thank you!
Thank you :)
Hello,
I've been trying to customize the legend shape of Syncfusion chart however it doesn't give any changes. There are no error message in the code. I wondered what I missed in the code. Here's my codes
CSHTML FILE
<div class="box box-default">
<div class="box-body">
@Html.EJS().Chart("container").Series(
sr =>
{
sr.XName("Name").YName("Loan").Name("Loan Risk").Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).DataSource(ViewBag.dataSource).Add();
sr.XName("Name").YName("Score").Name("Loan Score").Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).DataSource(ViewBag.dataSource).Add();
sr.Marker(mr => mr.DataLabel(dl => dl.Visible(true).Position(Syncfusion.EJ2.Charts.LabelPosition.Top).Font(ff => ff.FontWeight("600").Color("#ffffff")))).DataSource(ViewBag.dataSource).Name("Users").Add();
}).PrimaryYAxis(px => px.LabelFormat("p1").LabelStyle(ls => ls.Color("#21130d")).LineStyle(ls => ls.Width(0)).MajorTickLines(mg => mg.Width(0))
.MajorGridLines(mg => mg.Width(0))
).PrimaryXAxis(px => px.LabelIntersectAction(Syncfusion.EJ2.Charts.LabelIntersectAction.Hide).Interval(1)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).MajorGridLines(mg => mg.Width(0))).Tooltip(tt => tt.Enable(true)
).ChartArea(area => area.Border(br => br.Color("transparent"))
).LegendSettings(lg => lg.Visible(true).Shape(ChartShape.Hexagon)).Title("Pre - Funding Audit Report").Render()
</div>
</div>
I used Shape(ChartShape.Hexagon) method for changing the legend shape but it doesnt work
|
@Html.EJS().Chart("container").Series(sr =>{ sr.LegendShape(Syncfusion.EJ2.Charts.LegendShape.Rectangle).Add();
}).LegendSettings(ls=>ls.ShapeHeight(5).ShapeWidth(20)).Render() |
Hello,
And also if you could guide me how I'm going to get the data from View to Controller to create a Synfusion Pie Chart
using the vw_qc_loan_audit_finding_details_checklist.
Attachment: PieChart_aff340c1.rar
|
$.ajax({
url: "/Home/GetData",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: { "chartData": model },
success: function (data) {
alert(data);
},
failure: function (errMsg) {
alert(errMsg);
}
});
[HttpPost]
public JsonResult GetData(ChartSqlData chartData)
{
return Json(chartData);
} |
Hello,
Can you please guide me how to use Dialog Editing in ASP.NET MVC Data Grid Control bind in SQL
Hello,
Can you give me an example. Thank you!
Hello,
I tried the sample demo and it works however I want perform modal dialog window as I add and edit data and save using asp.net mvc bind in SQL. Thank you!
|
[index.cshtml]
@Html.EJS().Grid("DialogEdit").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
---
}).EditSettings(edit => {edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Render()
|