class ProductSalesApexChart(ReportView):
report_title = _("Product Sales Apex Charts")
report_description = _(
"ApexCharts isn't a built-in engine like Highcharts/Chart.js — this report shows how to plug in "
"any JS charting library as a custom chart_engine (registered in SLICK_REPORTING_SETTINGS['CHARTS']), "
"with a custom JS entry point (displayChartCustomEntryPoint) for fully bespoke chart initialisation.")
report_model = SalesTransaction
date_field = "date"
group_by = "product"
chart_engine = "apexcharts"
template_name = "demo/apex_report.html"
columns = [
"name",
ComputationField.create(
method=Sum,
field="value",
name="value__sum",
verbose_name="Total sold $",
is_summable=True,
),
]
chart_settings = [
Chart(
"Total sold $",
type="pie",
data_source=["value__sum"],
title_source=["name"],
),
Chart(
"Total sold $",
type="bar",
data_source=["value__sum"],
title_source=["name"],
),
Chart(
"A custom Entry Point $",
type="bar",
data_source=["value__sum"],
title_source=["name"],
entryPoint="displayChartCustomEntryPoint", # a custom entry point to control the chart
),
]