Comments (3)
You're welcome, glad that it works well !
from live-chart.
Hey @stsdc,
Since LiveChart 1.4.0, you can import your data in a much easier way.
Instead of :
var renderer = new LiveChart.SmoothLineArea();
var cpu = new LiveChart.Serie("CPU", renderer);
var chart = new LiveChart.Chart();
chart.add_serie(cpu);
//Other stuff
//To add the CPU history
var values = renderer.get_values();
values.clear(); // Clear all the data
//Here's your own data from ArrayList<double>
var cpu_history = new Gee.ArrayList<double?>();
cpu_history.add(10);
cpu_history.add(30);
cpu_history.add(20);
cpu_history.add(40);
cpu_history.add(20);
cpu_history.add(60);
cpu_history.add(30);
cpu_history.add(90);
var refresh_rate_is_ms = 2000; //your own refresh rate in milliseconds
var now = GLib.get_real_time() / 1000; //now in milliseconds
//the timestamp of the first point
//we are considering that it is "now", but because of your data structure
//it can be between now and now - 2secs), we can't guess
var ts = now - (cpu_history.size * refresh_rate_is_ms);
cpu_history.foreach((value) => {
values.add({ts, value});
ts += refresh_rate_is_ms;
return true;
});
You can write :
var cpu = new LiveChart.Serie("CPU", new LiveChart.SmoothLineArea(););
var chart = new LiveChart.Chart();
chart.add_serie(cpu);
//Here's your own data from ArrayList<double>
var cpu_history = new Gee.ArrayList<double?>();
cpu_history.add(10);
cpu_history.add(30);
cpu_history.add(20);
cpu_history.add(40);
cpu_history.add(20);
cpu_history.add(60);
cpu_history.add(30);
cpu_history.add(90);
var refresh_rate_is_ms = 2000; //your own refresh rate in milliseconds
cpu.clear(); // Clear all the data
chart.add_unaware_timestamp_collection(cpu, cpu_history, refresh_rate_is_ms);
Please let me know when it's working as expected on your side !
from live-chart.
Can confirm that it works. Good job. Thank You 😄
from live-chart.
Related Issues (20)
- Create NEWS.md HOT 1
- Allow to access to added series HOT 4
- Allow to add_unaware_timestamp_collection by serie number HOT 3
- Crushes if there is no value added instatly HOT 3
- Allow to clear serie by index HOT 7
- Allow to change colour of serie by index HOT 4
- Could support to show static chart with static data? HOT 4
- Some ideas to improve live-chart HOT 6
- Can't build it HOT 2
- The name `main_color' does not exist in the context of `LiveChart.Drawable' HOT 2
- Porting to pure C HOT 7
- Round corners HOT 9
- Tests require a graphical session HOT 1
- Add native support for stacked charts HOT 1
- Add multicolor feature to line and area HOT 17
- Showing minus value HOT 3
- Allow to set custom Area color
- Releasing Past 1.9.1 HOT 3
- Appearence: allow to hide labels, legend etc HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from live-chart.