Skip to content

Commit

Permalink
fix: bug with focus in stacking column chart (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsleepo authored Sep 27, 2024
1 parent d0cf610 commit c04ac11
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
32 changes: 32 additions & 0 deletions demo/examples/legend.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ <h1>Legend</h1>
<div id="chart6" class="container"></div>
</div>

<div class="grid">
<div id="chart7" class="container"></div>
</div>

<script>
const y1 = new Yagr(chart1, {
title: {text: 'On top'},
Expand Down Expand Up @@ -166,6 +170,34 @@ <h1>Legend</h1>
behaviour: 'extended',
},
});

const y7 = new Yagr(chart7, {
title: {text: 'On top'},
timeline: [1, 2, 3],
series: [
{data: [1, 2, 3], color: 'red', type: 'column',},

{data: [2, 1, 2], color: 'green', type: 'column'},
{data: [1, 2, 3], color: 'lime', type: 'column'},
],
"scales": {
"x": {},
"y": {
"normalize": false,
"stacking": true,
"type": "linear"
},
"yRight": {
"normalize": false,
"stacking": true,
"type": "linear"
}
},
legend: {
show: true,
position: 'top',
},
});
</script>
</body>
</html>
7 changes: 6 additions & 1 deletion src/YagrCore/plugins/legend/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,19 @@ export default class LegendPlugin {
}

const targetSerie = this.yagr.uplot.series.find(({id}) => id === serieId);

if (targetSerie) {
yagr.setFocus(targetSerie.id, true);

// fix bug with focus in stacking column chart
yagr.redraw(true, false);
}
};

const onSerieMouseLeave = () => {
yagr.setFocus(null, true);

// fix bug with focus in stacking column chart
yagr.redraw(true, false);
};

series.forEach((serieNode) => {
Expand Down

0 comments on commit c04ac11

Please sign in to comment.