Skip to content

Commit

Permalink
fix: support lack of plot legend in verbose text output (#395)
Browse files Browse the repository at this point in the history
fixes #217
  • Loading branch information
ellvix authored Feb 7, 2024
1 parent 5a7e5db commit a8e92c5
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,17 @@ class Display {
let reviewText = '';
if (constants.chartType == 'bar') {
// {legend x} is {colname x}, {legend y} is {value y}
if (plot.plotLegend.x.length > 0 && plot.columnLabels[position.x]) {
verboseText =
plot.plotLegend.x + ' is ' + plot.columnLabels[position.x] + ', ';
if (plot.columnLabels[position.x]) {
if (plot.plotLegend.x.length > 0) {
verboseText += plot.plotLegend.x + ' is ';
}
verboseText += plot.columnLabels[position.x] + ', ';
}
if (plot.plotData[position.x]) {
verboseText += plot.plotLegend.y + ' is ' + plot.plotData[position.x];
if (plot.plotLegend) {
verboseText += plot.plotLegend.y + ' is ';
}
verboseText += plot.plotData[position.x];
}
if (constants.textMode == 'off') {
// do nothing :D
Expand Down Expand Up @@ -542,14 +547,14 @@ class Display {
}
} else if (constants.chartType == 'line') {
// line layer
verboseText +=
plot.plotLegend.x +
' is ' +
plot.pointValuesX[position.x] +
', ' +
plot.plotLegend.y +
' is ' +
plot.pointValuesY[position.x];
if (plot.plotLegend) {
verboseText += plot.plotLegend.x + ' is ';
}
verboseText += plot.pointValuesX[position.x] + ', ';
if (plot.plotLegend) {
plot.plotLegend.y + ' is ';
}
verboseText += plot.pointValuesY[position.x];

if (constants.textMode == 'off') {
// do nothing
Expand All @@ -570,8 +575,14 @@ class Display {
constants.chartType == 'dodged_bar'
) {
// {legend x} is {colname x}, {legend y} is {colname y}, value is {plotData[x][y]}
verboseText += plot.plotLegend.x + ' is ' + plot.level[position.x] + ', ';
verboseText += plot.plotLegend.y + ' is ' + plot.fill[position.y] + ', ';
if (plot.plotLegend) {
verboseText += plot.plotLegend.x + ' is ';
}
verboseText += plot.level[position.x] + ', ';
if (plot.plotLegend) {
verboseText += plot.plotLegend.y + ' is ';
}
verboseText += plot.fill[position.y] + ', ';
verboseText += 'value is ' + plot.plotData[position.x][position.y];

if (constants.textMode == 'off') {
Expand Down

0 comments on commit a8e92c5

Please sign in to comment.