给出线性规定制标签 [英] Give a Linear Gauge custom labels

查看:104
本文介绍了给出线性规定制标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样定义的剑道线性量规...

I have a kendo linear gauge defined like this...

$("#gauge").kendoLinearGauge({

    pointer: {
        value: 4.5,
        shape: "arrow"
    },

    scale: {
        majorUnit: 1,
        minorUnit: 1,
        max: 6,
        ranges: [
            {
                from: 0,
                to: 1,
                color: "#ffc700"
            }, {
                from: 1,
                to: 2,
                color: "#ff7a00"
            }, {
                from: 2,
                to: 3,
                color: "#c20000"
            }, {
                from: 3,
                to: 4,
                color: "#FF0000"
            }, {
                from: 4,
                to: 5,
                color: "#00FF00"
            }, {
                from: 5,
                to: 6,
                color: "#0000FF"
            }
        ]
    }
});

这会产生一个看起来像这样的量规...

And this produces a gauge that looks like this...

我要做的是将数字标签替换为字符串值,例如"Unverified","Verified","Open"等,这样我最终得到的内容类似于此...

What I want to do is replace the numeric labels with string values like "Unverified", "Verified", "Open", etc so that I end up with something more akin to this...

我非常有信心我应该能够使用模板来做到这一点,但是我什至无法获得最简单的示例(包括下面来自telerik网站上显示的示例)来工作.

I'm fairly confident that I should be able to do this using a template, but I can't get even the simplest of examples (including the one shown below from the telerik website) to work.

$("#linear-gauge").kendoLinearGauge({
     scale: {
         labels: {
             // labels template
             template: "#= value #%"
         }
     }
});

任何人都可以提供任何建议吗?

Can anyone offer any suggestions?

推荐答案

创建模板函数

template: function (rec) {
    var label;
    switch (rec.value) {
        case 0:
            label = 'un verified';
            break;
        case 1:
            label = 'verified';
            break;
        default:
            label = 'open';
    }
    return label;
}

http://dojo.telerik.com/@harsh/EgeVa

这篇关于给出线性规定制标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆