Skip to content

Commit 41c3b1f

Browse files
committed
Use template string on Fold titles for annotations
1 parent 419be83 commit 41c3b1f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/components/containers/AnnotationAccordion.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ import {PanelMessage} from './PanelEmpty';
44
import PropTypes from 'prop-types';
55
import React, {Component} from 'react';
66
import {connectAnnotationToLayout} from 'lib';
7+
import {templateString} from 'plotly.js/src/lib';
78

89
const AnnotationFold = connectAnnotationToLayout(PlotlyFold);
910

1011
class AnnotationAccordion extends Component {
1112
render() {
1213
const {
13-
layout: {annotations = []},
14+
layout: {annotations = [], meta = []},
1415
localize: _,
1516
} = this.context;
1617
const {canAdd, children} = this.props;
1718

1819
const content =
1920
annotations.length &&
20-
annotations.map((ann, i) => (
21-
<AnnotationFold key={i} annotationIndex={i} name={ann.text} canDelete={canAdd}>
22-
{children}
23-
</AnnotationFold>
24-
));
21+
annotations.map((ann, i) => {
22+
const textPostTemplate = templateString(ann.text, {meta});
23+
return (
24+
<AnnotationFold
25+
key={i}
26+
annotationIndex={i}
27+
name={textPostTemplate === '' ? ann.text : textPostTemplate}
28+
canDelete={canAdd}
29+
>
30+
{children}
31+
</AnnotationFold>
32+
);
33+
});
2534

2635
const addAction = {
2736
label: _('Annotation'),

0 commit comments

Comments
 (0)