Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
380 views
in Technique[技术] by (71.8m points)

javascript - 如何在剑道图Y轴上显示时间格式(HH.MM.SS)(How to show time format(HH.MM.SS) in Kendo chart Y-axis)

I have following JSON format,

(我有以下JSON格式,)

[{ day: "YYY", avgSecond:  "100", waitSecond: "125"}, {day: "XXX", avgSecond:  "145", waitSecond: "117"} ,{day: "TTT", avgSecond:  "565", waitSecond: "340"},{day: "SSS", avgSecond:  "125", waitSecond: "250"}];

I need to show this data in kendo chart as, avgSecond and waitSecond in HH.MM.SS format in chart Y-axis and day in X-axis , My code as follows,

(我需要在avgSecond图表中以avgSecondwaitSecond的形式在waitSecond图表中显示此数据,在图表Y轴中以HH.MM.SS格式显示,在X-axis day ,我的代码如下,)

<div id="AvgChart"></div>

var seriesData = [{
    day: "YYY",
    second: "100",
    age: "125"
}, {
    day: "XXX",
    second: "145",
    age: "117"
}, {
    day: "TTT",
    second: "565",
    age: "340"
}, {
    day: "SSS",
    second: "125",
    age: "250"
}];

$("#AvgChart").kendoChart({
    title: {
        text: "Show Time in Seconds"
    },
    legend: {
        position: "bottom"
    },
    seriesDefaults: {
        labels: {
            visible: false
        }
    },
    series: [{
        name: "Averagetime",
        type: "line",
        color: "Blue",
        data: seriesData,
        field: "second",
        labels: {
            template: "#:convertTime(value)#"
        }
    }, {
        name: "WaitTime",
        type: "bar",
        color: "#ff0000",
        data: seriesData,
        field: "age",
        labels: {
            template: "#:convertTime(value)#"
        }
    }],    
    tooltip: {
        labels: {
            template: "#:convertTime(value)#"
        },
        visible: true,
    }
});


function convertTime(sec) {
    var hours = Math.floor(sec / 3600);
    (hours >= 1) ? sec = sec - (hours * 3600): hours = '00';
    var min = Math.floor(sec / 60);
    (min >= 1) ? sec = sec - (min * 60): min = '00';
    (sec < 1) ? sec = '00': void 0;

    (min.toString().length == 1) ? min = '0' + min: void 0;
    (sec.toString().length == 1) ? sec = '0' + sec: void 0;

    return hours + ':' + min + ':' + sec;
}

But Now problem Is I need to generate chart Y-axis in order to data, How can I do it, I found this Kendo dogo example : http://dojo.telerik.com/@tsvetomir/uvORE .

(但是现在的问题是,我需要生成图表Y轴以获取数据,我该怎么做呢,我发现了这个Kendo dogo示例: http : //dojo.telerik.com/@tsvetomir/uvORE 。)

How can I show time format in Y-Axis

(如何在Y轴上显示时间格式)

  ask by Adam translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...