hynky HF staff commited on
Commit
462133f
1 Parent(s): fb0323d

label show text now

Browse files
Files changed (1) hide show
  1. src/clusters.js +8 -3
src/clusters.js CHANGED
@@ -48,8 +48,8 @@ const DEFAULT_YAXIS = {
48
  range: [1.6774392919913423, 6.514440889610389],
49
  }
50
 
51
- const getLabelHoverFormat = (row, ) => {
52
- return `<b>Text</b>: ${row.text}<br><b>Label</b>: ${row.label}<br><b>Edu label</b>: ${row.eduScore}`;
53
  };
54
 
55
 
@@ -168,6 +168,11 @@ async function plotClusters() {
168
  };
169
  });
170
 
 
 
 
 
 
171
  const traces = [
172
  {
173
  type: "scatter",
@@ -180,7 +185,7 @@ async function plotClusters() {
180
  opacity: 8,
181
  },
182
  hoverinfo: "text",
183
- hovertext: data.map((row) => getLabelHoverFormat(row)),
184
  hoverlabel: {
185
  bgcolor: "white",
186
  },
 
48
  range: [1.6774392919913423, 6.514440889610389],
49
  }
50
 
51
+ const getLabelHoverFormat = (row, labelIDToName) => {
52
+ return `<b>Text</b>: ${row.text}<br><b>Label</b>: ${labelIDToName[row.label] ?? "Unknown"}<br><b>Edu label</b>: ${row.eduScore}`;
53
  };
54
 
55
 
 
168
  };
169
  });
170
 
171
+ const labelIDToName = annotations.reduce((acc, annotation) => {
172
+ acc[annotation.label] = annotation.text;
173
+ return acc;
174
+ }, {});
175
+
176
  const traces = [
177
  {
178
  type: "scatter",
 
185
  opacity: 8,
186
  },
187
  hoverinfo: "text",
188
+ hovertext: data.map((row) => getLabelHoverFormat(row, labelIDToName)),
189
  hoverlabel: {
190
  bgcolor: "white",
191
  },