Skip to content

Commit

Permalink
(re)Add Stacking option for highcharts
Browse files Browse the repository at this point in the history
  • Loading branch information
RamezIssac committed Jun 16, 2024
1 parent 3681c9d commit ca5517d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
42 changes: 32 additions & 10 deletions demo_proj/demo_app/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,28 +601,44 @@ class ChartJSExample(TimeSeriesReport):
title_source=["name"],
plot_total=True,
),
Chart(
"Total Sales [Line details]",
Chart.LINE,
data_source=["sum__value"],
title_source=["name"],
# plot_total=True,
),
# Chart(
# "Total Sales [Line details]",
# Chart.LINE,
# data_source=["sum__value"],
# title_source=["name"],
# # plot_total=True,
# ),
]


class HighChartExample(ChartJSExample):
class HighChartExample(TimeSeriesReport):
chart_engine = "highcharts"
report_title = _("Highcharts Examples ")

chart_settings = [
Chart("Client Sales Column", Chart.COLUMN, data_source=["sum__value"], title_source=["name"]),
Chart("Client Sales [Column]", Chart.COLUMN, data_source=["sum__value"], title_source=["name"]),
Chart(
"Stacking Client Sales [Column]",
Chart.COLUMN,
data_source=["sum__value"],
title_source=["name"],
stacking=True,
),
Chart(
"Total Client Sales Column",
"Total Client Sales[Column]",
Chart.COLUMN,
data_source=["sum__value"],
title_source=["name"],
plot_total=True,
),
Chart(
"Stacking Total Client Sales [Column]",
Chart.COLUMN,
data_source=["sum__value"],
title_source=["name"],
plot_total=True,
stacking=True,
),
Chart(
"Client Sales [Bar]",
Chart.BAR,
Expand Down Expand Up @@ -653,6 +669,12 @@ class HighChartExample(ChartJSExample):
title_source=["name"],
plot_total=True,
),
Chart(
"Client Sales [Area]",
Chart.AREA,
data_source=["sum__value"],
title_source=["name"],
),
]


Expand Down
6 changes: 3 additions & 3 deletions demo_proj/templates/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"/></svg>
</span>
<span class="nav-link-title">
HighCharts
HighCharts Charts Demo
</span>
</a>
</li>
Expand All @@ -188,7 +188,7 @@
d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"/></svg>
</span>
<span class="nav-link-title">
ChartsJS
Charts.js Charts
</span>
</a>
</li>
Expand All @@ -202,7 +202,7 @@
d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"/></svg>
</span>
<span class="nav-link-title">
Apex Chart Demo
Apex Charts
</span>
</a>
</li>
Expand Down
5 changes: 4 additions & 1 deletion slick_reporting/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Chart:
data_source: list
title_source: list
plot_total: bool = False
stacking: bool = False # only for highcharts
engine: str = ""
entryPoint: str = ""
COLUMN = "column"
Expand All @@ -39,6 +40,7 @@ def to_dict(self):
plot_total=self.plot_total,
engine=self.engine,
entryPoint=self.entryPoint,
stacking=self.stacking,
)


Expand Down Expand Up @@ -938,7 +940,7 @@ def get_full_response(
@staticmethod
def get_chart_settings(chart_settings=None, default_chart_title=None, chart_engine=None):
"""
Ensure the sane settings are passed to the front end.
Ensure the sane settings are passed to the front end. ?
"""
chart_engine = chart_engine or SLICK_REPORTING_DEFAULT_CHARTS_ENGINE
output = []
Expand All @@ -959,6 +961,7 @@ def get_chart_settings(chart_settings=None, default_chart_title=None, chart_engi
chart.get("entryPoint")
or app_settings.SLICK_REPORTING_SETTINGS["CHARTS"][chart["engine_name"]]["entryPoint"]
)
chart["stacking"] = chart.get("stacking", False)

output.append(chart)
return output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
});
chartOptions.data = response.data;


let is_time_series = is_timeseries_support(response, chartOptions); // response.metadata.time_series_pattern || '';
let is_crosstab = is_crosstab_support(response, chartOptions);

Expand Down

0 comments on commit ca5517d

Please sign in to comment.