Creating donut charts
About this task
- Card title
- A unique label or heading assigned to the card.
- Legend
- The label of the data group.
- Label
- The percentage value of the whole for an individual category, for example,
24%
or76%
. - Big number label
- The text that appears after the total count in the center of the donut chart, for example,
25 Shipments
. - Card tooltip
- A tooltip that provides extra details about the data that is displayed on the card.
- Footer link
- A clickable field or link with a label, for example,
View all
.
Procedure
On the General tab, define the card:
On the Data tab, add data to the card:
On the Style tab, define the style of the card:
Example
The following query retrieves the total number of inbound shipments that were delivered and the
total number of shipments that were delivered late. The query includes a tenantId
variable.
query estimatedLateDelivery($tenantId: String!, $customerFilter: BooleanExp = {CONSTANT_VALUE: true}, $supplierFilter: BooleanExp = {CONSTANT_VALUE: true}, $carrierFilter: BooleanExp = {CONSTANT_VALUE: true}, $originFilter: BooleanExp = {CONSTANT_VALUE: true}, $destinationFilter: BooleanExp = {CONSTANT_VALUE: true}) {
late: businessObjects(
simpleFilter: {tenantId: $tenantId, type: Shipment}
advancedFilter: {AND: [{EQUALS: [{SELECT: "shipmentType", type: STRING}, {VALUE: "INBOUND", type: STRING}]}, {GREATER_THAN: [{SELECT: "estimatedDeliveryDelay", type: FLOAT}, {VALUE: "0.0", type: FLOAT}]}, {NOT: {EQUALS: [{SELECT: "statusByDate", type: STRING}, {VALUE: "DELIVERED", type: STRING}]}}, $customerFilter, $supplierFilter, $carrierFilter, $originFilter, $destinationFilter]}
hint: {viewId: "graph"}
cursorParams: {first: 0}
) {
totalCount
}
totalShipments: businessObjects(
simpleFilter: {tenantId: $tenantId, type: Shipment}
advancedFilter: {AND: [{EQUALS: [{SELECT: "shipmentType", type: STRING}, {VALUE: "INBOUND", type: STRING}]}, {NOT: {EQUALS: [{SELECT: "statusByDate", type: STRING}, {VALUE: "DELIVERED", type: STRING}]}}, $customerFilter, $supplierFilter, $carrierFilter, $originFilter, $destinationFilter]}
hint: {viewId: "graph"}
cursorParams: {first: 0}
) {
totalCount
}
}
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. In the example, two shipments are late out of a total of eight shipments.
{
"data": {
"late": {
"totalCount": 2,
"__typename": "BusinessObjectsCursor"
},
"totalShipments": {
"totalCount": 8,
"__typename": "BusinessObjectsCursor"
}
},
"loading": false,
"networkStatus": 7
}
In the following code, COMMON.SHIPMENT_STATUS.ON_TIME
is added as a group. The
on-time shipments are calculated in the transform by subtracting the late shipments from the total
shipments.
{
"legendOrder": [
"COMMON.SHIPMENT_STATUS.ON_TIME",
"COMMON.SHIPMENT_STATUS.LATE"
],
"colorScale": {
"COMMON.SHIPMENT_STATUS.ON_TIME": "#009d9a",
"COMMON.SHIPMENT_STATUS.LATE": "#6929c4"
},
"totalCount": [
"{{this.data.totalShipments.totalCount}}"
],
"errors": "{{#? this.errors}}",
"pageInfo": "{}",
"results": [
{
"group": "COMMON.SHIPMENT_STATUS.LATE",
"value": "{{this.data.late.totalCount}}"
},
{
"group": "COMMON.SHIPMENT_STATUS.ON_TIME",
"value": "{{this.data.totalShipments.totalCount - this.data.late.totalCount}}"
}
]
}
In a transformation, the data that is displayed on the chart must match the data that is returned by the query. You can add any calculation on the data that the query returns.
What to do next
Add the card to a page by using the Page builder.