-1
The value of the Y series is given in seconds, but I need to present in the tooltip in minutes:seconds. Example: Value in seconds= 320. Value to be displayed in tooltip= 05:20.
I made a script to change the format, calculating the quotient and rest, turning to string and passing to tooptip, but the result is always Nan. How could I format this value to display on tooltip Os 05:20?
My application is c# with MVC standard. Charts are rendered by Highcharts.
@{var chartOptions4 = new Highcharts
{
Title = new Title
{
Text = "Setting Time"
},
XAxis = new List<XAxis>
{
new XAxis
{
Categories = ViewData["datas_saida_resf_prod"] as List<string>
}
},
YAxis = new List<YAxis>
{
new YAxis
{
Labels = new YAxisLabels
{
Formatter = "formatYAxis1"
}
}
},
Tooltip = new Tooltip
{
HeaderFormat = "<b>{point.x}</b><br>",
PointFormatter = "formatToolTip"
},
Series = new List<Series>
{
new LineSeries
{
Name = "Normal T.I.",
Data = @ViewData["lista_normalTI"] as List<LineSeriesData>
},
new LineSeries
{
Name = "Normal T.F.",
Data = @ViewData["lista_normalTF"] as List<LineSeriesData>
},
new LineSeries
{
Name = "Moído T.I.",
Data = @ViewData["lista_moidoTI"] as List<LineSeriesData>
},
new LineSeries
{
Name = "Moído T.F.",
Data = @ViewData["lista_moidoTF"] as List<LineSeriesData>
}
}
};
chartOptions4.ID = "chart4";
var renderer4 = new HighchartsRenderer(chartOptions4);
}
@Html.Raw(renderer4.RenderHtml())
Script:
function formatToolTip() {
var quociente, resto;
quociente = Math.floor((this.value / 60), 0);
resto = Math.round(((this.value / 60) - quociente) * 60);
var valor = (Math.floor((this.value / 60), 0)).toString() + ":" + (Math.round(((this.value / 60) - quociente) * 60)).toString();
var result = this.series.name + ':' + valor;
return result;
}
Why don’t you already pass this formatted information? your question is about javascript or C#?
– Leandro Angelo
Because, as far as I know, Lineseriesdata only accepts the double value.
– Ana Paula
So I thought of formatting in javascript itself
– Ana Paula