Creating pie charts
A pie chart card displays data in data groups that can be plotted as a circle that is
divided into sectors that each represent a proportion of the whole. You can use pie visualizations
to show the proportions of categorical data.
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.
- Labels
- The percentage value of the whole for an individual category, for example,
24%
or76%
. - 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
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.