live-chart icon indicating copy to clipboard operation
live-chart copied to clipboard

Add multicolor feature to line and area

Open stsdc opened this issue 2 years ago • 8 comments

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.

image

stsdc avatar Mar 12 '22 15:03 stsdc

Ok, if you need that feature, I'll take a look.

lcallarec avatar Mar 14 '22 09:03 lcallarec

ping :eyes:

stsdc avatar Oct 01 '22 21:10 stsdc

Shame on me. Time flies. I promise to take a look this week.

lcallarec avatar Oct 02 '22 19:10 lcallarec

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

lcallarec avatar Oct 04 '22 17:10 lcallarec

Just asking : do you have any needs to define more than one "area", i.e. "high (in orange)" and "very high (in red)" ?

lcallarec avatar Oct 13 '22 12:10 lcallarec

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.

stsdc avatar Oct 13 '22 13:10 stsdc

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.

lcallarec avatar Oct 13 '22 15:10 lcallarec

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 !

lcallarec avatar Oct 15 '22 11:10 lcallarec

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!

Zrzut ekranu z 2022-11-01 21 18 05

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:

stsdc avatar Nov 01 '22 20:11 stsdc

I'm a bit frightened about the crash you experienced. Was it a segfault ? Have you got any log about that crash ?

lcallarec avatar Nov 29 '22 16:11 lcallarec

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);

stsdc avatar Nov 29 '22 23:11 stsdc

Yes, thanks, it helps. Let me figure out what happened.

lcallarec avatar Nov 30 '22 08:11 lcallarec

@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.

lcallarec avatar Dec 01 '22 11:12 lcallarec

Yes, no more crashes :tada: , however only one serie is coloured. :thinking:

Zrzut ekranu z 2022-12-08 21 49 52

Using this:

renderer.region = new LiveChart.Region.between(50, 100).with_line_color(color_critical_line).with_area_color(color_critical_area);

stsdc avatar Dec 08 '22 20:12 stsdc

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 :

Screenshot from 2022-12-10 17 23 00

Can you confirm that everything is ok ?

lcallarec avatar Dec 10 '22 16:12 lcallarec

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!

Zrzut ekranu z 2022-12-10 18 14 32

stsdc avatar Dec 10 '22 17:12 stsdc

Finally released in 1.10.0.

lcallarec avatar Jan 07 '24 17:01 lcallarec