Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to access to added series #14

Closed
stsdc opened this issue Jul 4, 2020 · 4 comments
Closed

Allow to access to added series #14

stsdc opened this issue Jul 4, 2020 · 4 comments

Comments

@stsdc
Copy link
Contributor

stsdc commented Jul 4, 2020

I'm adding a few series and have to create another ArrayList to manipulate them. Would be nice to have an access to chart.series.

        private Gee.ArrayList<Serie> series = new Gee.ArrayList<Serie>();

Use case:

    public void update (int serie_number, double value) {
        chart.add_value (chart.series[serie_number], value);
    }
@lcallarec
Copy link
Owner

I could give access to series private chart array list, but it may lead to inconsistencies / bugs if you manually add or remove series.

To match your use case, I could add an chart.add_value method which take the serie_number instead of the Series :

public void add_value_by_index(int serie_index, double value) {
    add_value(series[serie_index], value);
}

Another option would be to have access to some kind of read-only array list ;

    public void update (int serie_number, double value) {
        Gee.List<Serie> series = chart.get_ro_series();
        chart.add_value (series.get(serie_number, value);
    }

IMHO, the both options match your use case. The first is straight forward, the second is more versatile (hence, it could resolves more use cases) but requires a bit more code on your side.

What do you think ?

@stsdc
Copy link
Contributor Author

stsdc commented Jul 6, 2020

I created serie_list = new Gee.ArrayList<LiveChart.Serie> (); and it works, but, well, now I have two lists with same content 😅
chart.add_value_by_index would be cool

@lcallarec
Copy link
Owner

https://github.com/lcallarec/live-chart/releases/tag/1.5.1

Please let me know when it works on your side.

Thanks !

@stsdc
Copy link
Contributor Author

stsdc commented Jul 12, 2020

works really nice

thank You!

@stsdc stsdc closed this as completed Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants