This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Google Chart API
#2
You don't need any Lua scripting here, it can be done purely with Custom JavaScript.

Here's a Gauge example:
Code:
$(function(){
  // load chart JS
  $.getScript('https://www.gstatic.com/charts/loader.js', function() {
    google.charts.load('current', {'packages':['gauge']});
    
    google.charts.setOnLoadCallback(function() {
      // create empty element and add it to plan with ID=4
      var el = $('<div></div>').css({
        position: 'absolute',
        width: 200,
        height: 200,
        top: 200,
        left: 200
      }).appendTo('#plan-4');

      // (re)draw gauge on each object update
      grp.listen('32/1/1', function(object) {
        var data = google.visualization.arrayToDataTable([
          ['Label', 'Value'],
          ['Level', object.value]
        ]);

        // gauge options
        var options = {
          width: 200,
          height: 200,
          redFrom: 90,
          yellowFrom: 75,
          yellowTo: 90,
          redTo: 100,
          minorTicks: 5
        };

        var chart = new google.visualization.Gauge(el.get(0));
        chart.draw(data, options);
      });
    });
  });
});
Reply


Messages In This Thread
Google Chart API - by andrepneves@gmail.com - 17.05.2018, 11:47
RE: Google Chart API - by admin - 17.05.2018, 12:28
RE: Google Chart API - by admin - 21.05.2018, 12:29
RE: Google Chart API - by admin - 25.05.2018, 06:39
RE: Google Chart API - by domotiqa - 28.02.2020, 06:54
RE: Google Chart API - by toujour - 31.03.2020, 09:07
RE: Google Chart API - by Daniel - 31.03.2020, 09:35
RE: Google Chart API - by toujour - 31.03.2020, 13:00
RE: Google Chart API - by jose_dli - 22.02.2021, 19:50
RE: Google Chart API - by admin - 23.02.2021, 08:50
RE: Google Chart API - by jose_dli - 23.02.2021, 10:05
RE: Google Chart API - by admin - 23.02.2021, 10:20
RE: Google Chart API - by jose_dli - 23.02.2021, 11:29
RE: Google Chart API - by jose_dli - 24.02.2021, 18:21
RE: Google Chart API - by legolas2069 - 06.03.2023, 08:01
RE: Google Chart API - by admin - 06.03.2023, 12:20

Forum Jump: