(Google Embed API) How to change chart-table-style width

徘徊边缘 提交于 2019-12-11 13:47:56

问题


(This is regarding google-embed-api NOT google charts, Stack Overflow won't let me create a new tag without 1500 reputation)

Hello,

I'm not incredible at CSS, and am working on a project where I must present a bunch of columns per dimension using googles new charts embed API. The chart is created through a js call to gapi.analytics.googleCharts.DataChart() which creates what I want, perfectly, however the CSS settings in the JS call are overriding the one's I specify.

  1. Calling gapi.analytics.googleCharts.DataChart()

  2. Creates a google charts table, in the div below, with width set to 450px

  3. The js created in-div css style overrides my CSS file's width : 100%

Any help would be huge, and thanks! -Alex


回答1:


I found the answer JIC anyone else is looking

Rather than try to override the styling in CSS, I found that google charts offers a width argument in the options elements. To set the chart width simply add options and define width in options: {width: '100%'}

    chart: {
          type: 'TABLE',
          container: 'sessions_table',
          options: {width: '100%'}
        }



回答2:


chart: {
      type: 'TABLE',
      container: 'sessions_table',
      options: {width: '100%'}
    }

this is only work for Table charts.when it come's for Line charts you have to trigger the chart redraw on window resize.

You can see the code in this answer



来源:https://stackoverflow.com/questions/26393036/google-embed-api-how-to-change-chart-table-style-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!