I'm having an issue with my chart not properly mapping fields I believe it very well could be how I've configured it.
According to the exception PickDistributionModel.UserName is not defined, however upon inspection of the endpoint returning the List<PickDistributionModel> it is populated with the users login.
Exception being thrown:
Uncaught ReferenceError: UserName is not defined<br> at eval (eval at compile (kendo.all.min.js:25), <anonymous>:3:84)<br> at init._pointContent (kendo.all.min.js:128)<br> at init.show (kendo.all.min.js:128)<br> at init._showTooltip (kendo.all.min.js:127)<br> at r.callObserver (kendo.all.min.js:118)<br> at r.trigger (kendo.all.min.js:118)<br> at init.trigger (kendo.all.min.js:127)<br> at init.notify (kendo.all.min.js:118)<br> at r.show (kendo.all.min.js:124)<br> at r.show (kendo.all.min.js:126)
Chart Implementation:
@(Html.Kendo().Chart<PickDistributionModel>().Name(
"picker-workload"
).Title(title =><br>{<br>title.Text(
"Pick Distribution (24hr)"
);<br>title.Position(ChartTitlePosition.Top);<br>}).Legend(legend => legend.Visible(
false
))<br>.ChartArea(chart => chart.Background(
"transparent"
))<br>.DataSource(source => source.Read(read => read.Action(
"GetPickDistributions"
,
"BoeingOrder"
,
new
{Area=
""
})))<br>.Series(s => s.Pie(m => m.Total, m => m.UserName)<br>.Tooltip(tooltip => tooltip.Visible(
true
).Template(
"#= UserName #: \n 0: #= Open # \n A: #= Audit # \n P: #= Picked #"
)).StartAngle(150)))
Controller Endpoint:
/// <summary><br> /// Gets the distribution of picks for users within the last 24 hours.<br> /// </summary><br> /// <returns><br> /// An array of <see cref="PickDistributionModel"/><br> /// </returns><br> [HttpPost]<br> public async Task<ActionResult> GetPickDistributions()<br> {<br> try<br> {<br> var floor = DateTime.Now.AddDays(-75).Date;<br> var ceiling = DateTime.Now.AddDays(-74).Date;<br> using var service = new PickAssignmentService();<br> var _ = await service.GetPickDistributionsAsync(floor: floor, ceiling: ceiling).ConfigureAwait(false);<br> return this.Json(_);<br> }<br> catch (Exception e)<br> {<br> // TODO: Document Exception<br> var errorId = this.LogError(e, GetUserId(), nameof(BoeingOrderController));<br> e.ToLog(errorId);<br> }<br><br> return BadRequest("Woops, something went wrong.");<br> }
Chart Model:
/// <summary><br> /// The model for representing pick distribution in a(n) chart.<br> /// </summary><br> public class PickDistributionModel<br> {<br> /// <summary><br> /// The name of the [dbo].[SecurityUser] the pick distribution model represents.<br> /// </summary><br> public string UserName { get; set; }<br><br> /// <summary><br> /// The total number of picks in a(n) users distribution.<br> /// </summary><br> public string Total { get; set; }<br><br> /// <summary><br> /// The number of picks in a(n) "picked" status.<br> /// </summary><br> public string Picked { get; set; }<br><br> /// <summary><br> /// The number of picks in a(n) "non-picked" status.<br> /// </summary><br> public string Open { get; set; }<br><br> /// <summary><br> /// The number of picks in a(n) "audit" status.<br> /// </summary><br> public string Audit { get; set; }<br> }