Skip to content

Commit 730352f

Browse files
tushortzaidan
authored andcommitted
CDD-3460: Dual category chart update
1 parent ba0f499 commit 730352f

8 files changed

Lines changed: 3788 additions & 2 deletions

File tree

cms/dynamic_content/cards.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ class DualCategoryChartCard(blocks.StructBlock):
518518
choices=get_dual_category_chart_types,
519519
help_text=help_texts.CHART_TYPE_FIELD,
520520
)
521+
show_timeseries_filter = blocks.BooleanBlock(
522+
help_text=help_texts.DUAL_CATEGORY_CHART_TIMESERIES_FILTER,
523+
default=False,
524+
required=False,
525+
)
521526

522527
static_fields = DualCategoryChartStaticFieldComponent()
523528

cms/dynamic_content/help_texts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@
382382
1m, 3m, 6m, 1y etc.
383383
"""
384384

385+
DUAL_CATEGORY_CHART_TIMESERIES_FILTER: str = """
386+
This option enables the timeseries filter for this chart when it is used for timeseries data.
387+
The timeseries filter allows a user to change the timeseries range for example between
388+
1m, 3m, 6m, 1y etc.
389+
Only enable this when the dual category chart is configured with timeseries metrics.
390+
"""
391+
385392
ANNOUNCEMENT_BANNER_TITLE: str = """
386393
The title to associate with the announcement. This must be provided.
387394
"""

cms/home/migrations/0038_alter_landingpage_body_dual_category_update.py

Lines changed: 1148 additions & 0 deletions
Large diffs are not rendered by default.

cms/topic/migrations/0035_alter_topicpage_body_dual_category_update.py

Lines changed: 1462 additions & 0 deletions
Large diffs are not rendered by default.

cms/topics_list/migrations/0009_alter_topicslistpage_body_dual_category_update.py

Lines changed: 1148 additions & 0 deletions
Large diffs are not rendered by default.

metrics/domain/common/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ def dual_category_chart_options(cls) -> list[str]:
115115
Examples:
116116
["stacked-bar", "pyramid"]
117117
"""
118-
selectable = (cls.stacked_bar, cls.pyramid)
118+
selectable = (
119+
cls.stacked_bar,
120+
# Note: Uncomment this once we have a proper pyramid chart implementation
121+
# cls.pyramid,
122+
)
119123
return tuple((chart_type.value, chart_type.value) for chart_type in selectable)
120124

121125
@classmethod

tests/unit/cms/dynamic_content/test_dual_category_chart_card.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TestDualCategoryChartCard:
3131
"y_axis_minimum_value",
3232
"y_axis_maximum_value",
3333
"chart_type",
34+
"show_timeseries_filter",
3435
"secondary_category",
3536
),
3637
)

tests/unit/metrics/domain/common/test_utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,19 @@ def test_values(self):
219219
]
220220
assert values == expected_values
221221

222+
def test_dual_category_chart_options(self):
223+
"""
224+
Given no input
225+
When the `dual_category_chart_options()` class method is called
226+
from the `ChartTypes` enum
227+
Then only stacked_bar is returned as a CMS-selectable dual category chart type
228+
"""
229+
# Given / When
230+
choices = ChartTypes.dual_category_chart_options()
231+
232+
# Then
233+
assert choices == (("stacked_bar", "stacked_bar"),)
222234

223-
class TestCheckForSubstringMatch:
224235
@pytest.mark.parametrize(
225236
"metric_name",
226237
[

0 commit comments

Comments
 (0)