cancel
Showing results for 
Search instead for 
Did you mean: 

Bar chart with distinct count, Percent of total

Alonso
Explorer
0 Kudos
117

I have a bar chart with distinct count, i want to show percent of total, when i choose percentage it multiplies it by 100, is there a solution?

View Entire Topic
priteshpatel65
Active Participant
0 Kudos

Try this

 

var oVizFrame = new sap.viz.ui5.controls.VizFrame({
width: "100%",
height: "400px",
vizType: "bar", // You can use other chart types too
dataset: oDataset, // your dataset
feeds: [
new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "size",
'type': "Measure",
'values': ["YourMeasure"]
}),
new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "color",
'type': "Dimension",
'values': ["YourDimension"]
})
]
});

// Customizing percentage formatting for the labels
var oFormat = sap.ui.core.format.NumberFormat.getPercentInstance({
style: "short", // Short format (e.g., 50% instead of 0.5)
minimumFractionDigits: 1, // Adjust this based on your requirements
maximumFractionDigits: 2
});

// Set custom label formatter
oVizFrame.setVizProperties({
plotArea: {
dataLabel: {
visible: true,
format: {
value: function (value) {
// Don't multiply by 100, directly use the value as is
return oFormat.format(value);
}
}
}
}
});

// Place the VizFrame on your page or view
oVizFrame.placeAt("yourContainer");

Alonso
Explorer
0 Kudos
Thanks for the reply, didn't try that because it seemed to complicated for this (or meybe my level...). Found a workaround, used a crosstab and added an Embedded summary that divides by 100, and used the crosstab chart