File size: 8,488 Bytes
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b699ae9
 
42ee455
 
 
 
 
f5e87d9
 
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
42ee455
 
 
 
235787d
42ee455
 
 
 
 
 
f5e87d9
 
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
 
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
 
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
42ee455
 
 
 
f5e87d9
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5e87d9
42ee455
f5e87d9
 
 
 
 
 
 
 
42ee455
 
 
76bf90c
 
f5e87d9
 
42ee455
 
 
 
f5e87d9
42ee455
f5e87d9
 
42ee455
 
 
 
f5e87d9
 
42ee455
f5e87d9
42ee455
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
"""Defines chart groups."""

import itertools
from dataclasses import dataclass

import pages.correlation
import pages.deviation
import pages.distribution
import pages.flow
import pages.magnitude
import pages.part_to_whole
import pages.ranking
import pages.spatial
import pages.time
import vizro.models as vm


class IncompletePage:
    """Fake vm.Page-like class.

    This has the properties required to make it function sufficiently like a page when generating the navigation cards.
    Only the title is configurable; path is fixed to "".
    """

    def __init__(self, title):  # noqa: D107
        self.title = title

    @property
    def path(self):  # noqa: D102
        return ""


@dataclass
class ChartGroup:
    """Represents a group of charts like "Deviation"."""

    name: str
    pages: list[vm.Page]
    incomplete_pages: list[IncompletePage]
    intro_text: str
    icon: str = ""  # ALL_CHART_GROUP is the only one that doesn't require an icon.


deviation_intro_text = """
#### Deviation enables you to draw attention to variations (+/-) from a fixed reference point. Often this reference \
point is zero, but you might also show a target or a long term average. You can also use deviation to express a \
positive, neutral or negative sentiment.
"""
deviation_chart_group = ChartGroup(
    name="Deviation",
    pages=pages.deviation.pages,
    incomplete_pages=[
        IncompletePage(title="Surplus deficit filled line"),
    ],
    icon="Contrast Square",
    intro_text=deviation_intro_text,
)


correlation_intro_text = """
#### Correlation helps you show the relationship between two or more variables. It is important that you make it clear\
 to your audience whether or not the relationship is causal, i.e., whether one causes the other.
"""
correlation_chart_group = ChartGroup(
    name="Correlation",
    pages=pages.correlation.pages,
    incomplete_pages=[IncompletePage("Correlation matrix")],
    icon="Bubble Chart",
    intro_text=correlation_intro_text,
)


ranking_intro_text = """
#### Ranking enables you to present items in an ordered list. Use this when you want to highlight the position of an \
item rather than its absolute or relative value. You might want to emphasize the most interesting points with \
highlighting or labels to ensure the reader understands what matters most.
"""
ranking_chart_group = ChartGroup(
    name="Ranking",
    pages=pages.ranking.pages,
    incomplete_pages=[
        IncompletePage("Ordered bubble"),
        IncompletePage("Slope"),
        IncompletePage("Lollipop"),
        IncompletePage("Bump"),
    ],
    icon="Stacked Bar Chart",
    intro_text=ranking_intro_text,
)


distribution_intro_text = """
#### Distribution helps you to present all the possible values (or intervals) of your data and how often they occur. \
You can organize the data to show the number or percentage of items in a specified group, what shape the group takes,\
 where the center lies, and how much variability there is in the data. This shape (or _skew_) of a distribution can be \
 a powerful way for you to highlight either the existence or lack of uniformity or equality in the data.
"""
distribution_chart_group = ChartGroup(
    name="Distribution",
    pages=pages.distribution.pages,
    incomplete_pages=[
        IncompletePage("Barcode"),
        IncompletePage("Cumulative curve"),
        IncompletePage("Beeswarm"),
    ],
    icon="Waterfall Chart",
    intro_text=distribution_intro_text,
)

magnitude_intro_text = """
#### Magnitude allows you to emphasize size comparisons of **counted** items in your data set. You can show relative \
comparisons (whether something is larger or smaller) or absolute differences (where the nuances are most interesting). \
Typically, you will use magnitude for actual numbers versus calculated rates or percentages.
"""
magnitude_chart_group = ChartGroup(
    name="Magnitude",
    pages=pages.magnitude.pages,
    incomplete_pages=[
        IncompletePage("Marimekko"),
        IncompletePage("Lollipop"),
        IncompletePage("Pictogram"),
        IncompletePage("Bullet"),
        IncompletePage("Radial"),
    ],
    icon="Bar Chart",
    intro_text=magnitude_intro_text,
)

time_intro_text = """
#### Time helps you draw attention to important trends emerging over a specified period. The time period you select \
could be as short as seconds or as long as centuries. What matters most is selecting the correct period of time to \
best show your audience the message they need to take away.
"""
time_chart_group = ChartGroup(
    name="Time",
    pages=pages.time.pages,
    incomplete_pages=[
        IncompletePage("Slope"),
        IncompletePage("Fan"),
        IncompletePage("Bubble timeline"),
        IncompletePage("Sparkline"),
    ],
    icon="Timeline",
    intro_text=time_intro_text,
)


part_to_whole_intro_text = """
#### Part-to-whole helps you show how one whole item breaks down into its component parts. If you consider the size of\
the parts to be most important, a magnitude chart may be more appropriate.
"""
part_to_whole_chart_group = ChartGroup(
    name="Part-to-whole",
    pages=pages.part_to_whole.pages,
    incomplete_pages=[
        IncompletePage("Marimekko"),
        IncompletePage("Arc"),
        IncompletePage("Gridplot"),
        IncompletePage("Venn"),
    ],
    icon="Donut Small",
    intro_text=part_to_whole_intro_text,
)

flow_intro_text = """
#### With flow charts, you can highlight the quantity or the intensity of the movement between more than one state or \
condition. The flow might be steps in a logical sequence or movement between different geographical locations.
"""
flow_chart_group = ChartGroup(
    name="Flow",
    pages=pages.flow.pages,
    incomplete_pages=[
        IncompletePage("Chord"),
        IncompletePage("Network"),
    ],
    icon="Air",
    intro_text=flow_intro_text,
)

spatial_intro_text = """
#### Spatial charts allow you to demonstrate precise locations or geographical patterns in your data.
"""
spatial_chart_group = ChartGroup(
    name="Spatial",
    pages=pages.spatial.pages,
    incomplete_pages=[IncompletePage("Flow map")],
    icon="Map",
    intro_text=spatial_intro_text,
)


CHART_GROUPS = [
    deviation_chart_group,
    correlation_chart_group,
    ranking_chart_group,
    distribution_chart_group,
    magnitude_chart_group,
    time_chart_group,
    part_to_whole_chart_group,
    flow_chart_group,
    spatial_chart_group,
]

all_intro_text = """

### Welcome to our visual vocabulary dashboard! 🎨

#### This dashboard serves as a comprehensive guide for selecting and creating various types of charts. It helps \
you decide when to use each chart type, and offers sample Python code using [Plotly](https://plotly.com/python/), \
and instructions for embedding these charts into a [Vizro](https://github.com/mckinsey/vizro) dashboard.

#### The charts in this dashboard are designed to make it easy for anyone to create beautiful and sophisticated visuals.

#### Our goal is to help you understand best practices in data visualization, ensure your charts effectively \
communicate your message, and streamline the creation of high-quality, interactive visualizations.

 

 


Created by:
- [Huong Li Nguyen](https://github.com/huong-li-nguyen) and [Antony Milne](https://github.com/antonymilne)

- Images created by QuantumBlack

Inspired by:
- [The FT Visual Vocabulary](https://github.com/Financial-Times/chart-doctor/blob/main/visual-vocabulary/README.md):
[Alan Smith](https://github.com/alansmithy), [Chris Campbell](https://github.com/digitalcampbell), Ian Bott,
Liz Faunce, Graham Parrish, Billy Ehrenberg, Paul McCallum, [Martin Stabe](https://github.com/martinstabe).

- [The Graphic Continuum](https://www.informationisbeautifulawards.com/showcase/611-the-graphic-continuum):
Jon Swabish and Severino Ribecca

Credits and sources:
- Charting library: [Plotly](https://plotly.com/python/plotly-express/)

- Data visualization best practices: [Guide to data chart mastery](https://www.atlassian.com/data/charts)

"""


# This contains all pages used across all chart groups, without de-duplicating. De-duplication is done where required
# by remove_duplicates.
ALL_CHART_GROUP = ChartGroup(
    name="All",
    pages=list(itertools.chain(*(chart_group.pages for chart_group in CHART_GROUPS))),
    incomplete_pages=list(itertools.chain(*(chart_group.incomplete_pages for chart_group in CHART_GROUPS))),
    intro_text=all_intro_text,
)