Skip to content

Commit 8f7eb7c

Browse files
Merge pull request #9 from mindthemath/hotfix/docs
docs fixes + hip.theme support
2 parents 4082261 + b2d9cb9 commit 8f7eb7c

12 files changed

Lines changed: 193 additions & 93 deletions

.claude/settings.local.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"allow": [
44
"Bash(npm run build:*)",
55
"mcp__plugin_playwright_playwright__browser_drag",
6-
"Bash(bun run build:*)",
7-
"Bash(pip uninstall:*)",
86
"Bash(bunx playwright test:*)",
9-
"Bash(./build.sh:*)"
7+
"Bash(./build.sh:*)",
8+
"mcp__plugin_playwright_playwright__browser_run_code",
9+
"Bash(make build:*)"
1010
]
1111
}
1212
}

docs/experiment_settings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Multiple points can share the same parent - this is especially useful when repre
2222

2323
.. raw:: html
2424

25-
<iframe src="https://mindthemath.github.io/hiplot/_static/demo/demo_line_xy.html" height="1000px" style="width: 100%; border: 0;"></iframe>
25+
<iframe src="https://mindthemath.github.io/hiplot/_static/demo/demo_line_xy.html?hip.theme=light" height="1000px" style="width: 100%; border: 0;"></iframe>
2626

2727

2828
.. _frontendRenderingSettings:

docs/getting_started.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Installing
77

88
Python version
99
^^^^^^^^^^^^^^
10-
HiPlot requires python version 3.6 or newer (you can check your python version with :code:`python3 --version`)
10+
HiPlot requires Python version greater than 3.9 (you can check your Python version with :code:`python3 --version`)
1111

1212

1313
Python virtualenv
@@ -38,7 +38,7 @@ Within the activated environment, use the following command to install HiPlot:
3838

3939
.. code-block:: bash
4040
41-
pip install -U hiplot # Or for conda users: conda install -c conda-forge hiplot
41+
pip install -U "hiplot-mm>=0.0.4"
4242
4343
4444
Congratulation, HiPlot is now ready to use! You can either:
@@ -65,7 +65,7 @@ Once we have created this object, we can display it with :class:`hiplot.Experime
6565
6666
.. raw:: html
6767

68-
<iframe src="./_static/demo/demo_basic_usage.html?hip.PARALLEL_PLOT.height=300" height="700px" width="100%"></iframe>
68+
<iframe src="./_static/demo/demo_basic_usage.html?hip.PARALLEL_PLOT.height=300&amp;hip.theme=light" height="700px" width="100%"></iframe>
6969

7070

7171
**Learn more** in the tutorial: :ref:`tutoNotebook`

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Given about 7000 experimental datapoints, we want to understand which parameters
2121

2222
.. raw:: html
2323

24-
<iframe src="./_static/demo/ml1.csv.html?hip.color_by=%22valid+ppl%22&amp;hip.PARALLEL_PLOT.height=300" height="1000px" style="width: 100%; border: 0;"></iframe>
24+
<iframe src="./_static/demo/ml1.csv.html?hip.color_by=%22valid+ppl%22&amp;hip.PARALLEL_PLOT.height=300&amp;hip.theme=light" height="1000px" style="width: 100%; border: 0;"></iframe>
2525

2626

2727
HiPlot documentation

docs/tuto_javascript.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Basic example
3333

3434
.. raw:: html
3535

36-
<iframe src="./_static/examples_javascript/Basic/index.html" height="700px" width="100%"></iframe>
36+
<iframe src="./_static/examples_javascript/Basic/index.html?hip.theme=light" height="700px" width="100%"></iframe>
3737

3838

3939
Customizing HiPlot react component
@@ -69,4 +69,4 @@ An advanced example
6969

7070
.. raw:: html
7171

72-
<iframe src="./_static/examples_javascript/Custom/index.html?hip.PARALLEL_PLOT.height=250" height="400px" width="100%"></iframe>
72+
<iframe src="./_static/examples_javascript/Custom/index.html?hip.PARALLEL_PLOT.height=250&amp;hip.theme=light" height="400px" width="100%"></iframe>

docs/tuto_streamlit.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ HiPlot component for Streamlit
1010
Getting started
1111
----------------------------------
1212

13-
You'll need both Streamlit (>=0.63 for `components support <https://docs.streamlit.io/develop/concepts/custom-components/intro>`_) and HiPlot (>=0.18)
13+
You'll need both Streamlit (>=0.63 for `components support <https://docs.streamlit.io/develop/concepts/custom-components/intro>`_) and HiPlot (hiplot-mm >= 0.0.4)
1414

15-
>>> pip install -U streamlit hiplot
15+
>>> pip install -U streamlit "hiplot-mm>=0.0.4"
1616

1717

1818
Displaying an :class:`hiplot.Experiment`

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "hiplot-mm"
7-
version = "0.0.4rc13"
7+
version = "0.0.4rc15"
88
description = "High dimensional Interactive Plotting tool"
99
readme = "README.md"
1010
license = "MIT"

src/distribution/plot.tsx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ import * as d3 from "d3";
1010
import style from "../hiplot.module.css";
1111
import { create_d3_scale_without_outliers, ParamDef } from "../infertypes";
1212
import { convert_to_categorical_input } from "../lib/d3_scales";
13-
import { foCreateAxisLabel, foDynamicSizeFitContent } from "../lib/svghelpers";
1413
import { ParamType, Datapoint } from "../types";
1514

15+
function labelTextFromHtml(html: string, fallback: string): string {
16+
const tmp = document.createElement("div");
17+
tmp.innerHTML = html || "";
18+
const text = (tmp.textContent || tmp.innerText || "").trim();
19+
return text.length ? text : fallback;
20+
}
21+
1622
const margin = { top: 20, right: 20, bottom: 50, left: 60 };
1723

1824
interface BinsDrawData {
@@ -87,19 +93,11 @@ export class DistributionPlot extends React.Component<DistributionPlotData, {}>
8793
);
8894
d3.select(this.axisBottomName.current)
8995
.html(null)
90-
.append(
91-
function () {
92-
return foCreateAxisLabel(this.props.param_def, null, null);
93-
}.bind(this),
94-
)
95-
.classed("distrplot_axislabel", true)
96-
.attr("x", -4)
97-
.attr("text-anchor", "end");
98-
d3.select(this.axisBottomName.current)
99-
.select(".distrplot_axislabel")
100-
.each(function (this: SVGForeignObjectElement) {
101-
foDynamicSizeFitContent(this);
102-
});
96+
.append("text")
97+
.attr("text-anchor", "middle")
98+
.attr("font-weight", "bold")
99+
.attr("fill", "currentColor")
100+
.text(labelTextFromHtml(this.props.param_def.label_html, this.props.axis));
103101
this.axisRight.current.innerHTML = "";
104102
} else {
105103
dataScale.range([this.figureHeight(), 0]);
@@ -112,6 +110,13 @@ export class DistributionPlot extends React.Component<DistributionPlotData, {}>
112110
.transition()
113111
.duration(animate ? this.props.animateMs : 0)
114112
.call(d3.axisLeft(dataScale).ticks(1 + this.props.height / 50));
113+
d3.select(this.axisBottomName.current)
114+
.html(null)
115+
.append("text")
116+
.attr("text-anchor", "middle")
117+
.attr("font-weight", "bold")
118+
.attr("fill", "currentColor")
119+
.text("Density");
115120
}
116121
}
117122
createDataScaleAndAxis(): void {
@@ -354,14 +359,21 @@ export class DistributionPlot extends React.Component<DistributionPlotData, {}>
354359
}
355360

356361
render() {
357-
const leftAxisLabel = this.isVertical() ? "Density" : this.props.axis;
358362
return (
359363
<div data-testid="distribution-plot" data-axis={this.props.axis}>
360364
<svg width={this.props.width} height={this.props.height}>
361-
<g transform={`translate(${margin.left}, 15)`} textAnchor="start" fontWeight="bold">
362-
<text style={{ stroke: "white", strokeWidth: "0.2em" }}>{leftAxisLabel}</text>
363-
<text>{leftAxisLabel}</text>
364-
</g>
365+
<text
366+
x={13}
367+
y={15}
368+
textAnchor="start"
369+
fontWeight="bold"
370+
fill="currentColor"
371+
className={style.axisLabelText}
372+
>
373+
{this.isVertical()
374+
? "Density"
375+
: labelTextFromHtml(this.props.param_def.label_html, this.props.axis)}
376+
</text>
365377
<g
366378
ref={this.svgContainer}
367379
className={style["distr-graph-svg"]}
@@ -386,8 +398,8 @@ export class DistributionPlot extends React.Component<DistributionPlotData, {}>
386398
></g>
387399
<g
388400
ref={this.axisBottomName}
389-
transform={`translate(${this.figureWidth()}, ${this.props.height - margin.top - 30})`}
390-
textAnchor="end"
401+
transform={`translate(${this.figureWidth() / 2}, ${this.props.height - margin.top - 10})`}
402+
textAnchor="middle"
391403
fontWeight="bold"
392404
></g>
393405
</g>

src/hiplot_web.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ import { UploadDataProvider } from "./dataproviders/upload";
1616

1717
export function build_props(extra?: any): HiPlotProps {
1818
const searchParams = new URLSearchParams(location.search);
19+
const themeParam =
20+
searchParams.get("hip.theme") ??
21+
searchParams.get("hiplot.theme") ??
22+
searchParams.get("HIPLOT.theme");
1923
const darkParam =
2024
searchParams.get("hip.dark") ??
2125
searchParams.get("hiplot.dark") ??
2226
searchParams.get("HIPLOT.dark");
23-
const darkValue = normalizeDarkModeSetting(darkParam, "auto");
27+
// `hip.theme` is the preferred query parameter. Keep `hip.dark` as a
28+
// compatibility fallback for existing links.
29+
const themeOrDarkParam = themeParam !== null ? themeParam : darkParam;
30+
const darkValue = normalizeDarkModeSetting(themeOrDarkParam, "auto");
2431
var props = {
2532
experiment: null,
2633
persistentState: new PersistentStateInURL("hip"),

src/infertypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function infertypes(
387387
}
388388
}
389389
if (info.type == ParamType.NUMERICLOG) {
390-
info.ticks_format = d3.format(".1e");
390+
info.ticks_format = ".1e";
391391
}
392392
return info;
393393
}

0 commit comments

Comments
 (0)