इसे उत्तरदायी बनाओ, यह लिंक एक उदाहरण है। इसे देखें
https://codepen.io/flopreynat/pen/BfLkA
HTML:
<div class="row">
<div class="col-md-12 text-center">
<h1>Make Google charts responsive</h1>
<p>Full blog post details <a href="http://flopreynat.com/blog/make-google-charts-responsive.html">on my blog</a></p>
</div>
<div class="col-md-4 col-md-offset-4">
<hr />
</div>
<div class="clearfix"></div>
<div class="col-md-6">
<div id="chart_div1" class="chart"></div>
</div>
<div class="col-md-6">
<div id="chart_div2" class="chart"></div>
</div>
</div>
सीएसएस:
.chart {
width: 100%;
min-height: 450px;
}
जे एस:
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart1);
function drawChart1() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div1'));
chart.draw(data, options);
}
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart2);
function drawChart2() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2013', 1000, 400],
['2014', 1170, 460],
['2015', 660, 1120],
['2016', 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
vAxis: {minValue: 0}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div2'));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart1();
drawChart2();
});
// अनुस्मारक: आप https://www.google.com/jsapi लगाने की जरूरत है मैं n आपके दस्तावेज़ का प्रमुख या कोडपेन //
पर बाहरी संसाधन के रूप में मैं सीमा को सीमित नहीं करना चाहता, मैं सिर्फ ग्रिड को अधिक घना बनाना चाहता हूं। अभी के लिए मैंने आकार को 150% व्यूपोर्ट चौड़ाई के रूप में सेट करके और सीएसएस में ज़ूम आउट किया है ... – Lemurr
क्या आपके पास कोई कोड है? Google विज़ुअलाइज़ेशन एपीआई में प्रत्येक कार्य करने के कई तरीके हैं, इसलिए यह जानना महत्वपूर्ण है कि आपने पहले ही क्या किया है और हम वहां से शुरू कर सकते हैं। उदाहरण के लिए, आपके एक्स-अक्ष में लेबल भी गिने गए हैं, इसलिए हमें यह जानना होगा कि आपका डेटा स्रोत कैसे बनाया गया था। – zer00ne