Skip to content

Commit

Permalink
Freezed API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lcallarec committed Mar 20, 2020
1 parent 8539201 commit aece3f7
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
101 changes: 97 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,114 @@

# Live Chart

## 1.0.0-beta1 (API freezed)

**Live Chart** is a real-time charting library for GTK3 and Vala, based on [Cairo](https://cairographics.org/).

## Features

Live chart, as its name imply, aims to render real-time series.

* Render many series withing a single chart
* Automatic y-axis adjustement
* Support chart area / window live resizing
* Extendable

## Screenshots

![animated_chart](docs/animated.gif)
![chart_1](docs/chart1.png)
![](docs/chart1.gif) ![chart_1](docs/chart2.gif)

## API

*N.B.: Classes and methods available in the source code and not documented here - even if they are public - are subject to changes in a future release*

### Chart

```vala
var chart = LiveChart.Chart();
```

As `Chart` object derives from `Gtk.DrawingArea`, don't forget to attach it to a `Gtk.Container` :

```vala
var window = new Gtk.Window();
window.add(chart);
```

### Series

A `Serie` is basically a structure that :

* Contains its own data set
* Has a name, like `Temperature in Paris`
* Know how it renders on the chart, like in `Bar`, `Line`...

#### Create a serie

```vala
// Serie with a default Line renderer
var serie_name = "Temperature in Paris";
var paris_temperature = new LiveChart.Serie(serie_name);
// Or inject the renderer
var serie_name = "Temperature in Paris";
var paris_temperature = new LiveChart.Serie(serie_name, new LiveChart.Bar());
```

Then register the `Serie` to the `Chart` :

```vala
var serie_name = "Temperature in Paris";
var paris_temperature = new LiveChart.Serie(serie_name);
chart.add_serie(paris);
```

#### Adding data points

Your `Serie` must have been registererd to the `Chart` before being able to add data points to this serie.

```vala
var serie_name = "Temperature in Paris";
var paris_temperature = new LiveChart.Serie(serie_name);
chart.add_serie(paris);
chart.add_value(paris_temperature, 19.5);
```

### Serie renderer

There's currently 3 built-in series available:

* Line series: [`LiveChart.Line`](https://github.com/lcallarec/live-chart/blob/master/src/line.vala)
* Curve series: [`LiveChart.Curve`](https://github.com/lcallarec/live-chart/blob/master/src/curve.vala)
* Bar series: [`LiveChart.Bar`](https://github.com/lcallarec/live-chart/blob/master/src/line.vala)

#### Configure a renderer

* Main color [`Gdk.RGBA`](https://valadoc.org/gdk-3.0/Gdk.RGBA.html)

```vala
var serie_name = "Temperature in Paris";
var paris_temperature = new LiveChart.Serie(serie_name);
paris_temperature.set_main_color({ 0.0, 0.1, 0.8, 1.0});
```

### Programmatic export

You can export your chart in `PNG` format :

```vala
var filename = "chart_export.png";
chart.to_png(filename);
```

## Deps

| dependency |
|----------------|
| libcairo2-dev |
| libgee-0.8-dev |
| libgtk-3-dev |

## Example

Expand Down
Binary file removed docs/animated.gif
Binary file not shown.
Binary file added docs/chart1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/chart1.png
Binary file not shown.
Binary file added docs/chart2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/live-chart.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class Example : Gtk.Window {
chart.legend = new LiveChart.HorizontalLegend();

chart.add_serie(heat);
chart.add_serie(rss);
chart.add_serie(heap);
chart.add_serie(rss);

var grid = new LiveChart.FixedTickIntervalGrid("MB", 100);
chart.grid = grid;
Expand Down Expand Up @@ -49,7 +49,7 @@ public class Example : Gtk.Window {

var heat_value = 200.0;
chart.add_value(heat, heat_value);
Timeout.add(5000, () => {
Timeout.add(2000, () => {
if (Random.double_range(0.0, 1.0) > 0.1) {
var new_value = Random.double_range(-20, 20.0);
if (heat_value + new_value > 0) heat_value += new_value;
Expand Down

0 comments on commit aece3f7

Please sign in to comment.