live-chart
live-chart copied to clipboard
Add multicolor feature to line and area
It would be super cool to be able change colour of segment of the line to indicate e.g. high values. That also would be nice to have for the area under such segment.
Ok, if you need that feature, I'll take a look.
ping :eyes:
Shame on me. Time flies. I promise to take a look this week.
Just a small update to keep you informed : I'm working on a poc. I should be able to release this feature next week, + this one https://github.com/lcallarec/live-chart/issues/36
Just asking : do you have any needs to define more than one "area", i.e. "high (in orange)" and "very high (in red)" ?
Not really, as for now 😅 Can't really think right now for other use cases for Monitor. Hmm maybe in profiling? As we can see in browser web tools. But I'm not going to do anything like that in the near future.
Ok, that's a good news :) Having more that one area is a pain ^^.
I'll release a beta before the end of the week, for SmoothLineArea only.
That feature wasn't so obvious to code and could have some impacts on performances and stability. It'll better if you could take some times to let this beta running inside your Monitor application a long time, just to check if everything is ok.
To test this feature, please update to 55d904b56bcb920e25a3f459572e48e99a92aeaf.
Usage :
var red = Gdk.Color() { red: 1, green: 0, blue: 0, alpha: 1};
var lightly_red = Gdk.Color() { red: 1, green: 0, blue: 0, alpha: 0.5};
var line = new LiveChart.SmoothLineArea(); //or SmoothLine();
line.region = new LiveChart.Region.between(100, double.MAX).with_line_color(red).with_area_color(lightly_red);
I'm waiting for your feedbacks !
Looks cool! (temperature)
But experienced a few crushes, maybe because I tried to colour area when using stacked charts on main CPU chart. Added if (series_quantity == 1)
and it's kinda stable.
Thanks!
You can check here https://github.com/stsdc/monitor/blob/6a6a4dbe8de14e89de4bcbe9d9c589f56af4220b/src/Widgets/Chart/Chart.vala#L49-L68
PS I believe you meant Gdk.RGBA
and =
:sweat_smile:
I'm a bit frightened about the crash you experienced. Was it a segfault ? Have you got any log about that crash ?
Here is a gdb output, hope it helps:
Thread 1 "com.github.stsd" received signal SIGSEGV, Segmentation fault.
0x00007ffff7f9ea21 in live_chart_region_handle (Python Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.:
self=, intersections=0x7fffe8027ed0, previous=0x7fffffffad20, current=0x7fffffffad50,
get_intersection=0x7ffff7f94c4b <___lambda12__live_chart_get_intersection>, get_intersection_target=0x7fffdc023460)
at ../subprojects/live-chart/src/region.vala:82
82 intersections.close(coords.x, exited_at);
Yes, thanks, it helps. Let me figure out what happened.
@stsdc : would you please test monitor with this commit of live-chart : https://github.com/lcallarec/live-chart/commit/1c090e18fa4ae9f3ccfe0f38d619ebeccd7d6361
Should fix the issue you noticed, which was - I believe - unrelated to the number of series you had on the chart.
Let me know if it's working.
Yes, no more crashes :tada: , however only one serie is coloured. :thinking:
Using this:
renderer.region = new LiveChart.Region.between(50, 100).with_line_color(color_critical_line).with_area_color(color_critical_area);
I just tested your monitor app (with livechart pointing on HEAD).
I removed the condition on "colorize only if series_quantity == 1
at https://github.com/stsdc/monitor/blob/6a6a4dbe8de14e89de4bcbe9d9c589f56af4220b/src/Widgets/Chart/Chart.vala#L61
And I've got all series colored :
Can you confirm that everything is ok ?
Can confirm everything works! It was probably just a strange case were only one thread was loaded plus I have a pretty hi dpi, so wasn't able to notice. Sorry for that :sweat_smile: and thanks for this feature. Issue can be closed!
Finally released in 1.10.0.