[GH-ISSUE #191] Linechart: Add support for a legend #109

Closed
opened 2026-03-03 16:22:28 +03:00 by kerem · 5 comments
Owner

Originally created by @keithknott26 on GitHub (Apr 27, 2019).
Original GitHub issue: https://github.com/mum4k/termdash/issues/191

Consider adding support for a legend in the linechart, this is particularly useful when more than one series is used.

  • Would this be best placed underneath or inside the linechart?
  • If inside, what happens when the legend and the line meet?
Originally created by @keithknott26 on GitHub (Apr 27, 2019). Original GitHub issue: https://github.com/mum4k/termdash/issues/191 Consider adding support for a legend in the linechart, this is particularly useful when more than one series is used. - Would this be best placed underneath or inside the linechart? - If inside, what happens when the legend and the line meet?
Author
Owner

@mum4k commented on GitHub (Apr 28, 2019):

Agreed @keithknott26, this would indeed be a useful feature. Originally I was considering labels inside the linechart itself like here:

However I no longer think this is the best solution exactly due to what you described, lines might meet the legend. The infrastructure would handle that well. Depending on the order of drawing, one of the two would be hidden by the other in the location of the overlap. However this would decrease the readability of the linechart itself, hidden line means loss of details.

I think your first option might be best - if labels are desired, we could just reserve one line under the line chart and print them there.

<!-- gh-comment-id:487344123 --> @mum4k commented on GitHub (Apr 28, 2019): Agreed @keithknott26, this would indeed be a useful feature. Originally I was considering labels inside the linechart itself like here: ![](https://raw.githubusercontent.com/yaronn/blessed-contrib/master/docs/images/line.gif) However I no longer think this is the best solution exactly due to what you described, lines might meet the legend. The infrastructure would handle that well. Depending on the order of drawing, one of the two would be hidden by the other in the location of the overlap. However this would decrease the readability of the linechart itself, hidden line means loss of details. I think your first option might be best - if labels are desired, we could just reserve one line under the line chart and print them there.
Author
Owner

@mum4k commented on GitHub (Apr 28, 2019):

Het @keithknott26,

as @slok demonstrated in #188, using the Text widget alongside the LineChart gives a lot of flexibility on legend placement and also allows to scroll the legend if there are many entries. This also plays well into the Termdash philosophy of reusable components.

At this point I am wondering whether instead of implementing the legend in the LineChart we shouldn't identify the gaps and improve the Text widget if any.

What do you think? What are the scenarios that cannot be conveniently achieved with the Text widget?

<!-- gh-comment-id:487424761 --> @mum4k commented on GitHub (Apr 28, 2019): Het @keithknott26, as @slok demonstrated in #188, using the Text widget alongside the LineChart gives a lot of flexibility on legend placement and also allows to scroll the legend if there are many entries. This also plays well into the Termdash philosophy of reusable components. At this point I am wondering whether instead of implementing the legend in the LineChart we shouldn't identify the gaps and improve the Text widget if any. What do you think? What are the scenarios that cannot be conveniently achieved with the Text widget?
Author
Owner

@keithknott26 commented on GitHub (Apr 29, 2019):

@mum4k,

I tried this myself locally and it looks great! I also like that @slok created a widget with multiple elements inside so there is only one border. The fact that you can scroll is a bonus.

Do you think it will be possible to use the table widget instead of the text widget? I'm just wondering how easy aligning the text would be inside the widget, for now I'm using spaces and tabs , but depending on how you wrote the table widget one might be able to use that instead assuming each row could have its own text formatting applied (color, spacing).

I haven't found many scenarios which can't be achieved with the Text widget but here are a couple low priority suggestions.

-An "auto-scroll" feature
-Support for blinking text
-Issue found where if you use a \t character it prevents the line from being displayed

<!-- gh-comment-id:487427680 --> @keithknott26 commented on GitHub (Apr 29, 2019): @mum4k, I tried this myself locally and it looks great! I also like that @slok created a widget with multiple elements inside so there is only one border. The fact that you can scroll is a bonus. Do you think it will be possible to use the table widget instead of the text widget? I'm just wondering how easy aligning the text would be inside the widget, for now I'm using spaces and tabs , but depending on how you wrote the table widget one might be able to use that instead assuming each row could have its own text formatting applied (color, spacing). I haven't found many scenarios which can't be achieved with the Text widget but here are a couple low priority suggestions. -An "auto-scroll" feature -Support for blinking text -Issue found where if you use a \t character it prevents the line from being displayed
Author
Owner

@mum4k commented on GitHub (Apr 29, 2019):

I this that what @slok has are actually multiple inner containers inside an outer container. The outer container has a border and two inner containers without borders. Each of the inner containers has a widget.

Indeed similarly we could place a table widget next to the LineChart. The table widget will support individual alignment and formatting for each row and for each cell. Please take a look at the API that is already drafted in the table branch and let me know if you see anything missing or if we should change something. Do note that this is still very much in development.

Feel free to open separate issues for the suggestions, we can discuss them individually and agree on next steps.

I am going to close this issue based on our discussion and your assertion that we can do with the Text widget for now and with Table later. However if you do find something missing, please don't hesitate to reopen this.

<!-- gh-comment-id:487432856 --> @mum4k commented on GitHub (Apr 29, 2019): I this that what @slok has are actually multiple inner containers inside an outer container. The outer container has a border and two inner containers without borders. Each of the inner containers has a widget. Indeed similarly we could place a table widget next to the LineChart. The table widget will support individual alignment and formatting for each row and for each cell. Please take a look at the API that is already drafted in the [table branch](https://github.com/mum4k/termdash/tree/table/widgets/table) and let me know if you see anything missing or if we should change something. Do note that this is still very much in development. Feel free to open separate issues for the suggestions, we can discuss them individually and agree on next steps. I am going to close this issue based on our discussion and your assertion that we can do with the Text widget for now and with Table later. However if you do find something missing, please don't hesitate to reopen this.
Author
Owner

@slok commented on GitHub (Apr 29, 2019):

That's right! is a container with 2 containers Inside (one for the graph and another one for the legend), and the border set only to the outer container, so could be very easy to change the legend made with a text widget to use a table widget or any other widget instead.

<!-- gh-comment-id:487452847 --> @slok commented on GitHub (Apr 29, 2019): That's right! is a container with 2 containers Inside (one for the graph and another one for the legend), and the border set only to the outer container, so could be very easy to change the legend made with a text widget to use a table widget or any other widget instead.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/termdash#109
No description provided.