Skip to content

Commit

Permalink
Fix mapping of charts to categories
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Jul 16, 2024
1 parent 3940c45 commit cbcff26
Showing 1 changed file with 48 additions and 45 deletions.
93 changes: 48 additions & 45 deletions vizro-core/examples/chart-gallery/utils/_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,68 @@


def tidy_chart_title(chart: str) -> str:
prefixes_to_remove = ["time-", "magnitude-", "deviation-"]
"""Tidy up the chart title by removing prefixes and unwanted characters.
The pre-fixes are previously given to uniquely create a page ID.
"""
prefixes_to_remove = ["time-", "magnitude-", "deviation-", "distribution-"]
pattern = "^(" + "|".join(prefixes_to_remove) + ")"
chart_without_prefix = re.sub(pattern, "", chart)
return chart_without_prefix.replace("-", " ").title()


DEVIATION_CHARTS = sorted(["diverging-bar", "butterfly", "slope", "lollipop"])
CORRELATION_CHARTS = ["scatter"]
DEVIATION_CHARTS = sorted(
[
"diverging-bar",
# "diverging-stacked-bar",
"butterfly",
"surplus",
]
)
CORRELATION_CHARTS = [
"scatter",
"scatter-matrix",
"column-line",
# "connected-scatter",
"heatmap-matrix",
"bubble",
]
RANKING_CHARTS = sorted(
[
"ordered-bar",
"ordered-column",
"stacked-column",
"ordered-bubble",
"column-line",
"donut",
"arc",
"slope",
"lollipop",
"waterfall",
"diverging-bar",
"boxplot",
"stepped-line",
]
)
DISTRIBUTION_CHARTS = sorted(
[
"histogram",
"distribution-butterfly",
"pie",
"donut",
"arc",
"dot-plot",
"barcode",
"boxplot",
"violin",
"lollipop",
"distribution-butterfly",
"cumulative-curve",
"waterfall",
"venn",
"barcode",
# "beeswarm",
]
)

MAGNITUDE_CHARTS = sorted(
[
"column",
"marimekko",
"stacked-column",
"ordered-bubble",
"column-line",
"surplus",
"bubble-timeline",
"bar",
"pie",
"donut",
"arc",
"violin",
"slope",
# "paired-column",
# "paired-bar",
"marimekko",
"bubble",
"lollipop",
"cumulative-curve",
"waterfall",
"venn",
"diverging-bar",
"radar",
"parallel",
"pictogram",
"bullet",
"dot-plot",
"magnitude-treemap",
"radial",
]
)
TIME_CHARTS = sorted(
Expand All @@ -84,29 +85,31 @@ def tidy_chart_title(chart: str) -> str:
"time-column",
"gantt",
"column-line",
"slope",
"fan",
# "area",
# "connected-scatter",
"heatmap",
"bubble-timeline",
"scatter",
"lollipop",
"diverging-bar",
"stepped-line",
"sparkline",
]
)
PART_TO_WHOLE_CHARTS = sorted(
[
"marimekko",
# "stacked-bar",
"stacked-column",
"column-line",
"marimekko",
"funnel",
"pie",
"donut",
"arc",
"waterfall",
"treemap",
"arc",
"venn",
"waterfall",
]
)
FLOW_CHARTS = sorted(["gantt", "line", "slope", "stepped-line"])
SPATIAL_CHARTS = sorted(["choropleth", "dot-density", "flow-map"])
FLOW_CHARTS = sorted(["sankey", "waterfall", "chord", "network"])
SPATIAL_CHARTS = sorted(["choropleth", "dot-density", "flow-map", "proportional-symbol"])

ALL_CHARTS = sorted(
set(
Expand Down

0 comments on commit cbcff26

Please sign in to comment.