reinert / dygraph-elements

Graph element set powered by dygraphs
1 stars 0 forks source link

[Feature Request] Expose the roll-period option #4

Closed masonlouchart closed 8 years ago

masonlouchart commented 8 years ago

I would like to be able to activate declaratively some buttons/links to play with the rollPeriod option. I think it's frequent to have buttons like in the link-interaction example (hour, day, week, month, full).

I'm not sure about the way to do this. I'm thinking to a dygraph-roll-periods element which will display links by default or use the given template (paper-button, paper-icon-button, etc...) if there is one.

It could be resulted in something like that:

<dygraph-line data="[[data]]" options="[[options]]" roll-period="[[_selectedRollPeriod]]">
    <!-- creates links for roll periods hour, week, month and full -->
    <dygraph-roll-periods selected="{{_selectedRollPeriod}}"></dygraph-roll-periods>

    <!-- creates links only for roll periods week and month -->
    <dygraph-roll-periods periods="['week', 'month']" selected="{{_selectedRollPeriod}}"></dygraph-roll-periods>

    <!-- creates paper-button for roll periods week, month and full -->
    <dygraph-roll-periods periods="['week', 'month', 'full']" selected="{{_selectedRollPeriod}}">
       <template>
         <paper-button raised noink value="[[period.value]]">[[period.name]]</paper-button>
       </template>
    </dygraph-roll-periods>
</dygraph-line>

Note: only one dygraph-roll-period at a time and its "periods" attribute will be a valid JS array.

Maybe I'm gone too far and have the option roll-period exposed could be enough ❓

reinert commented 8 years ago

Sorry for the delay. This case you related is more appropriate as a composite element, i.e., a new element wrapping the dygraph-line and exposing these features. I have many of those with some buttons triggering specific functionalities. I suggest you do like so.

masonlouchart commented 8 years ago

Using composition why not. But I'm still thinking it should be an element of this group. It could own the functions to zoom and unzoom on a specific range. I added this feature (using composition) to my element and it was pretty boring to do it.

reinert commented 8 years ago

Sorry! You meant to expose the http://dygraphs.com/options.html#rollPeriod option. Definitely it's in the scope of the element. I'll do that for you.