charles-001 / dolphie

Your single pane of glass for real-time analytics into MySQL/MariaDB & ProxySQL
https://pypi.org/project/dolphie/
GNU General Public License v3.0
651 stars 40 forks source link

How i can did sparklines in textual like you? #63

Closed wstr27 closed 6 months ago

wstr27 commented 6 months ago

Please help me with this question. I try to find answer, but can do it

charles-001 commented 6 months ago

Hi @wstr27 -

I colored it like this in the CSS:

Sparkline > .sparkline--max-color {
    color: #869fd9;
}
Sparkline > .sparkline--min-color {
    color: #384c7a;
}

To use Sparkline, you need to do this:

from textual.widgets import Sparkline

def compose(self):
    yield Sparkline([])

To update it like I do so it looks live, I do:

sparkline = self.query_one(Sparkline)
sparkline.data = [1,5,6,8,10]
sparkline.refresh()