2017-03-07 3 views
1

에 대한 반응 구글 차트를 만들려고 노력하지만 모든 장치에 대한 반응이 아니다이 난`는 자동으로 Google 웹 로그 분석에서 데이터를 보유 생성 내 웹 애플리케이션 차트에있는 모든 장치의 크기

자바 스크립트 코드 :

var dataChart1 = new gapi.analytics.googleCharts.DataChart({ 
    query: { 
     'ids': 'ga:789456123', // <-- Replace with the ids value for your view. 
     'start-date': '30daysAgo', 
     'end-date': 'yesterday', 
     'metrics': 'ga:pageviews', 
     'filters': 'ga:pagePath==<?php echo $page; ?>', 
     'dimensions': 'ga:date' 
    }, 
    chart: { 
     'container': 'chart-1-container', 
     'type': 'LINE', 
     'options': { 
     'width': '40%' 
     } 
    } 
    }); 
    dataChart1.execute(); 

HTML DIV 태그에 생성 :

<div id="chart-1-container" style="width:100%l height:100%;"></div> 

답변

0

이 시도하십시오, 그것은 당신에게 더 나은

을 도울 수 당신이 포함 된 API를 사용하고 있기 때문에 .. 할 것 dataChart1.execute();를 호출 : 0
$(window).resize(function(){ 
    drawChart(); 
}); 
+0

답장을 보내 주셔서 감사합니다. –

+0

더 잘 이해하고 사용하려면이 [https://codepen.io/flopreynat/pen/BfLkA](https://codepen.io/)을 참조하십시오. flopreynat/pen/BfLkA) –

1

바인딩 window Resize 이벤트 리스너 및 jQuery를 사용하여 크기 조정

예에 차트를 다시 그리기 ..

$(window).resize(function(){ 
    redrawMychart() // impement this method which calls draw() method 
}); 

편집 창에서 당신을위한 일은 크기를 조정합니다.

참고 : 창의 크기가 조정될 때마다 다시 그려 지므로 스마트 그리기 옵션을 찾아 여러 번 다시 그리지 않도록하십시오.

+0

응답 해 주셔서 감사합니다. 그러나 차트를 그리지 않으려 고합니다. Google 애널리틱스에서 생성 한 차트로이 메소드를 어떻게 호출해야합니까? –

+0

@ mousa.Alshaikh check edit –

+0

chartname.execute를 함수 windows.resize로 대체 하시겠습니까 ?? 함수 호출 chartname의 본문에서? –