I am currently utilizing a kendo chart with a date x-axis. Each point on the graph corresponds to different dates, but the x-axis displays only a monthly view. To showcase the last data point for each month, I have implemented a custom aggregate function as follows:
Data points include:
Jan 01 2014 - $1500 Jan 03 2014 - $2000 Jan 10 2014 - $75
The graph displays: Jan 2014 - $75
When hovering over these points, I want to display a customized tooltip with specific values related to each data point. The tooltip content is generated by my business logic and it’s not necessary to discuss here. If we consider the example values above, the desired tooltips are:
Jan 01 2014 - $100 Jan 03 2014 - $200 Jan 10 2014 - $300
However, when hovering over the aggregated point for the current month, the tooltip should ideally show the value 'C' due to the previous aggregate function. Yet, the displayed value is:
Jan 2014 - '$100'
My inquiry is: Is there a method to specify a customized aggregate function for the kendo tooltip?
The code snippet for the chart is presented below:
public class MyModel{
public DateTime Date {get; set;}
public double ShownValue {get; set;}
public double ToolTipValue {get; set;}
}
@(Html.Kendo().Chart(List<MyModel>)
.Name("myChart")
.DataSource(dataSource => dataSource
.Sort(s => s.Add(fc => fc.Date))
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Line().Style(ChartLineStyle.Smooth)
)
.Series(series =>
{
series.Line(value => value.ShownValue, category => category.Date)
.Aggregate("selectLastPoint");
})
.CategoryAxis(axis => axis
.Labels(labels => labels.Rotation(0).Format("MMM 'yy"))
.Date()
.BaseUnit(ChartAxisBaseUnit.Months)
.Justify(false)
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels.Format("{0:c}"))
)
.Tooltip(t => t
.Visible(true)
.Format("{0:c}")
.Template("#= kendo.format('{0:C}',dataItem.TooltipValue) #")
))
The aforementioned aggregate function's code is provided below:
function selectLastPoint(values) {
return values[values.length - 1];
}
I would greatly appreciate any assistance. Warm regards, Luis.