BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
I am working with various types of charts. I everything seems to work when I pass a list directly from the controller but when trying to use a UrlAdaptor as the datasource the table never contains any data.
Here is my chart control definition
<ejs-accumulationchart id="container" title="Volunteer Hours" load="window.onChartLoad" enableAnimation="false">
<e-accumulationchart-tooltipsettings enable="false"></e-accumulationchart-tooltipsettings>
<e-accumulationchart-legendsettings visible="true"></e-accumulationchart-legendsettings>
<e-accumulation-series-collection>
<e-accumulation-series xName="EventType" yName="HoursWorked" name="HoursWorked" query="new ej.data.Query()">
<e-data-manager crossDomain="true" url="/Home/UrlDatasource" adaptor="UrlAdaptor"></e-data-manager>
</e-accumulation-series>
</e-accumulation-series-collection>
</ejs-accumulationchart>
Here is the definition for the UrlDataAdaptor which correctly returns data.
public JsonResult UrlDatasource([FromBody] DataManagerRequest dm)
{
IEnumerable<VolunteerHours> DataSource = VolunteerHours.GetAllRecords();
DataOperations operation = new DataOperations();
int count = DataSource.Cast<VolunteerHours>().Count();
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
if (dm.Skip != 0) //Paging
{
DataSource = operation.PerformSkip(DataSource, dm.Skip);
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
I am using VisualStudio 2022, asp.net core v7 and SyncFusion 24.2.3. I have attached a simple example program.
Hi Chris,
Greetings from Syncfusion.
We have considered the reported scenario as a bug and logged a defect report for the same. The fix for the reported scenario will be included in our weekly patch release which is expected to be rolled out on 27th February 2024. Please find the below feedback link to keep track of the reported scenario.
Feedback link: https://www.syncfusion.com/feedback/50897/pie-chart-is-not-rendered-when-urladaptor-is-used
Kindly, revert us if you have any concerns.
Regards,
Swetha
Chris,
Thank you for your patience.
We can render the chart with url adaptor by adding the DefaultContractResolver in the Startup.cs file to resolve the reported scenario. We have modified the provided sample and the same can be downloaded from the attached file.
Documentation link: https://ej2.syncfusion.com/aspnetcore/documentation/grid/data-binding/data-binding#troubleshoot-grid-render-rows-without-data
Code Snippet:
public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddMvc().AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); } |
Screenshot:
Kindly, revert us if you have any concerns.
Swetha,
Thank you for this update. I have been able to populate my Charts and Graphs using a URL Adaptor after adding the ContractResolver.
One additional question can I use a Data Query to specify additional parameters. This is simple to do with DataGrid but I'm not sure how to implement it with a chart and specifically each e-series. I want to use the same URL Adapter for multiple series. For example monthly counts by year so my query would look something like this.
query="new ej.data.Query().addParams('Year', 2024)"
Where would this query be included in the chart definition?
Alternately could a different URL adapter be specified for each e-series or is it specific to the e-series-collection?
Just discovered a few more issues with using the DefaultContractResolver. First off the scheduler control does not render data when the contract resolver is defined. Second it changes the way that parameters are passed back to JAVA in the args.rowData.
For example without the contract resolver parameters come back in camel case with the first letter always in lower case. With the contract resolver defined the exact name of the parameter comes back. So if one of the columns in my data is named EventId with the contract resolver this is parsed to EventId without the contract resolver it becomes eventId.
Not a huge deal but since JAVA is case sensitive this ended up breaking several of my scirpts where I needed to retrieve a value from a row.
// Works if contract resolver is not defined
value= args.rowData.eventId
// Must be changed to this with contract resolver
value= args.rowData.EventId
I understand that the behavior is different just wanted to point this out. Also any ideas on why the UrlAdapter stopped working with the scheduler let me know.
Chris
Hi Chris,
We have forwarded the query to the corresponding team. So, we will update you with further details once they have replied.