Download the PHP package brocode/module-chartee without Composer
On this page you can find all versions of the php package brocode/module-chartee. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brocode/module-chartee
More information about brocode/module-chartee
Files in brocode/module-chartee
Package module-chartee
Short Description Module to generate Graphs and Charts with chart.js
License MIT
Informations about the package module-chartee
Chartee - a Magento 2 chart-js module
This module should ease the way of creating powerful charts in Magento 2. It is based on the chart.js library (which itself is already used by Magento2 for its dashboard charts) and various extensions for additional chart types.
Goals of this module:
- Be independent of the version management of Magento and updates of its library dependencies (only the current 2.4.7-beta2 uses chart.js v4.4.0!) and use newer chart.js versions in older Magento2 installations
- Provide a simple way to create charts in Magento2 without much knowledge of the chart.js library itself
- Provide boilerplate codes to easily integrate any type of chart in various places within Magento
- Encourage everyone to create meaningful representations of data already available in Magento2, no stackholder would see otherwise as it is buried in the databases
Installation
Features
Supported chart types
Bar chart Based on the base implementation from https://www.chartjs3.com/docs/chart/getting-started/
Stacked bar chart
A bar chart variation with the help of the chart.js plugin https://github.com/y-takey/chartjs-plugin-stacked100/
Polar chart
A polar chart based on the sample from https://codepen.io/FranciscusAgnew/pen/LRGPYX
Doughnut chart
A variation of the base doughnut chart, based on https://www.youtube.com/watch?v=YcRj52VovYQ
Gauge chart
A variation of the doughnut chart, based on https://www.youtube.com/watch?v=VF6jd2Fv4bs&list=RDCMUCojXvfr41NqDxaPb9amu8-A&index=1
Boxplot chart
What is a Boxplot chart? See Wikipedia for more information.
A boxplot chart, based on https://www.youtube.com/watch?v=2zEbeX0bPS8
Ready to use charts
Customer Group Distribution
The charts shows the distribution of registered customers between all customer groups. It also provides the possibility to download the shown data as CSV.
It can be found in the page :
Permissions: only admin users with the permission can see the chart.
Configuration:
- the chart can be disabled via configuration
- the download filename can be changed via configuration
Adminhtml menu items
All menus can be found under
Chartbuilder Listing
Shows all registered chart builders.
Currently no further features are implemented. Possible features could be:
- Preview of generated chart.js configurations (TBD)
Demo Charts
Listing of all current demo charts and links how they have been implemented on js side.
Boilerplate code snipptes
ColumnBaseChart
Simple base class to order all added subblocks in a column layout. It dynamically sets the according needed columns, based if a chart is shown or not (which can change based on configuration or permissions). Additionally a section title added.
Sample of a row with 2 columns and a section title: `
BaseCompositeChart
Base chart display class. It can be used within the frontend and adminhtml (a specialized subclass exists with the extension of checking backend permissions: BroCode\Chartee\Block\Adminhtml\BaseCompositeChartsBlock). It provides the following features:
- checks the visibility based on a configuration value
- adds the possibility to prepare a download link of the shown data (or more) as CSV file
- the download file name can be configured (otherwise it will be autogenerated as {current-date}_{md5-hash}.csv)
- the key to the data from the chartbuilder that should be downloadable
- checks the visibility based on a ACL permission (only the adminhtml-class)
`
Chart Data Builder
Every chart needs a datasource, which is an implementation of \BroCode\Chartee\Api\ChartDataBuilderInterface. For every base chart a separate Databuilder is already implemented with default configurations for that type of chart and possibly additional methods for creating the needed configuration.
Every base chart has its default DataBuilder and an implementation example within \BroCode\Chartee\Model\DataBuilder\Demo.
Implementation of a new Databuilder
Extend the needed specific ChartDataBuilder, here a Sample of the DemoPolarChartDataBuilder: ``
To add downloadable data to be used, any data must be set separatelly to the chart builder class: ``
Registration within the databuilder service
The databuilder needs to be registered within a di.xml in order to use it as named builder within the Template-block class: `
Datafiltering
the \BroCode\Chartee\Model\ChartRequestParameterService provides methods to gather all set filtering parameter that should be considered when building up the needed data.
Current following parameters are supported:
- Scope (ChartRequestParameterService::getStoreIds(), based on the backend store switcher Magento\Backend\Block\Store\Switcher)
- DateRange (ChartRequestParameterService::getStartDate() & ChartRequestParameterService::getEndDate(), null if not set)
Hint for adding a store filter to your backend page: `
Hint for adding a date range filter to your backend page:
Hint for using a date range picker in a custom element:
Hint for configuration possibility (see https://www.daterangepicker.com/#config), e.g. hiding the week numbers:
`
BroCode\Chartee\Block\Widget\BaseChart
These charts are used by the BaseCompositeChart class and can also be used as standalone charts too. The according demo page charts are implemented that way.
Steps to add a new chart:
- create a databuilder (see above)
- create a virtual type and define a specific view model for that databuilder `
- create a layout update and set a the defined view model `
JS-Libraries, Chart.js version and extensions
- chart.js v4.4.0
- chart.js helpers (parts of it) v4.3.2
- chart.js boxplot plugin v4.2.4
- chart.js stacked100 plugin v1.5.2
- chart.js autocolors plugin 0.2.2
- custom implementation (based on samples from the internet, see above for reference) within graph.js
- doughnut labels line plugin
- gauge chart
- JQuery daterangepicker extension https://github.com/dangrossman/daterangepicker