Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]System głosowania (sonda) w kształcie okręgu
Forum PHP.pl > Forum > Przedszkole
mefistofeles
Poszukuje sondy, która oddane głosy reprezentuje na wykresie kołowym (jak w office).
Miał ktoś może styczność z czymś takim ?
darko
Osobiście nie korzystałem, ale wiem o istnieniu Google Chart
mefistofeles
Ciekawe narzędzie, ale coś jest z nim nie tak.

Jeśłi odpalimy sobie taki np kod:


  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type"
  5. content="text/html; charset=iso-8859-2"/>
  6. Google Visualization API Sample
  7. </title>
  8. <script type="text/javascript"
  9. src="http://www.google.com/jsapi">
  10. </script>
  11. <script type="text/javascript">
  12. google.load('visualization', '1',
  13. {packages: ['piechart']});
  14. </script>
  15. <script type="text/javascript">
  16. function drawVisualization() {
  17. // Create and populate the data table.
  18. var data = new google.visualization.DataTable();
  19. data.addColumn('string', 'Month');
  20. data.addColumn('number', 'Sales');
  21. data.addRows([
  22.  
  23.  
  24.  
  25. ['January',{v:20, f:'$20M'}],
  26. ['February',{v:31, f:'$31M'}],
  27. ['March',{v:61, f:'$61M'}],
  28. ['April',{v:26, f:'$26M'}],
  29. ['January',{v:20, f:'$20M'}],
  30. ['February',{v:31, f:'$31M'}],
  31. ['March',{v:61, f:'$61M'}],
  32. ['April',{v:26, f:'$26M'}]
  33.  
  34.  
  35.  
  36.  
  37. ]);
  38.  
  39. // Create and draw the visualization.
  40. new google.visualization.PieChart(
  41. document.getElementById('visualization')).
  42. draw(data, {is3D:true});
  43. }
  44. google.setOnLoadCallback(drawVisualization);
  45. </script>
  46. </head>
  47. <body style="font-family: Arial;border: 0 none;font-size:20px;">
  48. <div id="visualization"
  49. style="width: 300px; height: 300px;">
  50. </div>
  51. </body>
  52. </html>



Wszystko gra, ale jak zmienimy wartość January na coś innego np tak:

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type"
  5. content="text/html; charset=iso-8859-2"/>
  6. Google Visualization API Sample
  7. </title>
  8. <script type="text/javascript"
  9. src="http://www.google.com/jsapi">
  10. </script>
  11. <script type="text/javascript">
  12. google.load('visualization', '1',
  13. {packages: ['piechart']});
  14. </script>
  15. <script type="text/javascript">
  16. function drawVisualization() {
  17. // Create and populate the data table.
  18. var data = new google.visualization.DataTable();
  19. data.addColumn('string', 'Month');
  20. data.addColumn('number', 'Sales');
  21. data.addRows([
  22.  
  23.  
  24.  
  25. ['Wojciech Bek',{v:20, f:'$20M'}],
  26. ['February',{v:31, f:'$31M'}],
  27. ['March',{v:61, f:'$61M'}],
  28. ['April',{v:26, f:'$26M'}],
  29. ['January',{v:20, f:'$20M'}],
  30. ['February',{v:31, f:'$31M'}],
  31. ['March',{v:61, f:'$61M'}],
  32. ['April',{v:26, f:'$26M'}]
  33.  
  34.  
  35.  
  36.  
  37. ]);
  38.  
  39. // Create and draw the visualization.
  40. new google.visualization.PieChart(
  41. document.getElementById('visualization')).
  42. draw(data, {is3D:true});
  43. }
  44. google.setOnLoadCallback(drawVisualization);
  45. </script>
  46. </head>
  47. <body style="font-family: Arial;border: 0 none;font-size:20px;">
  48. <div id="visualization"
  49. style="width: 300px; height: 300px;">
  50. </div>
  51. </body>
  52. </html>



To kod wariuje i czcionka z 11px spada do 5px i nic z tym nie idzie zrobić chyba, żeby się bawić w buforowanie kodu wynikowego i podmienianie
stringów ale to dziwne obejście by było.

Ktoś wie dlaczego tak się dzieje, lub jak ustawić na sztywno wielkość czcionki bo w stylach się nie da ?
mortus
Wielkość czcionki można ustawić tutaj:
Kod
// Create and draw the visualization.
new google.visualization.PieChart(
    document.getElementById('visualization')).
        draw(data, {is3D: true, legendFontSize: '11px'});
Podobnie jak kilka innych parametrów. Przy czym jeżeli masz długie nazwy serii danych to powinieneś zmienić szerokość wykresu (width w div-ie visualization) na większą, albo umieścić legendę np. pod wykresem (poszukaj parametru pod linkiem, który Ci podałem).
mefistofeles
Super!
Wielkie dzięki za pomoc smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.