Skip to content

Commit

Permalink
Merge branch 'main' into fix/vizro-ai/duplicate_fig_diplayed
Browse files Browse the repository at this point in the history
  • Loading branch information
nadijagraca committed Jul 15, 2024
2 parents 8179ebb + b8b15d4 commit cb15104
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @Joseph-Perkins @antonymilne @huong-li-nguyen @maxschulz-COL
vizro-ai/ @Joseph-Perkins @Anna-Xiong @lingyielia @maxschulz-COL
docs/ @stichbury
docs/ @stichbury @Joseph-Perkins @antonymilne @huong-li-nguyen @maxschulz-COL
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
48 changes: 48 additions & 0 deletions vizro-core/changelog.d/20240712_090435_antony.milne_custom_icon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
1 change: 0 additions & 1 deletion vizro-core/docs/pages/user-guides/card-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ If you now click on the card area, you should automatically be redirected to the

### Create a KPI card
To create a KPI card, you can use the existing KPI card functions from [`vizro.figures`](../API-reference/figure-callables.md).
Unlike the static text card `vm.Card`, a KPI card must be created using a figure function.
Unlike the static text card `vm.Card`, a KPI card must be created using a figure function,
which enables the text content of the KPI to change based on input from controls or actions.

Expand Down
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/user-guides/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ You can alter the icons used by specifying the name of the icon in the [Google M
icon="Bar Chart",
pages=["My first page", "My second page"],
),
vm.NavLink(label="Section 2", icon="pie_chart", pages=["My third page"]),
vm.NavLink(label="Section 2", icon="Pie Chart", pages=["My third page"]),
]
)
),
Expand All @@ -266,7 +266,7 @@ You can alter the icons used by specifying the name of the icon in the [Google M
- My first page
- My second page
- label: Section 1
icon: pie_chart
icon: Pie Chart
pages:
- My third page
```
Expand Down
11 changes: 9 additions & 2 deletions vizro-core/src/vizro/models/_components/form/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def validate_multi(cls, multi, values):
@_log_call
def build(self):
full_options, default_value = get_options_and_default(options=self.options, multi=self.multi)
# 30 characters is roughly the number of "A" characters you can fit comfortably on a line in the dropdown.
# "A" is representative of a slightly wider than average character:
# https://stackoverflow.com/questions/3949422/which-letter-of-the-english-alphabet-takes-up-most-pixels
# We look at the longest option to find number_of_lines it requires. Option height is the same for all options
# and needs 24px for each line + 8px padding.
number_of_lines = math.ceil(max(len(str(option)) for option in full_options) / 30)
option_height = 8 + 24 * number_of_lines

return html.Div(
children=[
dbc.Label(self.title, html_for=self.id) if self.title else None,
Expand All @@ -72,8 +80,7 @@ def build(self):
value=self.value if self.value is not None else default_value,
multi=self.multi,
persistence=True,
# 37 is the cut-off character length where the text inside the dropdown starts to wrap
optionHeight=32 + 24 * math.floor(max(len(str(option)) for option in full_options) / 37),
optionHeight=option_height,
persistence_type="session",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ def test_dropdown_without_all_option(self):
[
(["A", "B", "C"], 32),
([10, 20, 30], 32),
(["A text with a length of 36..........", "B", "C"], 32),
(["A text with a length of 37...........", "B", "C"], 56),
(["A text with a length of 37..........." + "A text with a length of 37...........", "B", "C"], 80),
(["A" * 30, "B", "C"], 32),
(["A" * 31, "B", "C"], 56),
(["A" * 60, "B", "C"], 56),
(["A" * 61, "B", "C"], 80),
],
)
def test_dropdown_dynamic_option_height(self, options, option_height):
Expand Down

0 comments on commit cb15104

Please sign in to comment.