،ﻩﺪﯿﭽﯿﭘ ﯽﺒﺗﺍﺮﻣ ﻪﻠﺴﻠﺳ ﯽﺘﺧﺭﺩ ﯼﺎﻫ ﻪﺸﻘﻧ ﺎﺗ ﻩﺩﺎﺳ ﯽﻄﺧ ﯼﺎﻫﺭﺍﺩﻮﻤﻧ ﺯﺍ
ﯽﮔﺪﻨﮐﺍﺮﭘ ﺭﺍﺩﻮﻤﻧ
ﯽﻄﺧ ﺭﺍﺩﻮﻤﻧ
ﯽﻧﻮﺘﺳ/ﯼﺍ ﻪﻠﯿﻣ ﺭﺍﺩﻮﻤﻧ
ﯽﺘﺣﺎﺴﻣ ﺭﺍﺩﻮﻤﻧ
ﯼﺍ ﻩﺮﯾﺍﺩ ﺭﺍﺩﻮﻤﻧ
ﺕﺎﻧﻭﺩ ﺭﺍﺩﻮﻤﻧ
ﯽﻧﺎﻣﺯﺎﺳ ﺕﺭﺎﭼ
ﯽﯾﺎﯿﻓﺍﺮﻐﺟ ﺭﺍﺩﻮﻤﻧ/ﻪﺸﻘﻧ
1. ﺮﺼﻨﻋ ﮏﯾ <div> (ﻪﺑﺮﺼﺤﻨﻣ ﻪﺳﺎﻨﺷ ﮏﯾ ﺎﺑﺩﺮﻓ) ﺭﺩ HTML ﯽﻣ ﻪﮐ ﯽﯾﺎﺟﺪﯿﻨﮐ ﻪﻓﺎ
<div id="myChart" style="max-width:700px; height:400px"></div>
2. ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺎﻫﺭﺍﺩﻮﻤﻧ ﺭﺍﺬﮔﺭﺎﺑ ﻪﺑ ﯼﺪﻧﻮﯿﭘ:
<script src="https://www.gstatic.com/charts/loader.js"></script>
3. Graph API ﯼﺮﯿﮔﺭﺎﺑ ﻡﺎﮕﻨﻫ ﺭﺩ ﺎﺗ ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺍﺭ ﯽﻌﺑﺎﺗ ﻭ ﺪﯿﻨﮐ ﯼﺮﯿﮔﺭﺎﺑ ﺍﺭ API ﺩﻮ
<script>
google.charts.load('current',{packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
// Your Function
function drawChart() {
...
}
</script>
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Contry', 'Mhl'],
['Italy', 55],
['France', 49],
['Spain', 44],
['USA', 24],
['Argentina', 15]
]);
// Set Options
const options = {
title: 'World Wide Wine Production'
};
// Draw
const chart = new google.visualization.BarChart(document.getElementById('myChart'));
chart.draw(data, options);
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<body>
<div id="myChart" style="width:100%; max-width:600px; height:500px;"></div>
<script>
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Contry', 'Mhl'],
['Italy',55],
['France',49],
['Spain',44],
['USA',24],
['Argentina',15]
]);
// Set Options
const options = {
title:'World Wide Wine Production'
};
// Draw
const chart = new google.visualization.BarChart(document.getElementById('myChart'));
chart.draw(data, options);
}
</script>
</body>
</html>
:ﻦﯾﺰﮕﯾﺎﺟ ﺖﺳﺍ ﯽﻓﺎﮐ ،ﯼﺎﭘ ﺭﺍﺩﻮﻤﻧ ﻪﺑ ﺭﺍﻮﻧ ﺭﺍﺩﻮﻤﻧ ﻞﯾﺪﺒﺗ ﯼﺍﺮﺑ
const chart = new google.visualization.PieChart(document.getElementById('myChart'));
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<body>
<div
id="myChart" style="width:100%; max-width:600px; height:500px;">
</div>
<script>
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Contry', 'Mhl'],
['Italy',54.8],
['France',48.6],
['Spain',44.4],
['USA',23.9],
['Argentina',14.5]
]);
// Set Options
const options = {
title:'World Wide Wine Production'
};
// Draw
const chart = new google.visualization.PieChart(document.getElementById('myChart'));
chart.draw(data, options);
}
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺎﻫ ﻪﻨﯾﺰﮔ ﻪﺑ ﺍﺭ is3D: true ﺖﺳﺍ ﯽﻓﺎﮐ ،ﯼﺪﻌﺑ ﻪﺳ ﺕﺭﻮﺻ ﻪﺑ Pie ﺶﯾﺎﻤﻧ ﯼﺍﺮﺑ
const options = {
title: 'World Wide Wine Production',
is3D: true
};
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<body>
<div
id="myChart" style="width:100%; max-width:600px; height:500px;">
</div>
<script>
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Contry', 'Mhl'],
['Italy',54.8],
['France',48.6],
['Spain',44.4],
['USA',23.9],
['Argentina',14.5]
]);
// Set Options
const options = {
title:'World Wide Wine Production',
is3D:true
};
// Draw
const chart = new google.visualization.PieChart(document.getElementById('myChart'));
chart.draw(data, options);
}
</script>
</body>
</html>
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Price', 'Size'],
[50,7],[60,8],[70,8],[80,9],[90,9],[100,9],
[110,10],[120,11],[130,14],[140,14],[150,15]
]);
// Set Options
const options = {
title: 'House Prices vs Size',
hAxis: {title: 'Square Meters'},
vAxis: {title: 'Price in Millions'},
legend: 'none'
};
// Draw Chart
const chart = new google.visualization.LineChart(document.getElementById('myChart'));
chart.draw(data, options);
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<body>
<div id="myChart" style="width:100%; max-width:600px; height:500px;"></div>
<script>
google.charts.load('current',{packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Price', 'Size'],
[50,7],[60,8],[70,8],[80,9],[90,9],
[100,9],[110,10],[120,11],
[130,14],[140,14],[150,15]
]);
// Set Options
const options = {
title: 'House Prices vs. Size',
hAxis: {title: 'Square Meters'},
vAxis: {title: 'Price in Millions'},
legend: 'none'
};
// Draw
const chart = new google.visualization.LineChart(document.getElementById('myChart'));
chart.draw(data, options);
}
</script>
</body>
</html>
:ﺪﯿﻫﺩ ﺮﯿﯿﻐﺗ ScatterChart ﻪﺑ ﺍﺭ google.visualization ،ﻩﺩﺍﺩ ﻥﺎﻤﻫ ﺭﺍﺩﻮﻤﻧ ﯽﮔﺪﻨﮐﺍﺮﭘ
const chart = new google.visualization.ScatterChart(document.getElementById('myChart'));
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<body>
<div id="myChart" style="width:100%; max-width:600px; height:500px;"></div>
<script>
google.charts.load('current',{packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Set Data
const data = google.visualization.arrayToDataTable([
['Price', 'Size'],
[50,7],[60,8],[70,8],[80,9],[90,9],
[100,9],[110,10],[120,11],
[130,14],[140,14],[150,15]
]);
// Set Options
const options = {
title: 'House Prices vs. Size',
hAxis: {title: 'Square Meters'},
vAxis: {title: 'Price in Millions'},
legend: 'none'
};
// Draw
const chart = new google.visualization.ScatterChart(document.getElementById('myChart'));
chart.draw(data, options);
}
</script>
</body>
</html>