显示电流值在经典圆形线规使用道场

Display current value in the Classic Circular Linear Gauge using dojo

本文关键字:经典 显示      更新时间:2023-09-26

是否可以像默认的圆形线规那样在经典的圆形线规中显示当前值?

谢谢。

将test_Classic_CircularLinearGauge.html中的脚本标签改为:

<script type="text/javascript">
    require(["dojo/_base/kernel","dojo/parser","dijit/layout/BorderContainer",
            "dijit/layout/ContentPane",
            "dojox/dgauges/components/classic/CircularLinearGauge"]);
</script>

:

<script type="text/javascript">
    require(["dojo/_base/kernel","dojo/parser","dijit/layout/BorderContainer",
            "dijit/layout/ContentPane",
            "dojox/dgauges/components/classic/CircularLinearGauge"]);
    // ADD THE CURRENT VALUE TO INDICATOR
    require(["dojo/ready","dijit","dojox/dgauges/TextIndicator"],function(
            ready,dijit,TextIndicator){
        ready(function(){
            var gauge=dijit.registry.byId("g1"); // ADAPT THIS TO YOUR GAUGE ID
            indicator=gauge._elementsIndex.scale._indicators[0];
            var indicatorText=new TextIndicator();
            indicatorText.set("indicator",indicator);
            indicatorText.set("x",80);
            indicatorText.set("y",150);
            gauge.addElement("indicatorText",indicatorText);
        });
    });
</script>

有点脏,有点硬。一个更好的方法是在CircularLinearGauge之外创建你自己的类,并在构造函数中添加TextIndicator…