1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| // ----Récupération des DATA----
String test = "\" ['07h00', 23],\"";
// ----Mise en forme des graphiques----
String htmlgraph1 = "<html>"
+ " <head>"
+ " <script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>"
+ " <script type=\"text/javascript\">"
+ " google.charts.load('current', {packages:[\"corechart\"]});"
+ " google.charts.setOnLoadCallback(drawChart);"
+ " function drawChart() {"
+ " var data = google.visualization.arrayToDataTable(["
+ " ['Timestamp', 'Température'],"
+ test
// + " ['07h00', 23],"
+ " ['08h00', 24],"
+ " ['09h00', 24],"
+ " ['10h00', 22]"
+ " ]);"
+ " var options = {"
+ " title: 'Température extérieure',"
+ " backgroundColor: 'transparent',"
+ " curveType: 'function',"
+ " };"
+ " var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));"
+ " chart.draw(data, options);"
+ " }"
+ " </script>"
+ " </head>"
+ " <body>"
+ " <div id=\"curve_chart\" style=\"width: 300px; height: 150px;\"></div>"
+ " </body>" + "</html>";
// ----Affichage Graphiques----
WebSettings webSettings = graph1.getSettings();
webSettings.setJavaScriptEnabled(true);
graph1.setBackgroundColor(0);
graph1.requestFocusFromTouch();
graph1.loadDataWithBaseURL( "file:///android_asset/", htmlgraph1, "text/html", "utf-8", null ); |
Partager