给线性仪表自定义标签
Give a Linear Gauge custom labels
我有一个这样定义的 kendo 线性仪表...
$("#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"
}
]
}
});
这会产生一个看起来像这样的仪表...
我想要做的是用 "Unverified"、"Verified"、"Open" 等字符串值替换数字标签,这样我最终得到的结果更类似于此。 ..
我相当有信心我应该能够使用模板来做到这一点,但我连最简单的示例都无法获得(包括下面显示的示例telerik 网站)开始工作。
$("#linear-gauge").kendoLinearGauge({
scale: {
labels: {
// labels template
template: "#= value #%"
}
}
});
谁能提供一些建议?
创建模板函数
template: function (rec) {
var label;
switch (rec.value) {
case 0:
label = 'un verified';
break;
case 1:
label = 'verified';
break;
default:
label = 'open';
}
return label;
}
我有一个这样定义的 kendo 线性仪表...
$("#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"
}
]
}
});
这会产生一个看起来像这样的仪表...
我想要做的是用 "Unverified"、"Verified"、"Open" 等字符串值替换数字标签,这样我最终得到的结果更类似于此。 ..
我相当有信心我应该能够使用模板来做到这一点,但我连最简单的示例都无法获得(包括下面显示的示例telerik 网站)开始工作。
$("#linear-gauge").kendoLinearGauge({
scale: {
labels: {
// labels template
template: "#= value #%"
}
}
});
谁能提供一些建议?
创建模板函数
template: function (rec) {
var label;
switch (rec.value) {
case 0:
label = 'un verified';
break;
case 1:
label = 'verified';
break;
default:
label = 'open';
}
return label;
}