michael-gracie / gslides

Wrapper around Google APIs to create charts in Google Slides with python
https://michael-gracie.github.io/gslides
MIT License
31 stars 6 forks source link

Cannot resize the chart #54

Open OLR-Nadia opened 1 year ago

OLR-Nadia commented 1 year ago

Description

I want to try resizing the chart, but there's no option to resize it (but it's still a parameter in here (https://michael-gracie.github.io/gslides/gslides.html#module-gslides.chart)). It'll be helpful if there's a way to resize the chart as I'm trying to replace my template with those chart (currently it become small and distorted if trying to fit the template)

What I Did

def build_plot(dataframe: Frame, x_axis_column: str, y_axis_column: str, title: str, plot_type: str): if plot_type == "line": series = [Series.line(series_columns=[y_axis_column])] elif plot_type == "scatter": series = [Series.scatter(series_columns=[y_axis_column])] elif plot_type == "bar": series = [Series.column(series_columns=[y_axis_column], data_label_enabled=True)] else: raise ValueError("Invalid plot_type. Choose 'line', 'scatter', or 'bar'.")

    ch = Chart(
        data=dataframe.data,
        x_axis_column=x_axis_column,
        series=series,
        title=title,
        x_axis_label=x_axis_column,
        y_axis_label=y_axis_column,
        legend_position='TOP_LEGEND',
        y_min=0
    )
    return ch      

def chart_slide_id(self, frame_ch, frame_pillar_avg_eng, slide_service, prs):
    ch_graph = {}
    chart_dict = {}

    ch_graph['followers_growth'] = utils.build_plot(dataframe=frame_ch, x_axis_column='date', y_axis_column='followers_growth', title='Daily Followers Growth', plot_type='line')
    ch_graph['profile_views'] = utils.build_plot(dataframe=frame_ch, x_axis_column='date', y_axis_column='profile_views', title='Daily Profile Views', plot_type='line')
    ch_graph['pillar_avg_engagement'] = utils.build_plot(dataframe=frame_pillar_avg_eng, x_axis_column='content_pillar', y_axis_column='engagement', title='Avg Engagement Per Pillar', plot_type='bar')

    for key in ch_graph:
        prs.add_slide(
            objects=[ch_graph[key]],
            layout=(1, 1),
            title = f'{key}'
        )
OLR-Nadia commented 1 year ago

update: In the init method, I noticed there isn't a parameter for 'size'. However, the documentation mentions it. It might be helpful to clarify if setting the size for the chart is possible.