Creating grouped bar charts
The grouped bar chart is used to display values across multiple categories at a time.
Data groups can be plotted in the form of grouped bars with equal widths and variable heights
representing the magnitude of the quantity. Grouped bar charts can be used to visualize the rate of
change of a quantity for multiple categories against pre-defined targets based on the statistical
figure.
About this task
- Card title
- A unique label or heading that is 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 that is 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 the
tenantId
variable.
For a grouped 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": 289,
"aggregationResults": [
{
"dimensionValues": [
{
"name": "order.vendor.name",
"value": "",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 167457072,
"__typename": "NameValueNumValuePair"
}
],
"__typename": "AggregationResult"
},
{
"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": 153200,
"__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": "SJN Fuels",
"__typename": "NameValuePair"
}
],
"values": [
{
"name": "totalOrderLinesBySupplier",
"numValue": 9518,
"__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": "NDgzMzA0NA==",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "NDgzMzE3NA==",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "NDgzNDQ2Nw==",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "NDgzNDQyNw==",
"object": {
"valueCurrency": "USD",
"__typename": "OrderLine"
},
"__typename": "BusinessObjectEdge"
},
{
"cursor": "NDgzNDM5OQ==",
"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 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 orderline"
}
}
}
What to do next
Add the card to a page by using the Page builder.