Dynamic updates for RTBuilder charts

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic updates for RTBuilder charts

Agustin Meriles
Hi everyone! I'm Agustin. I'm new at the Pharo/Moose community, so this is my first post.

I'm playing around with Roassal (which by the way, I found really interesting), and my goal is to have a typical chart (let's say piechart, or barchart) that updates dinamically as the data arrives.
I cannot figure out how to do this, without replacing the full data set and creating the instance again.

So, if I build this chart:

b := RTPieBuilder new.
b interaction popup.
b objects: #(10 4 1 2 5).
b slice: [ :aNumber | aNumber ].
b normalizer distinctColor.
b labelled.
b build.
^ b view.

then if I update the objects collection

b objects: #(15 5 3 20 31 7 8).

the only way to reflects the change in the piechart is to create a new instance.

Does Roassal provides any functionality for doing this and am I missing something?

Thanks in advance!





_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic updates for RTBuilder charts

abergel
Hi Agustin!

You are very welcome!

Yes, you need to recreate a new PieChart. But this is easy and efficient. Try the following:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"We create an empty view. The view will contain the button and the pie."
view := RTView new.

"fillView is block that:
        (i) remove all the elements in the view (except the button);
        (ii) create a new pie with totally random data
        (iii) force a screen refresh with #signalUpdate"
fillView :=
[
        | b |
        view clean.
        b := RTPieBuilder new.
       
        "The RTPieBuilder will create the pie in the view"
        b view: view.
        b interaction popup.
        b objects: ((1 to: 10 atRandom) collect: [ :i | 30 atRandom ]).
        b slice: [ :aNumber | aNumber ].
        b normalizer distinctColor.
        b labelled.
        b build.
        view signalUpdate
].

"Add a button menu to the view"
view addMenu: 'Generate new data' callback: [ fillView value ].

"We want some data when opening the view"
fillView value.
view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Let us know if you have any further question

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



> On Apr 5, 2016, at 3:18 PM, Agustin Meriles <[hidden email]> wrote:
>
> Hi everyone! I'm Agustin. I'm new at the Pharo/Moose community, so this is my first post.
>
> I'm playing around with Roassal (which by the way, I found really interesting), and my goal is to have a typical chart (let's say piechart, or barchart) that updates dinamically as the data arrives.
> I cannot figure out how to do this, without replacing the full data set and creating the instance again.
>
> So, if I build this chart:
>
> b := RTPieBuilder new.
> b interaction popup.
> b objects: #(10 4 1 2 5).
> b slice: [ :aNumber | aNumber ].
> b normalizer distinctColor.
> b labelled.
> b build.
> ^ b view.
>
> then if I update the objects collection
>
> b objects: #(15 5 3 20 31 7 8).
>
> the only way to reflects the change in the piechart is to create a new instance.
>
> Does Roassal provides any functionality for doing this and am I missing something?
>
> Thanks in advance!
>
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic updates for RTBuilder charts

Agustin Meriles
Hi Alexandre!

Thank you so much for your answer.
I will explore how to best approach that behaviour to my live model. 

thanks again!

2016-04-05 16:45 GMT-03:00 Alexandre Bergel <[hidden email]>:
Hi Agustin!

You are very welcome!

Yes, you need to recreate a new PieChart. But this is easy and efficient. Try the following:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"We create an empty view. The view will contain the button and the pie."
view := RTView new.

"fillView is block that:
        (i) remove all the elements in the view (except the button);
        (ii) create a new pie with totally random data
        (iii) force a screen refresh with #signalUpdate"
fillView :=
[
        | b |
        view clean.
        b := RTPieBuilder new.

        "The RTPieBuilder will create the pie in the view"
        b view: view.
        b interaction popup.
        b objects: ((1 to: 10 atRandom) collect: [ :i | 30 atRandom ]).
        b slice: [ :aNumber | aNumber ].
        b normalizer distinctColor.
        b labelled.
        b build.
        view signalUpdate
].

"Add a button menu to the view"
view addMenu: 'Generate new data' callback: [ fillView value ].

"We want some data when opening the view"
fillView value.
view
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Let us know if you have any further question

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



> On Apr 5, 2016, at 3:18 PM, Agustin Meriles <[hidden email]> wrote:
>
> Hi everyone! I'm Agustin. I'm new at the Pharo/Moose community, so this is my first post.
>
> I'm playing around with Roassal (which by the way, I found really interesting), and my goal is to have a typical chart (let's say piechart, or barchart) that updates dinamically as the data arrives.
> I cannot figure out how to do this, without replacing the full data set and creating the instance again.
>
> So, if I build this chart:
>
> b := RTPieBuilder new.
> b interaction popup.
> b objects: #(10 4 1 2 5).
> b slice: [ :aNumber | aNumber ].
> b normalizer distinctColor.
> b labelled.
> b build.
> ^ b view.
>
> then if I update the objects collection
>
> b objects: #(15 5 3 20 31 7 8).
>
> the only way to reflects the change in the piechart is to create a new instance.
>
> Does Roassal provides any functionality for doing this and am I missing something?
>
> Thanks in advance!
>
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev



--
Ing. Agustín Meriles
Jefe Departamento de Desarrollo
Pinard Software e Innovación S.R.L.


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev