在SAPUI5 VizFrame的柱状图中设置图例标题,可以通过以下步骤实现:
var oVizFrame = new sap.viz.ui5.controls.VizFrame();
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
name: "Category",
value: "{Category}"
}],
measures: [{
name: "Value",
value: "{Value}"
}],
data: {
path: "/data"
}
});
oVizFrame.setDataset(oDataset);
var oDimensionAxis = new sap.viz.ui5.types.Axis({
title: {
visible: true,
text: "Category"
}
});
var oMeasureAxis = new sap.viz.ui5.types.Axis({
title: {
visible: true,
text: "Value"
}
});
var oLegend = new sap.viz.ui5.types.Legend({
title: {
visible: true,
text: "Legend"
}
});
var oChartConfig = new sap.viz.ui5.types.Bar({
categoryAxis: oDimensionAxis,
valueAxis: oMeasureAxis,
legend: oLegend
});
oVizFrame.setVizType("bar");
oVizFrame.setVizProperties(oChartConfig);
完整的代码示例:
var oVizFrame = new sap.viz.ui5.controls.VizFrame();
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
name: "Category",
value: "{Category}"
}],
measures: [{
name: "Value",
value: "{Value}"
}],
data: {
path: "/data"
}
});
oVizFrame.setDataset(oDataset);
var oDimensionAxis = new sap.viz.ui5.types.Axis({
title: {
visible: true,
text: "Category"
}
});
var oMeasureAxis = new sap.viz.ui5.types.Axis({
title: {
visible: true,
text: "Value"
}
});
var oLegend = new sap.viz.ui5.types.Legend({
title: {
visible: true,
text: "Legend"
}
});
var oChartConfig = new sap.viz.ui5.types.Bar({
categoryAxis: oDimensionAxis,
valueAxis: oMeasureAxis,
legend: oLegend
});
oVizFrame.setVizType("bar");
oVizFrame.setVizProperties(oChartConfig);
以上代码将在SAPUI5 VizFrame中创建一个柱状图,并设置了图例标题为"Legend"。你可以根据实际需求修改标题内容和其他配置项。
领取专属 10元无门槛券
手把手带您无忧上云