Skip to content

Commit 205366e

Browse files
committed
fix hovertext dimension to be matrix/ 2d array type
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
1 parent 8a8dab9 commit 205366e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

examples/scientific_charts/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::f64::consts::PI;
44

5-
use plotly::common::{ColorScale, ColorScalePalette, Font};
5+
use plotly::common::{ColorScale, ColorScalePalette, Font, HoverInfo};
66
use plotly::contour::Contours;
77
use plotly::{Contour, HeatMap, Layout, Plot};
88
use plotly_utils::write_example_to_html;
@@ -124,7 +124,15 @@ fn customizing_spacing_between_x_and_y_ticks(show: bool, file_name: &str) {
124124
// ANCHOR: basic_heat_map
125125
fn basic_heat_map(show: bool, file_name: &str) {
126126
let z = vec![vec![1, 20, 30], vec![20, 1, 60], vec![30, 60, 1]];
127-
let trace = HeatMap::new_z(z).zmin(1.0).zmax(60.0);
127+
let trace = HeatMap::new_z(z)
128+
.zmin(1.0)
129+
.zmax(60.0)
130+
.hover_info(HoverInfo::Text)
131+
.hover_text_matrix(vec![
132+
vec!["A", "B", "C"],
133+
vec!["D", "E", "F"],
134+
vec!["G", "H", "I"],
135+
]);
128136
let mut plot = Plot::new();
129137
plot.add_trace(trace);
130138

plotly/src/traces/heat_map.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ where
8686
#[serde(rename = "hovertemplate")]
8787
hover_template: Option<Dim<String>>,
8888
#[serde(rename = "hovertext")]
89-
hover_text: Option<Vec<String>>,
89+
#[field_setter(with_matrix)]
90+
hover_text: Option<Dim<String>>,
9091
#[serde(rename = "legendgroup")]
9192
legend_group: Option<String>,
9293
#[serde(rename = "legendgrouptitle")]
@@ -99,7 +100,8 @@ where
99100
show_legend: Option<bool>,
100101
#[serde(rename = "showscale")]
101102
show_scale: Option<bool>,
102-
text: Option<Vec<String>>,
103+
#[field_setter(with_matrix)]
104+
text: Option<Dim<String>>,
103105
transpose: Option<bool>,
104106
visible: Option<Visible>,
105107
x: Option<Vec<X>>,

0 commit comments

Comments
 (0)