Javascript SAP UI5中的仪表/刻度盘

Javascript SAP UI5中的仪表/刻度盘,javascript,sapui5,gauge,Javascript,Sapui5,Gauge,我有一个要求,即我需要在显示温度传感器数据的页面中显示仪表/刻度盘-范围从-100到200 C。我研究发现,SAP UI5只有一个仪表(径向微曲线)以显示百分比值,因此它仅显示0到100 <!-- Row-1 --> <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin"> <content>

我有一个要求,即我需要在显示温度传感器数据的页面中显示仪表/刻度盘-范围从-100到200 C。我研究发现,SAP UI5只有一个仪表(径向微曲线)以显示百分比值,因此它仅显示0到100

        <!-- Row-1 -->
        <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
            <content>
                <HBox>
                    <Panel id="idPanel" height="300px" width="700px">
                        <content>
                            <HBox>
                                <FlexBox id="idSensor1" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Flow" class="donutDescription" align="Center" />
                                            <micro:RadialMicroChart id="idGaugeSensor1"
                                                percentage="50" total="50">
                                            </micro:RadialMicroChart>


                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>
                                            <Label text="UOM: L/s" class="donutDescription" align="Center" />

                                        </VBox>

                                    </items>
                                </FlexBox>
                                <FlexBox height="100px" width="100px">
                                    <items>

                                        <Label text="" />



                                    </items>
                                </FlexBox>
                                <FlexBox id="idSensor2" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Pressure" class="donutDescription" />
                                            <micro:RadialMicroChart id="idGaugeSensor2"
                                                percentage="125" total="125">
                                            </micro:RadialMicroChart>

                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>

                                        </VBox>

                                    </items>
                                </FlexBox>
                            </HBox>
                        </content>
                    </Panel>

                </HBox>
            </content>
        </Panel>


    </content>
</Page>
经过一些研究,我发现了以下链接:

        <!-- Row-1 -->
        <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
            <content>
                <HBox>
                    <Panel id="idPanel" height="300px" width="700px">
                        <content>
                            <HBox>
                                <FlexBox id="idSensor1" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Flow" class="donutDescription" align="Center" />
                                            <micro:RadialMicroChart id="idGaugeSensor1"
                                                percentage="50" total="50">
                                            </micro:RadialMicroChart>


                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>
                                            <Label text="UOM: L/s" class="donutDescription" align="Center" />

                                        </VBox>

                                    </items>
                                </FlexBox>
                                <FlexBox height="100px" width="100px">
                                    <items>

                                        <Label text="" />



                                    </items>
                                </FlexBox>
                                <FlexBox id="idSensor2" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Pressure" class="donutDescription" />
                                            <micro:RadialMicroChart id="idGaugeSensor2"
                                                percentage="125" total="125">
                                            </micro:RadialMicroChart>

                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>

                                        </VBox>

                                    </items>
                                </FlexBox>
                            </HBox>
                        </content>
                    </Panel>

                </HBox>
            </content>
        </Panel>


    </content>
</Page>

        <!-- Row-1 -->
        <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
            <content>
                <HBox>
                    <Panel id="idPanel" height="300px" width="700px">
                        <content>
                            <HBox>
                                <FlexBox id="idSensor1" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Flow" class="donutDescription" align="Center" />
                                            <micro:RadialMicroChart id="idGaugeSensor1"
                                                percentage="50" total="50">
                                            </micro:RadialMicroChart>


                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>
                                            <Label text="UOM: L/s" class="donutDescription" align="Center" />

                                        </VBox>

                                    </items>
                                </FlexBox>
                                <FlexBox height="100px" width="100px">
                                    <items>

                                        <Label text="" />



                                    </items>
                                </FlexBox>
                                <FlexBox id="idSensor2" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Pressure" class="donutDescription" />
                                            <micro:RadialMicroChart id="idGaugeSensor2"
                                                percentage="125" total="125">
                                            </micro:RadialMicroChart>

                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>

                                        </VBox>

                                    </items>
                                </FlexBox>
                            </HBox>
                        </content>
                    </Panel>

                </HBox>
            </content>
        </Panel>


    </content>
</Page>
在这里,作者创建了一个gauge.js文件,用于在页面中添加自定义拨号/仪表

        <!-- Row-1 -->
        <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
            <content>
                <HBox>
                    <Panel id="idPanel" height="300px" width="700px">
                        <content>
                            <HBox>
                                <FlexBox id="idSensor1" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Flow" class="donutDescription" align="Center" />
                                            <micro:RadialMicroChart id="idGaugeSensor1"
                                                percentage="50" total="50">
                                            </micro:RadialMicroChart>


                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>
                                            <Label text="UOM: L/s" class="donutDescription" align="Center" />

                                        </VBox>

                                    </items>
                                </FlexBox>
                                <FlexBox height="100px" width="100px">
                                    <items>

                                        <Label text="" />



                                    </items>
                                </FlexBox>
                                <FlexBox id="idSensor2" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Pressure" class="donutDescription" />
                                            <micro:RadialMicroChart id="idGaugeSensor2"
                                                percentage="125" total="125">
                                            </micro:RadialMicroChart>

                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>

                                        </VBox>

                                    </items>
                                </FlexBox>
                            </HBox>
                        </content>
                    </Panel>

                </HBox>
            </content>
        </Panel>


    </content>
</Page>
我遵循的步骤:

        <!-- Row-1 -->
        <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
            <content>
                <HBox>
                    <Panel id="idPanel" height="300px" width="700px">
                        <content>
                            <HBox>
                                <FlexBox id="idSensor1" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Flow" class="donutDescription" align="Center" />
                                            <micro:RadialMicroChart id="idGaugeSensor1"
                                                percentage="50" total="50">
                                            </micro:RadialMicroChart>


                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>
                                            <Label text="UOM: L/s" class="donutDescription" align="Center" />

                                        </VBox>

                                    </items>
                                </FlexBox>
                                <FlexBox height="100px" width="100px">
                                    <items>

                                        <Label text="" />



                                    </items>
                                </FlexBox>
                                <FlexBox id="idSensor2" height="100px" width="100%">
                                    <items>
                                        <VBox>
                                            <Label text="Pressure" class="donutDescription" />
                                            <micro:RadialMicroChart id="idGaugeSensor2"
                                                percentage="125" total="125">
                                            </micro:RadialMicroChart>

                                            <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                change="onChange">
                                            </Slider>

                                        </VBox>

                                    </items>
                                </FlexBox>
                            </HBox>
                        </content>
                    </Panel>

                </HBox>
            </content>
        </Panel>


    </content>
</Page>
  • 我在项目中添加了gauge.ds

  •         <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
  • 我在index.html中添加了以下内容:

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
  • 我的XML视图如下所示:

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    

  • 我无法理解或弄清楚应该在何处添加并调用gauge.js函数来创建dial/gauge,以便将其放置在我想要的位置?

    您引用的博客将引导您使用自定义库,该库通过将创建的仪表放置在容器元素中来使用。理想情况下,最佳实践是创建自定义控件并在XML视图中使用该控件

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    您可以将这些库作为外部资源添加到清单文件中,而不是在index.html中声明它们。您还需要包括仪表库要求的数据

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    "models": {
      .....
    },
    "resources": {
            "js":[
                {
                    "uri": "lib/d3.js"
                },
                {
                    "uri": "lib/gauge.js"
                }
            ]
    }
    
    在XML视图中,我们需要一个容器来放置仪表控件

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    <FlexBox
            width="95%"
            id="gaugeFlexBox"
            alignItems="Stretch">               
    </FlexBox>
    

    注意:这绝对不是一个好的做法,因为创建的仪表控件不是UI5控件。要使其成为UI5控件,您必须将其扩展为自定义控件。

    我能够通过上面@Stephen提到的方法实现它

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    我在index.html中添加了两个js文件

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    然后在我的控制器sap.ui.define中,我将路径添加到gauge.js

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    
    这样我就可以调用gauge.js函数了

            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>
    

    非常感谢

    感谢您提供详细信息,但如果我的项目没有清单文件,因为它只是一个单页的简单应用程序,该怎么办?您可以将其添加到组件声明元数据中:{name:“application”,version:“1.0”,包括:[“lib/gauge.js”,“lib/d3.js”],我不想在我的项目中包含外部依赖项。SAPUI5库中是否有gauge/tacho的替代方案?您可以使用jQuery.sap.require(“sap/ui/thirdparty/d3”);它将需要SAPUI5内部使用的d3库。然后,gauge将不需要外部库依赖项。UI5最接近的功能是
            <!-- Row-1 -->
            <Panel id="idRow1" height="350px" width="1500px" class="sapUiResponsiveMargin">
                <content>
                    <HBox>
                        <Panel id="idPanel" height="300px" width="700px">
                            <content>
                                <HBox>
                                    <FlexBox id="idSensor1" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Flow" class="donutDescription" align="Center" />
                                                <micro:RadialMicroChart id="idGaugeSensor1"
                                                    percentage="50" total="50">
                                                </micro:RadialMicroChart>
    
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor1" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
                                                <Label text="UOM: L/s" class="donutDescription" align="Center" />
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox height="100px" width="100px">
                                        <items>
    
                                            <Label text="" />
    
    
    
                                        </items>
                                    </FlexBox>
                                    <FlexBox id="idSensor2" height="100px" width="100%">
                                        <items>
                                            <VBox>
                                                <Label text="Pressure" class="donutDescription" />
                                                <micro:RadialMicroChart id="idGaugeSensor2"
                                                    percentage="125" total="125">
                                                </micro:RadialMicroChart>
    
                                                <Slider enableTickmarks="true" showAdvancedTooltip="true"
                                                    min="0" max="100" id="idInputSensor2" class="sapUiSmallMarginBottom"
                                                    change="onChange">
                                                </Slider>
    
                                            </VBox>
    
                                        </items>
                                    </FlexBox>
                                </HBox>
                            </content>
                        </Panel>
    
                    </HBox>
                </content>
            </Panel>
    
    
        </content>
    </Page>