Charts are a type of Insight that can be added to any sidebar widget using metadata configuration.
This configuration can be added to the listviewdefs
or detaiviewdefs
of the module you want to add it to.
At the moment there are only 3 chart types available to use:
-
horizontal-bar
-
pie-grid
-
vertical-bar
Other chart types will be added in the future. It is also possible to implement your own custom char type. Towards the end of this page you’ll find documentation on it.
The following code snippet takes an example from the Accounts module listviewdefs
configuration.
For more examples of configurations you can look at:
-
public/legacy/modules/Accounts/metadata/listviewdefs.php
-
public/legacy/modules/Accounts/metadata/detailviewdefs.php
-
public/legacy/modules/Leads/metadata/listviewdefs.php
-
public/legacy/modules/Opportunities/metadata/listviewdefs.php
<?php
...
$viewdefs['Opportunities'] = [
'ListView' => [
'sidebarWidgets' => [
'opportunities-by-sales-stage-price' => [
'type' => 'chart',
'labelKey' => 'LBL_QUICK_CHARTS',
'options' => [
'toggle' => true,
'headerTitle' => false,
'charts' => [
[
'chartKey' => 'opportunities-by-sales-stage-price',
'chartType' => 'horizontal-bar',
'statisticsType' => 'opportunities-by-sales-stage-price',
'labelKey' => 'PIPELINE_BY_SALES_STAGE',
'chartOptions' => [
]
]
]
],
'acls' => [
'Opportunities' => ['view', 'list']
]
]
]
]
];
...
From the example above we can see that charts have different options when configuring. Within the options
array, we can
see that it then displays toggle
, this is to show the dropdown with the name of the chart and also allow changing
between charts.
You may also see within the options
array there is another array called charts
. Within this array there is; chartKey
,
chartType
, statisticsType
, labelKey
and chartOptions
.
Some of these are simple in meaning. chartKey
is just the name given to the chart to make it individual, 'chartType' is
they type of chart you would like to display. Some other options for this would include: pie-grid-chart, line-chart, vertical-bar-chart
and base-chart. labelKey
is also just the label shown within the chart.
The statisticsType
option, this is how each chart gets it’s data, you are able to see each statistic file within the
core/modules/<module>
directory, this key links to a specific service within the statistics API.