plotly / dash-pivottable

react-pivottable in Dash
MIT License
192 stars 52 forks source link

Specify plot size #31

Open rmaranhao opened 4 years ago

rmaranhao commented 4 years ago

Hi. I am integrating PivotTable with other components in the same screen. I have already included a scrollable DIV as suggested in #7 but I would really like to be able to specify the size of the plots. Due to the nature of my data I get very large plots that would be much better if rendered in a smaller format.

The code would be something like this:

    return  html.Div(id='div_pivot', children=[
                dash_pivottable.PivotTable(
                    id='Tabela',
                    data=data,
                    cols=dic_pivot['cols'],
                    #colOrder='key_a_to_z',
                    rows=dic_pivot['rows'],
                    #rowOrder='key_a_to_z',
                    rendererName='Table',
                    aggregatorName='Sum',
                    vals=dic_pivot['vals'],
                    valueFilter={},
                    hiddenFromAggregators=dic_pivot['hiddenFromAggregators'],
                    hiddenFromDragDrop=dic_pivot['vals'],
                    hiddenAttributes=hidden,                     
#The line below is a suggestion and causes an error in the current version
                    rendererOptions={'autosize':True, 'width':700, 'height':450,},
                ),], style={'height':'450px', 'overflow':'scroll', 'resize':'both'} )
xhluca commented 3 years ago

Hi @rmaranhao , thanks for opening the PR!

rendererOptions is not available in the API reference, which is why it causes an error.

For plot size, I believe it is controlled on the JS side of react-pivottable. It might be possible to modify the stylesheet (see this comment) but you will likely need to modify the react source code (see contributing FAQ for details). Here's the piece of code that controls the width/height. You will likely need to specify a plotlyOptions prop from the Renderer component being created in the previous link. See this line