Zoom x-axis in RTGrapher?

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

Zoom x-axis in RTGrapher?

alistairgrant
Hi Everyone,

I'm using RTGrapher to display a simple line graph where the x-axis
has values from roughly 0 to 500,000 and the y-axis from 0 to 20.

What I'd like to be able to do is to zoom in just the x-axis, i.e.
instead of displaying the entire 0 to 500,000 range, be able to narrow
it down in stages, to, e.g. 430,000 to 431,000.  The y-axis would be
unchanged, i.e. still 0 to 20.  Ideally I could then scroll left and
right along the x-axis.

I can create a Spec widget with buttons to redraw the graph, but was
wondering if there was a better way.

Thanks,
Alistair

Reply | Threaded
Open this post in threaded view
|

Re: Zoom x-axis in RTGrapher?

abergel
Hi Alistair!

Yes, this is something we thought about some times ago.

After updating Roassal, try this:
-=-=-=-=-=-=-=-=-=-=-=-=
v := RTView new.
b := [ :someClasses |
        g := RTGrapher new.
        g view: v.
        ds := RTData new.
        ds points: someClasses.
        ds y: [ :cls | cls numberOfMethods ].
        ds x: [ :cls | cls numberOfLinesOfCode ].
        g add: ds.

        g addDecorator: (RTRangeSelector new callback: [:es |
                | classesToZoomIn |
                classesToZoomIn := es collect: #model.
                v cleanAll.
                b value: classesToZoomIn
        ]).
        g build.
].

b value: RTShape withAllSubclasses.
v
-=-=-=-=-=-=-=-=-=-=-=-=

Let me know how it goes.

Cheers,
Alexandre

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



> On Mar 28, 2018, at 4:02 AM, Alistair Grant <[hidden email]> wrote:
>
> Hi Everyone,
>
> I'm using RTGrapher to display a simple line graph where the x-axis
> has values from roughly 0 to 500,000 and the y-axis from 0 to 20.
>
> What I'd like to be able to do is to zoom in just the x-axis, i.e.
> instead of displaying the entire 0 to 500,000 range, be able to narrow
> it down in stages, to, e.g. 430,000 to 431,000.  The y-axis would be
> unchanged, i.e. still 0 to 20.  Ideally I could then scroll left and
> right along the x-axis.
>
> I can create a Spec widget with buttons to redraw the graph, but was
> wondering if there was a better way.
>
> Thanks,
> Alistair
>


Reply | Threaded
Open this post in threaded view
|

Re: Zoom x-axis in RTGrapher?

alistairgrant
Hi Alexandre,

Thanks! (more below)


On 28 March 2018 at 14:56, Alexandre Bergel <[hidden email]> wrote:

> Hi Alistair!
>
> Yes, this is something we thought about some times ago.
>
> After updating Roassal, try this:
> -=-=-=-=-=-=-=-=-=-=-=-=
> v := RTView new.
> b := [ :someClasses |
>         g := RTGrapher new.
>         g view: v.
>         ds := RTData new.
>         ds points: someClasses.
>         ds y: [ :cls | cls numberOfMethods ].
>         ds x: [ :cls | cls numberOfLinesOfCode ].
>         g add: ds.
>
>         g addDecorator: (RTRangeSelector new callback: [:es |
>                 | classesToZoomIn |
>                 classesToZoomIn := es collect: #model.
>                 v cleanAll.
>                 b value: classesToZoomIn
>         ]).
>         g build.
> ].
>
> b value: RTShape withAllSubclasses.
> v
> -=-=-=-=-=-=-=-=-=-=-=-=
>
> Let me know how it goes.

Great, it's working fine!

If you select an empty portion of the graph an error is raised -
"Error: No dataset has been added?".

I solved this with the following change, which simply ignores empty
areas and notifies the user:


RTRangeSelector>>callbackWithSelectedElements
    | selectedElements |
    selectedElements := self elementsWithinTheSelection.
    selectedElements ifEmpty: [
        UIManager default inform: 'Empty region selected, ignoring'.
        ^self ].
    self evaluateCallBackWithElements: selectedElements


That was a quick hack, so there could well be a better solution.

From what I can see, there isn't a way to zoom back out or scroll left
and right.

I might modify RTRangeSelector so that a right click zooms out.  I'll
have to think about scrolling a bit more.


Thanks again!
Alistair


> Cheers,
> Alexandre
>
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>> On Mar 28, 2018, at 4:02 AM, Alistair Grant <[hidden email]> wrote:
>>
>> Hi Everyone,
>>
>> I'm using RTGrapher to display a simple line graph where the x-axis
>> has values from roughly 0 to 500,000 and the y-axis from 0 to 20.
>>
>> What I'd like to be able to do is to zoom in just the x-axis, i.e.
>> instead of displaying the entire 0 to 500,000 range, be able to narrow
>> it down in stages, to, e.g. 430,000 to 431,000.  The y-axis would be
>> unchanged, i.e. still 0 to 20.  Ideally I could then scroll left and
>> right along the x-axis.
>>
>> I can create a Spec widget with buttons to redraw the graph, but was
>> wondering if there was a better way.
>>
>> Thanks,
>> Alistair
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Zoom x-axis in RTGrapher?

abergel
Easy.

You can add a reset button:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
v := RTView new.
b := [ :someClasses |
       g := RTGrapher new.
       g view: v.
       ds := RTData new.
       ds points: someClasses.
       ds y: [ :cls | cls numberOfMethods ].
       ds x: [ :cls | cls numberOfLinesOfCode ].
       g add: ds.

       g addDecorator: (RTRangeSelector new callback: [ :es |
               | classesToZoomIn |
                                       
               classesToZoomIn := es collect: #model.
               v cleanAll.
               b value: classesToZoomIn
       ]).
       g build.
        v addMenu: 'Reset' callback: [ v cleanAll. b value: RTShape withAllSubclasses ].
].

b value: RTShape withAllSubclasses.
v
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

If you wish to have a right click, you can do:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
v := RTView new.
b := [ :someClasses |
       g := RTGrapher new.
       g view: v.
       ds := RTData new.
       ds points: someClasses.
       ds y: [ :cls | cls numberOfMethods ].
       ds x: [ :cls | cls numberOfLinesOfCode ].
       g add: ds.

       g addDecorator: (RTRangeSelector new callback: [ :es |
               | classesToZoomIn |
                                       
               classesToZoomIn := es collect: #model.
               v cleanAll.
               b value: classesToZoomIn
       ]).
       g build.
                 v when: TRMouseRightClick do: [ v cleanAll. b value: RTShape withAllSubclasses. v signalUpdate ].
].

b value: RTShape withAllSubclasses.
v
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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



> On Mar 29, 2018, at 5:45 AM, Alistair Grant <[hidden email]> wrote:
>
> Hi Alexandre,
>
> Thanks! (more below)
>
>
> On 28 March 2018 at 14:56, Alexandre Bergel <[hidden email]> wrote:
>> Hi Alistair!
>>
>> Yes, this is something we thought about some times ago.
>>
>> After updating Roassal, try this:
>> -=-=-=-=-=-=-=-=-=-=-=-=
>> v := RTView new.
>> b := [ :someClasses |
>>        g := RTGrapher new.
>>        g view: v.
>>        ds := RTData new.
>>        ds points: someClasses.
>>        ds y: [ :cls | cls numberOfMethods ].
>>        ds x: [ :cls | cls numberOfLinesOfCode ].
>>        g add: ds.
>>
>>        g addDecorator: (RTRangeSelector new callback: [:es |
>>                | classesToZoomIn |
>>                classesToZoomIn := es collect: #model.
>>                v cleanAll.
>>                b value: classesToZoomIn
>>        ]).
>>        g build.
>> ].
>>
>> b value: RTShape withAllSubclasses.
>> v
>> -=-=-=-=-=-=-=-=-=-=-=-=
>>
>> Let me know how it goes.
>
> Great, it's working fine!
>
> If you select an empty portion of the graph an error is raised -
> "Error: No dataset has been added?".
>
> I solved this with the following change, which simply ignores empty
> areas and notifies the user:
>
>
> RTRangeSelector>>callbackWithSelectedElements
>    | selectedElements |
>    selectedElements := self elementsWithinTheSelection.
>    selectedElements ifEmpty: [
>        UIManager default inform: 'Empty region selected, ignoring'.
>        ^self ].
>    self evaluateCallBackWithElements: selectedElements
>
>
> That was a quick hack, so there could well be a better solution.
>
> From what I can see, there isn't a way to zoom back out or scroll left
> and right.
>
> I might modify RTRangeSelector so that a right click zooms out.  I'll
> have to think about scrolling a bit more.
>
>
> Thanks again!
> Alistair
>
>
>> Cheers,
>> Alexandre
>>
>> --
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.bergel.eu
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>
>>
>>
>>> On Mar 28, 2018, at 4:02 AM, Alistair Grant <[hidden email]> wrote:
>>>
>>> Hi Everyone,
>>>
>>> I'm using RTGrapher to display a simple line graph where the x-axis
>>> has values from roughly 0 to 500,000 and the y-axis from 0 to 20.
>>>
>>> What I'd like to be able to do is to zoom in just the x-axis, i.e.
>>> instead of displaying the entire 0 to 500,000 range, be able to narrow
>>> it down in stages, to, e.g. 430,000 to 431,000.  The y-axis would be
>>> unchanged, i.e. still 0 to 20.  Ideally I could then scroll left and
>>> right along the x-axis.
>>>
>>> I can create a Spec widget with buttons to redraw the graph, but was
>>> wondering if there was a better way.
>>>
>>> Thanks,
>>> Alistair
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Zoom x-axis in RTGrapher?

alistairgrant
Hi Alexandre,

On 29 March 2018 at 15:07, Alexandre Bergel <[hidden email]> wrote:

> Easy.
>
> You can add a reset button:
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> v := RTView new.
> b := [ :someClasses |
>        g := RTGrapher new.
>        g view: v.
>        ds := RTData new.
>        ds points: someClasses.
>        ds y: [ :cls | cls numberOfMethods ].
>        ds x: [ :cls | cls numberOfLinesOfCode ].
>        g add: ds.
>
>        g addDecorator: (RTRangeSelector new callback: [ :es |
>                | classesToZoomIn |
>
>                classesToZoomIn := es collect: #model.
>                v cleanAll.
>                b value: classesToZoomIn
>        ]).
>        g build.
>         v addMenu: 'Reset' callback: [ v cleanAll. b value: RTShape withAllSubclasses ].
> ].
>
> b value: RTShape withAllSubclasses.
> v
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Thanks!  All working now...

Cheers,
Alistair