diff --git a/hiplot/experiment.py b/hiplot/experiment.py
index 97da800b..777fe0d4 100644
--- a/hiplot/experiment.py
+++ b/hiplot/experiment.py
@@ -96,6 +96,7 @@ class ValueDef(_DictSerializable):
For example :code:`"interpolateSinebow"`.
To inverse the colormap, append `#inverse` to the name (eg :code:`"interpolateSinebow#inverse"`)
:ivar label_css: Space-separated bootstrap CSS classes to apply on the label when supported
+ :ivar label_html: HTML code used to render the column name
See :attr:`hiplot.Experiment.parameters_definition`
"""
@@ -113,6 +114,7 @@ def __init__(
self.label_css = label_css
self.force_value_min: tp.Optional[float] = None
self.force_value_max: tp.Optional[float] = None
+ self.label_html: tp.Optional[str] = None
def force_range(self, minimum: float, maximum: float) -> "ValueDef":
"""
@@ -139,6 +141,7 @@ def _asdict(self) -> tp.Dict[str, tp.Any]:
"force_value_min": self.force_value_min,
"force_value_max": self.force_value_max,
"label_css": self.label_css,
+ "label_html": self.label_html,
}
diff --git a/hiplot/fetchers_demo.py b/hiplot/fetchers_demo.py
index bb3cccda..06c0a747 100644
--- a/hiplot/fetchers_demo.py
+++ b/hiplot/fetchers_demo.py
@@ -322,6 +322,18 @@ def demo_3xcols() -> hip.Experiment:
return xp
+def demo_col_html() -> hip.Experiment:
+ COL1 = "
col1
"
+ COL2 = "col_2"
+ experiment = hip.Experiment.from_iterable([
+ {COL1: 1.0, COL2: 1},
+ {COL1: 2.0, COL2: 2},
+ {COL1: 3.0, COL2: 3},
+ ])
+ experiment.parameters_definition[COL2].label_html = "col2"
+ return experiment
+
+
README_DEMOS: t.Dict[str, t.Callable[[], hip.Experiment]] = {
"demo": demo,
"demo_3xcols": demo_3xcols,
@@ -346,4 +358,5 @@ def demo_3xcols() -> hip.Experiment:
"demo_color_interpolate_inverse": demo_color_interpolate_inverse,
"demo_first_value_nan": demo_first_value_nan,
"demo_weighted_rows": demo_weighted_rows,
+ "demo_col_html": demo_col_html,
}
diff --git a/src/infertypes.ts b/src/infertypes.ts
index 1e46eda4..3041ffb2 100644
--- a/src/infertypes.ts
+++ b/src/infertypes.ts
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
-
+import $ from "jquery";
import * as d3 from "d3";
import * as color from "color";
@@ -315,6 +315,7 @@ export function infertypes(url_states: PersistentState, table: Array,
'force_value_min': hint !== undefined && hint.force_value_min != null ? hint.force_value_min : null,
'force_value_max': hint !== undefined && hint.force_value_max != null ? hint.force_value_max : null,
'label_css': hint !== undefined && hint.label_css !== null ? hint.label_css : "",
+ 'label_html': hint !== undefined && hint.label_html !== null && hint.label_html !== undefined ? hint.label_html : $("").text(key).html(),
};
// What other types we can render as?
if (numeric) {
diff --git a/src/lib/svghelpers.ts b/src/lib/svghelpers.ts
index fa766019..264add54 100644
--- a/src/lib/svghelpers.ts
+++ b/src/lib/svghelpers.ts
@@ -58,7 +58,7 @@ export function foCreateAxisLabel(pd: ParamDef, cm?: React.RefObject = this.ordered_cols.map(function(x) {
const pd = me.props.params_def[x];
return {
- 'title': x == '' ? '' : $("").attr("class", pd.label_css).text(x)[0].outerHTML,
+ 'title': x == '' ? '' : $("").attr("class", pd.label_css).html(pd.label_html)[0].outerHTML,
'defaultContent': 'null',
'type': x == '' ? 'html' : (pd.numeric ? "num" : "string"),
'visible': !me.props.hide || !me.props.hide.includes(x),
diff --git a/src/types.ts b/src/types.ts
index 29723676..d2724ee5 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -35,6 +35,7 @@ export interface HiPlotValueDef { // Mirror of python `hip.ValueDef`
force_value_min: number | null;
force_value_max: number | null;
label_css: string | null;
+ label_html: string | null;
};
export interface DatapointsCompressed {