使用dojo在Classic Circular Linear Gauge中显示当前值

时间:2013-04-02 19:15:57

标签: javascript jquery css dojo

是否可以在classic circular linear gauge中显示default circular linear gauge中的当前值?

谢谢。

1 个答案:

答案 0 :(得分:3)

更改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 ......