Line-Charts einfach gemacht ...
... C:\temp\GoogleCharts
Beispiel für eine Wahlumfrage:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// var color = ['lime','cyan','magenta','yellow'];
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'CDU/CSU', 'SPD', 'GRÜNE', 'FDP', 'LINKE', 'AfD', 'Sonstige'],
['24.11.22', 29.5, 20.0, 20.0 , 7.0 , 4.0 , 14.0, 5.5 ],
['21.12.22', 30.0, 22.0, 18.0 , 7.5 , 4.5 , 12.0, 6.0 ],
['26.01.23', 31.0, 21.0, 17.0 , 6.0 , 4.5 , 14.0, 6.5 ],
['15.02.23', 30.0, 22.5, 16.0 , 7.5 , 4.0 , 14.0, 6.0 ],
['24.11.22', 29.5, 20.0, 20.0 , 7.0 , 4.0 , 14.0, 5.5 ],
['21.12.22', 30.0, 22.0, 18.0 , 7.5 , 4.5 , 12.0, 6.0 ],
['26.01.23', 31.0, 21.0, 17.0 , 6.0 , 4.5 , 14.0, 6.5 ],
['15.02.23', 30.0, 22.5, 16.0 , 7.5 , 4.0 , 14.0, 6.0 ],
['24.11.22', 29.5, 20.0, 20.0 , 7.0 , 4.0 , 14.0, 5.5 ],
['21.12.22', 30.0, 22.0, 18.0 , 7.5 , 4.5 , 12.0, 6.0 ],
['26.01.23', 31.0, 21.0, 17.0 , 6.0 , 4.5 , 14.0, 6.5 ],
['15.02.23', 30.0, 22.5, 16.0 , 7.5 , 4.0 , 14.0, 6.0 ],
['24.11.22', 29.5, 20.0, 20.0 , 7.0 , 4.0 , 14.0, 5.5 ],
['21.12.22', 30.0, 22.0, 18.0 , 7.5 , 4.5 , 12.0, 6.0 ],
['26.01.23', 31.0, 21.0, 17.0 , 6.0 , 4.5 , 14.0, 6.5 ],
['15.02.23', 30.0, 22.5, 16.0 , 7.5 , 4.0 , 14.0, 6.0 ],
]);
var options = {
title: 'Allensbach Wahlumfragen',
curveType: 'function',
// legend: { position: 'bottom' }
legend: { position: 'right' },
series: {
0: { color: '#43459d' }, // dark blue
1: { color: '#e2431e' }, // red
2: { color: '#6f9654' }, // green
3: { color: '#f1ca3a' }, // yellow
4: { color: '#e7711b' }, // orange
5: { color: '#1c91c0' }, // blue
6: { color: '#DCDCDC' }, // gray
}
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 1500px; height: 800px"></div>
</body>
</html>
Offene Fragen
- Wie kann man die Farben pro Partei definieren, damit die nicht "zufällig" erscheinen?
- Wie kann man auch "viele Datümer" nebeneinander gut darstellen?
- Kann man dann noch "nach links" oder "nach rechts" scrollen?
xxxx






0 Kommentare:
Kommentar veröffentlichen