简体   繁体   English

将Google表格加载到Dashboard中的Google图表

[英]Loading google sheets to google charts in Dashboard

I'm having trouble displaying google sheets info on the dashboard. 我在仪表板上显示Google表格信息时遇到问题。 The x and y-axis labels show up like Generalxxx . x和y轴标签显示为Generalxxx The data is from here . 数据来自这里

 var laptimeChart = new google.visualization.ChartWrapper({
            'chartType': 'ColumnChart',
            'containerId': 'chart_div',
            'width': '500',
            'height': '500',
            'view': { 'columns': [1,2] }
        });

the chart seems to be using the "General" format by default 该图表默认情况下似乎使用“常规”格式

to correct, set a specific format for each axis... 要更正,请为每个轴设置特定format ...

      options: {
        hAxis: {
          format: '0'
        },
        vAxis: {
          format: '#,##0'
        }
      },

see following working snippet... 请参阅以下工作片段...

 google.charts.load('current', { packages: ['controls', 'corechart', 'table'] }).then(function () { var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1PlT8k6qXsCkOCEEJFn7apKYgDunLi1Lzmnmo_AKQBXc/edit#gid=0'); query.send(handleQueryResponse); function handleQueryResponse(response) { if (response.isError()) { console.log('Error: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } var data = response.getDataTable(); var control = new google.visualization.ControlWrapper({ controlType: 'NumberRangeFilter', containerId: 'control', options: { filterColumnIndex: 1, ui: { format: { pattern: '0' } } } }); var chart = new google.visualization.ChartWrapper({ chartType: 'ColumnChart', containerId: 'chart', options: { hAxis: { format: '0' }, vAxis: { format: '#,##0' } }, view: { columns: [1, 2] } }); var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard')); dashboard.bind(control, chart); dashboard.draw(data); } }); 
 <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="dashboard"> <div id="control"></div> <div id="chart"></div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM