Matrix Sunburst: Labelled arcs

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

Matrix Sunburst: Labelled arcs

Offray Vladimir Luna Cárdenas-2
Hi,

Some time ago I asked about how to make some kind of matrix sunburst, like the one on [1]. Thanks to the help of the community, specially Milton we're almost there. Look at this:



[1] http://www.theguardian.com/world/interactive/2012/may/08/gay-rights-united-states

Now I would like to locate better the labels for each country, ideally at the center of each arc. The important part of message which is making this is here:

=================
PublishedMedInfo>>addLineSeparatorsTo:  aView withData: data separatedBy: aDistance centerSized: aSize
    | e1 e2 ang cos sin radio label countries |
    label := RTLabel new
        height: 16.
    countries := self medDataMatrix at: 1.
    1 to: data children size do: [ :i |
        e1 := (RTBox new size: 1) element.
        ang := ((i - 0) * 360 / data children size) degreesToRadians.
        cos := ang cos.
        sin := ang sin.
        radio := aSize.
        e1 translateTo: (radio * cos)@(radio * sin).
        e2 := (RTBox new size: 1) element.
        radio := self arcWidth * 30 + aSize.
        e2 translateTo: (radio * cos )@ (radio * sin).
        label text: (countries at: (countries size + 1 - i)).
        aView
            add: e1;
            add: e2;
            add: (RTLine new width: aDistance; color: Color white;  edgeFrom: e1 to: e2);
            add: (label element translateBy: (((radio - 70) * cos)"- 15" )@ (radio - 70 * sin) "+ 15")
         ]
=================

as you can see the e1 and e2 edges are the ones that create the separation between columns in the matrix sunburst and are computed inside an iterator. I would like to keep a temporal edge that stores the value of the e2 edge in the previous run and locate the label in the coordinates between actual e2 and the previous one (lets call it "edgeTemp"). How can I do this?

Thanks,

Offray

Ps: I have subscribed this new direction because my previous one is failing tonight. Probably I will unsubscribe the previous and keep this one for Pharo and Moose mailing lists.

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

Re: Matrix Sunburst: Labelled arcs

Offray Vladimir Luna Cárdenas-2
Hi again,

If someone wants to run the code in the screenshot, just use the dummy data file attached and load this:


    Gofer new
           smalltalkhubUser: 'Offray' project: 'Dataviz';
            package: 'Dataviz';
          load.

Cheers,

Offray

On 08/12/15 21:53, Offray Vladimir Luna Cárdenas wrote:
Hi,

Some time ago I asked about how to make some kind of matrix sunburst, like the one on [1]. Thanks to the help of the community, specially Milton we're almost there. Look at this:



[1] http://www.theguardian.com/world/interactive/2012/may/08/gay-rights-united-states

Now I would like to locate better the labels for each country, ideally at the center of each arc. The important part of message which is making this is here:

=================
PublishedMedInfo>>addLineSeparatorsTo:  aView withData: data separatedBy: aDistance centerSized: aSize
    | e1 e2 ang cos sin radio label countries |
    label := RTLabel new
        height: 16.
    countries := self medDataMatrix at: 1.
    1 to: data children size do: [ :i |
        e1 := (RTBox new size: 1) element.
        ang := ((i - 0) * 360 / data children size) degreesToRadians.
        cos := ang cos.
        sin := ang sin.
        radio := aSize.
        e1 translateTo: (radio * cos)@(radio * sin).
        e2 := (RTBox new size: 1) element.
        radio := self arcWidth * 30 + aSize.
        e2 translateTo: (radio * cos )@ (radio * sin).
        label text: (countries at: (countries size + 1 - i)).
        aView
            add: e1;
            add: e2;
            add: (RTLine new width: aDistance; color: Color white;  edgeFrom: e1 to: e2);
            add: (label element translateBy: (((radio - 70) * cos)"- 15" )@ (radio - 70 * sin) "+ 15")
         ]
=================

as you can see the e1 and e2 edges are the ones that create the separation between columns in the matrix sunburst and are computed inside an iterator. I would like to keep a temporal edge that stores the value of the e2 edge in the previous run and locate the label in the coordinates between actual e2 and the previous one (lets call it "edgeTemp"). How can I do this?

Thanks,

Offray

Ps: I have subscribed this new direction because my previous one is failing tonight. Probably I will unsubscribe the previous and keep this one for Pharo and Moose mailing lists.


_______________________________________________
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

matriz-sunburst.csv (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Matrix Sunburst: Labelled arcs

Tudor Girba-2
Looks great. Only the labels have to be aligned in the center of the arcs, and then it should be quite fine.

Cheers,
Doru


> On Dec 8, 2015, at 10:00 PM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
>
> Hi again,
>
> If someone wants to run the code in the screenshot, just use the dummy data file attached and load this:
>
>
>     Gofer new
>            smalltalkhubUser: 'Offray' project: 'Dataviz';
>             package: 'Dataviz';
>           load.
>
> Cheers,
>
> Offray
>
> On 08/12/15 21:53, Offray Vladimir Luna Cárdenas wrote:
>> Hi,
>>
>> Some time ago I asked about how to make some kind of matrix sunburst, like the one on [1]. Thanks to the help of the community, specially Milton we're almost there. Look at this:
>>
>> <Mail Attachment.png>
>>
>> [1] http://www.theguardian.com/world/interactive/2012/may/08/gay-rights-united-states
>>
>> Now I would like to locate better the labels for each country, ideally at the center of each arc. The important part of message which is making this is here:
>>
>> =================
>> PublishedMedInfo>>addLineSeparatorsTo:  aView withData: data separatedBy: aDistance centerSized: aSize
>>     | e1 e2 ang cos sin radio label countries |
>>     label := RTLabel new
>>         height: 16.
>>     countries := self medDataMatrix at: 1.
>>     1 to: data children size do: [ :i |
>>         e1 := (RTBox new size: 1) element.
>>         ang := ((i - 0) * 360 / data children size) degreesToRadians.
>>         cos := ang cos.
>>         sin := ang sin.
>>         radio := aSize.
>>         e1 translateTo: (radio * cos)@(radio * sin).
>>         e2 := (RTBox new size: 1) element.
>>         radio := self arcWidth * 30 + aSize.
>>         e2 translateTo: (radio * cos )@ (radio * sin).
>>         label text: (countries at: (countries size + 1 - i)).
>>         aView
>>             add: e1;
>>             add: e2;
>>             add: (RTLine new width: aDistance; color: Color white;  edgeFrom: e1 to: e2);
>>             add: (label element translateBy: (((radio - 70) * cos)"- 15" )@ (radio - 70 * sin) "+ 15")
>>          ]
>> =================
>>
>> as you can see the e1 and e2 edges are the ones that create the separation between columns in the matrix sunburst and are computed inside an iterator. I would like to keep a temporal edge that stores the value of the e2 edge in the previous run and locate the label in the coordinates between actual e2 and the previous one (lets call it "edgeTemp"). How can I do this?
>>
>> Thanks,
>>
>> Offray
>>
>> Ps: I have subscribed this new direction because my previous one is failing tonight. Probably I will unsubscribe the previous and keep this one for Pharo and Moose mailing lists.
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>>
>> [hidden email]
>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
> <matriz-sunburst.csv>_______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com

"Being happy is a matter of choice."



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

Re: Matrix Sunburst: Labelled arcs

Offray Vladimir Luna Cárdenas-2
Yep, this kind of tricky positioning is what I was trying to figure out
at the begining of the thread 😉 (that's why the question about the
"temporal" edge).

Pharo/Roassal/Moose has been an amazing learning experience and even
without the proper time for a continuous practice, this year an a half
has been really fun and empowering.

Thanks, as always.

Offray

El 2015-12-08 23:08, Tudor Girba escribió:

> Looks great. Only the labels have to be aligned in the center of the
> arcs, and then it should be quite fine.
>
> Cheers,
> Doru
>
>
>> On Dec 8, 2015, at 10:00 PM, Offray Vladimir Luna Cárdenas
>> <[hidden email]> wrote:
>>
>> Hi again,
>>
>> If someone wants to run the code in the screenshot, just use the dummy
>> data file attached and load this:
>>
>>
>>     Gofer new
>>            smalltalkhubUser: 'Offray' project: 'Dataviz';
>>             package: 'Dataviz';
>>           load.
>>
>> Cheers,
>>
>> Offray
>>
>> On 08/12/15 21:53, Offray Vladimir Luna Cárdenas wrote:
>>> Hi,
>>>
>>> Some time ago I asked about how to make some kind of matrix sunburst,
>>> like the one on [1]. Thanks to the help of the community, specially
>>> Milton we're almost there. Look at this:
>>>
>>> <Mail Attachment.png>
>>>
>>> [1]
>>> http://www.theguardian.com/world/interactive/2012/may/08/gay-rights-united-states
>>>
>>> Now I would like to locate better the labels for each country,
>>> ideally at the center of each arc. The important part of message
>>> which is making this is here:
>>>
>>> =================
>>> PublishedMedInfo>>addLineSeparatorsTo:  aView withData: data
>>> separatedBy: aDistance centerSized: aSize
>>>     | e1 e2 ang cos sin radio label countries |
>>>     label := RTLabel new
>>>         height: 16.
>>>     countries := self medDataMatrix at: 1.
>>>     1 to: data children size do: [ :i |
>>>         e1 := (RTBox new size: 1) element.
>>>         ang := ((i - 0) * 360 / data children size) degreesToRadians.
>>>         cos := ang cos.
>>>         sin := ang sin.
>>>         radio := aSize.
>>>         e1 translateTo: (radio * cos)@(radio * sin).
>>>         e2 := (RTBox new size: 1) element.
>>>         radio := self arcWidth * 30 + aSize.
>>>         e2 translateTo: (radio * cos )@ (radio * sin).
>>>         label text: (countries at: (countries size + 1 - i)).
>>>         aView
>>>             add: e1;
>>>             add: e2;
>>>             add: (RTLine new width: aDistance; color: Color white;  
>>> edgeFrom: e1 to: e2);
>>>             add: (label element translateBy: (((radio - 70) * cos)"-
>>> 15" )@ (radio - 70 * sin) "+ 15")
>>>          ]
>>> =================
>>>
>>> as you can see the e1 and e2 edges are the ones that create the
>>> separation between columns in the matrix sunburst and are computed
>>> inside an iterator. I would like to keep a temporal edge that stores
>>> the value of the e2 edge in the previous run and locate the label in
>>> the coordinates between actual e2 and the previous one (lets call it
>>> "edgeTemp"). How can I do this?
>>>
>>> Thanks,
>>>
>>> Offray
>>>
>>> Ps: I have subscribed this new direction because my previous one is
>>> failing tonight. Probably I will unsubscribe the previous and keep
>>> this one for Pharo and Moose mailing lists.
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>>
>>> [hidden email]
>>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>>
>> <matriz-sunburst.csv>_______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
> --
> www.tudorgirba.com
>
> "Being happy is a matter of choice."
>
>
>
> _______________________________________________
> 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