Javascript 是否可以在Kendo UI线性仪表上仅显示最大/最小值?
我现在有一个线性仪表,看起来像这样:Javascript 是否可以在Kendo UI线性仪表上仅显示最大/最小值?,javascript,css,kendo-ui,Javascript,Css,Kendo Ui,我现在有一个线性仪表,看起来像这样: $("#depthBar-" + conveyanceId).kendoLinearGauge({ pointer: { value: 0, shape: "arrow", color: "transparent", start: 0, reverse: true }, scale: { majorUnit: 500, mi
$("#depthBar-" + conveyanceId).kendoLinearGauge({
pointer: {
value: 0,
shape: "arrow",
color: "transparent",
start: 0,
reverse: true
},
scale: {
majorUnit: 500,
minorUnit: 100,
min: -2000,
max: 2000,
vertical: false,
reverse: false,
ranges: [
{
from: -2000, // LimitLo
to: -1500,
color: "#ffc700"
},
{
from: 2000, // LimitHi
to: 1500,
color: "#ffc700"
}, {
from: 2000, // LimitHiHi
to: 1800,
color: "#c20000"
}, {
from: -5000,
to: -1800,
color: "#c20000" // LimitLoLo
}, {
from: 0,
to: 286,
color: "lightblue"
}
]
}
});
是否可以让条形图仅显示最大和最小标签,而不显示介于两者之间的标签?在这种情况下,我希望它只在刻度的一端显示“-2000”,在另一端显示“2000”。好的,您可以将刻度标签上的模板设置为函数,进行一些计算,然后只返回所需的标签
labels: {
// labels template
template: getLabel
}
及
看起来有点古怪,也许有更好的方法,但这应该能满足你的需求。(示例)设置模板会很好。通常,当我需要这样做时,我会计算最大值和最小值之间的差值,并通过参数或仪表创建计算将其设置为主要单位。设置值,如
谢谢你D现在我只需尝试使其动态,以适应我的所有仪表(其中5个):)
function getLabel(e) {
if(e.value === 2000) {
return 2000;
}
else if(e.value === -2000) {
return -2000;
}
else {
return '';
}
}
$("#gauge").kendoRadialGauge({
pointer: {
value: $("#gauge-value").val()
},
scale: {
majorUnit:180,
minorUnit: 5,
startAngle: -30,
endAngle: 210,
max: 180
}
});
}