我在UI5中开发了一个堆积的条形图。

PCIpad's Portrait方向上都可以正常工作。但是,当涉及到Ipad's landscape方向时,图表会变小,并且会显示一个滚动条以访问位于图表底部的条。我不确定为什么堆积的条形图不能动态调整条形的高度。(如图所示)

javascript - UI5-如何调整堆积条形图中的条形高度-LMLPHP

我的看法 :

<f:SimpleForm editable="true" layout="ResponsiveGridLayout"
id="OEEform" class="formTitleStyle" labelSpanL="6"
labelSpanM="6" adjustLabelSpan="false" emptySpanL="0"
emptySpanM="0" columnsL="2" columnsM="2">
<f:content>

<Label id="idPerformance" visible="true" text="Performance">
    <layoutData>
        <l:GridData span="L5 M5 S5" />
    </layoutData>
</Label>
<ProgressIndicator id="idPerformancePI" class="sapUiSmallMarginBottom"
    percentValue="0" showValue="true" state="None"
    displayValue="0%" width="100%" />

<Label id="idAvailability" visible="true" text="Availability">
    <layoutData>
        <l:GridData span="L5 M5 S5" />
    </layoutData>
</Label>
<ProgressIndicator id="idAvailabilityPI"
    class="sapUiSmallMarginBottom" percentValue="0"
    displayValue="0%" showValue="true" state="None" width="100%" />

<core:Title />

<Label id="idQuality" visible="true" text="Quality">
    <layoutData>
        <l:GridData span="L5 M5 S5" />
    </layoutData>
</Label>
<ProgressIndicator id="idQualityPI" class="sapUiSmallMarginBottom"
    percentValue="0" displayValue="0%" showValue="true"
    state="None" width="100%" />

<Label id="idOEE" visible="true" text="OEE">
    <layoutData>
        <l:GridData span="L5 M5 S5" />
    </layoutData>
</Label>
<ProgressIndicator id="idOEEPI" class="sapUiSmallMarginBottom"
    percentValue="0" displayValue="0%" showValue="true"
    state="None" width="100%" />


</f:content>
        </f:SimpleForm>


    <viz:Popover id="idPopOver"></viz:Popover>
    <viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
         width='100%' vizType='stacked_bar'>
        <viz:dataset>
<viz.data:FlattenedDataset
    data="{/Rowsets/Rowset/0/Row}">
    <viz.data:dimensions>
        <viz.data:DimensionDefinition
name="Title" value="{Title}" />
        <!-- <viz.data:DimensionDefinition name="Staco" value="{Staco}"
/> -->
        <viz.data:DimensionDefinition
name="Status" value="{Status}" />
        <!-- <viz.data:DimensionDefinition name="Fat Percentage"
value="{Fat Percentage}" /> -->
    </viz.data:dimensions>
    <viz.data:measures>
        <viz.data:MeasureDefinition
name="Hours" value="{Hours}" />
    </viz.data:measures>
</viz.data:FlattenedDataset>
        </viz:dataset>
        <viz:feeds>
<viz.feeds:FeedItem uid="valueAxis"
    type="Measure" values="Hours" />
<viz.feeds:FeedItem uid="categoryAxis"
    type="Dimension" values="Title" />
<viz.feeds:FeedItem uid="color" type="Dimension"
    values="Status" />
<!-- <viz.feeds:FeedItem uid="color" type="Dimension" values="Fat
    Percentage" />
<viz.feeds:FeedItem uid="waterfallType"
    type="Dimension" values="Type" /> -->
        </viz:feeds>
    </viz:VizFrame>


现在只有一种方法,当方向为横向时,我需要显着降低钢筋的高度。

我在控制器中添加了以下代码(请参见注释),在其中向图表分配属性,但是不知何故它没有设置高度。

   oVizFrame.setVizProperties({

    valueAxis : {
        title : {
            visible : true
        }
    },

    categoryAxis : {
        title : {
            visible : false
        },
        label:{
            visible:false
        }
    },


    legend: {
     title: {
         visible: false
     },
     label: {
         text: {
               positiveValue: "Hours"
         }
     }
    },

    plotArea:{
     dataLabel:{
    renderer: function(oParam){

     //alert(oParam.dataPointWidth + " -- " + oParam.ctx["Status"]);

    if(oParam.dataPointWidth > 300)
    {
        oParam.text = oParam.ctx["Status"] + " (" + oParam.val + ")";
    }
// Below code is not setting the height of the bar
    if (sap.ui.Device.orientation.landscape === true){
        oParam.dataPointHeight = 10;
    }
     },
     visible : true
     },
    dataPointStyle:{  //Allows to set color,legend and data label based on rules defined.
    'rules':[


我究竟做错了什么?还有其他方法可以调整条形图中条形的高度吗?

最佳答案

如果尝试以下操作,会发生什么:

            oVizFrame.setVizProperties({
...
                           plotArea: {
                                 dataPointSize: {
                                       max: 400,
                                       min: 5
                            }


另请参见plotArea.dataPointSize.min中相应的文档

Stacked Bar Chart



Chart Property Reference / Overview

如果您有很多条,它们可能会收缩太多而变得难以阅读。
在这种情况下,仍可能需要滚动条。

07-24 09:50
查看更多