Creating stacked bar charts
The stacked bar chart can be used to plot the relative value that each data series
contributes to the total, and is useful for comparing proportional contributions within a
category.
About this task
- Card title
- A unique label or heading assigned to the card.
- Card tooltip
- A tooltip provides extra details about the data that is displayed on the card.
- Threshold
- A line on the chart above or below which are significant values.
- Y-axis title
- A label assigned to the vertical axis of the chart.
- X-axis title
- A label assigned to the horizontal axis of the chart.
- Legend
- The label of the data group.
- Footer link
- A clickable field or link with a label, for example,
View all
.
Procedure
Example
The following query retrieves the past due borderline by supplier. The query includes
tenantId
variable.
For a stacked bar chart, any attribute that is returned by a query can be displayed.
query pastDueOrderlineBySupplier($tenantId: String!) {
pastDueOrderLineBySupplierChar: businessObjects(
simpleFilter: {type: OrderLine, tenantId: $tenantId}
hint: {viewId: "graph"}
advancedFilter: {AND: [{GREATER_THAN: [{SELECT: "order.plannedDeliveryDelay", type: FLOAT}, {VALUE: "0.0", type: FLOAT}]}, {EQUALS: [{SELECT: "order.orderType", type: STRING}, {VALUE: "INBOUND", type: STRING}]}]}
aggregationParams: {paginationParams: {first: 50, sort: [{fieldPath: "totalOrderLinesBySupplier.sum", order: DESC}]}, dimension: {fieldPath: "order.vendor.name", type: STRING}, reduce: {expression: {fieldPath: "value", operator: SUM, type: INT}, output: {resultAlias: "totalOrderLinesBySupplier", type: INT}}}
) {
totalCount
aggregationResults {
dimensionValues {
name
value
}
values {
name
numValue
}
}
edges {
cursor
object {
... on OrderLine {
valueCurrency
}
}
}
}
}
The following code is an example of how to define the variables to use in the query:
{
"tenantId": "{{ tenantId }}"
}
The following code is an example of the data that is returned by the query:
{
"data": {
"pastDueOrderLineBySupplierChar": {
"totalCount": 19,
"aggregationResults": [
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "McGrey Electrical",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 604160,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "Total Source Extrusion Corporation",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 226800,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "F & M Metals",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 125900,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "LightLens Industries",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 107920,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "Alumi-lux Metal Products",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 59605,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "Gemini Design Technology",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 39040,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "Amos Wire Products Inc",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 28160,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "SilverOptics",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 13392,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "Interalloy Corporation",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 744,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
}
],
"edges": [
{
"cursor": "MTYyOTc4OTM=",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "MTYyOTc5MDc=",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "MTYyOTc5MTk=",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "MTYyOTc5Njk=",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "MTYyOTgwNTQ=",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
}
],
"__typename": "BusinessObjectsCursor"
}
},
"loading": false,
"networkStatus": 7
}
The following code is an example of the transformation that is applied to the data. The attribute that is shown must match what is returned from the data. This attribute is chosen in the data groups section. Any calculation can be done on the data that is returned.
{
"errors": "{{ #? this.errors }}",
"totalCount": "{{ this.data.pastDueOrderLineBySupplierChar.totalCount }}",
"pageInfo": {},
"results": {
"{{ #each this.data.pastDueOrderLineBySupplierChar.aggregationResults }}": {
"group": "{{this.dimensionValues[0].value}}",
"value": "{{this.values[0].numValue}}",
"key": "Past due order"
}
}
}
What to do next
Add the card to a page by using the Page builder.