ok so I have created a chart, that takes data from a MVC action method and populates a chart, in your example here http://dojo.telerik.com/@tsvetomir/UvON You have autosync set to true, but where is the push coming from? How do I send the updated information? My chart loads Initially but does not change when any of the status' change.
Code for chart:
<script>
var connection = $.hubConnection();
var hub = connection.createHubProxy("centralHub");
connection.logging = true;
var hubPromise = connection.start();
</script>
@{
double[] clockins = new double[5];
double[] breaks = new double[5];
double[] lunch = new double[5];
if (Model != null)
{
foreach (var item in Model)
{
switch (item.SiteName)
{
case "Mabel":
switch (item.TypeName)
{
case "ClockIn":
clockins[0] = item.Count;
break;
case "Break":
breaks[0] = item.Count;
break;
case "Lunch":
lunch[0] = item.Count;
break;
}
break;
case "Harp":
switch (item.TypeName)
{
case "ClockIn":
clockins[1] = item.Count;
break;
case "Break":
breaks[1] = item.Count;
break;
case "Lunch":
lunch[1] = item.Count;
break;
}
break;
case "Pendleton":
switch (item.TypeName)
{
case "ClockIn":
clockins[2] = item.Count;
break;
case "Break":
breaks[2] = item.Count;
break;
case "Lunch":
lunch[2] = item.Count;
break;
}
break;
case "Granite":
switch (item.TypeName)
{
case "ClockIn":
clockins[3] = item.Count;
break;
case "Break":
breaks[3] = item.Count;
break;
case "Lunch":
lunch[3] = item.Count;
break;
}
break;
case "HQ":
switch (item.TypeName)
{
case "ClockIn":
clockins[4] = item.Count;
break;
case "Break":
breaks[4] = item.Count;
break;
case "Lunch":
lunch[4] = item.Count;
break;
}
break;
}
}
}
}
<body>
<div class="k-chart">
@(Html.Kendo().Chart<TcStatusChartData>()
.Name("chart")
.Title("Agents by status")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Bar().Stack(ChartStackType.Normal)
)
.Series(series =>
{
series.Column(new double[] { clockins[0], clockins[1], clockins[2], clockins[3], clockins[4] }).Stack(ChartStackType.Normal).Name("Clocked In");
series.Column(new double[] { breaks[0], breaks[1], breaks[2], breaks[3], breaks[4] }).Stack(ChartStackType.Normal).Name("On Break");
series.Column(new double[] { lunch[0], lunch[1], lunch[2], lunch[3], lunch[4] }).Stack(ChartStackType.Normal).Name("On Lunch");
}).SeriesColors("#33FF33", "#CCFF33", "#FF9933")
.CategoryAxis(axis => axis
.Categories("Mabel", "Harp", "Pendleton", "Granite", "HQ")
.MajorGridLines(lines => lines.Visible(false))
)
.ValueAxis(axis => axis
.Numeric()
.Labels(labels => labels.Format("{0}"))
.Max(100)
.Line(line => line.Visible(false))
.MajorGridLines(lines => lines.Visible(true))
).DataSource(datasource => datasource
.SignalR().AutoSync(true)
.Transport(tr => tr.Promise("hubPromise")
.Hub("hub")
.Server(server => server
.Read("chart_Read")
.Update("update")
.Destroy("desstroy")
.Create("create")))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= value #")
)
)
</div>
</body>
Code for chart:
<script>
var connection = $.hubConnection();
var hub = connection.createHubProxy("centralHub");
connection.logging = true;
var hubPromise = connection.start();
</script>
@{
double[] clockins = new double[5];
double[] breaks = new double[5];
double[] lunch = new double[5];
if (Model != null)
{
foreach (var item in Model)
{
switch (item.SiteName)
{
case "Mabel":
switch (item.TypeName)
{
case "ClockIn":
clockins[0] = item.Count;
break;
case "Break":
breaks[0] = item.Count;
break;
case "Lunch":
lunch[0] = item.Count;
break;
}
break;
case "Harp":
switch (item.TypeName)
{
case "ClockIn":
clockins[1] = item.Count;
break;
case "Break":
breaks[1] = item.Count;
break;
case "Lunch":
lunch[1] = item.Count;
break;
}
break;
case "Pendleton":
switch (item.TypeName)
{
case "ClockIn":
clockins[2] = item.Count;
break;
case "Break":
breaks[2] = item.Count;
break;
case "Lunch":
lunch[2] = item.Count;
break;
}
break;
case "Granite":
switch (item.TypeName)
{
case "ClockIn":
clockins[3] = item.Count;
break;
case "Break":
breaks[3] = item.Count;
break;
case "Lunch":
lunch[3] = item.Count;
break;
}
break;
case "HQ":
switch (item.TypeName)
{
case "ClockIn":
clockins[4] = item.Count;
break;
case "Break":
breaks[4] = item.Count;
break;
case "Lunch":
lunch[4] = item.Count;
break;
}
break;
}
}
}
}
<body>
<div class="k-chart">
@(Html.Kendo().Chart<TcStatusChartData>()
.Name("chart")
.Title("Agents by status")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Bar().Stack(ChartStackType.Normal)
)
.Series(series =>
{
series.Column(new double[] { clockins[0], clockins[1], clockins[2], clockins[3], clockins[4] }).Stack(ChartStackType.Normal).Name("Clocked In");
series.Column(new double[] { breaks[0], breaks[1], breaks[2], breaks[3], breaks[4] }).Stack(ChartStackType.Normal).Name("On Break");
series.Column(new double[] { lunch[0], lunch[1], lunch[2], lunch[3], lunch[4] }).Stack(ChartStackType.Normal).Name("On Lunch");
}).SeriesColors("#33FF33", "#CCFF33", "#FF9933")
.CategoryAxis(axis => axis
.Categories("Mabel", "Harp", "Pendleton", "Granite", "HQ")
.MajorGridLines(lines => lines.Visible(false))
)
.ValueAxis(axis => axis
.Numeric()
.Labels(labels => labels.Format("{0}"))
.Max(100)
.Line(line => line.Visible(false))
.MajorGridLines(lines => lines.Visible(true))
).DataSource(datasource => datasource
.SignalR().AutoSync(true)
.Transport(tr => tr.Promise("hubPromise")
.Hub("hub")
.Server(server => server
.Read("chart_Read")
.Update("update")
.Destroy("desstroy")
.Create("create")))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= value #")
)
)
</div>
</body>