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.

chartist to display nice pie...
#13
1. Copy all code from this file: https://dl.openrb.com/misc/chartist.js and paste at the top of the Custom JavaScript code
2. Download source from here: https://github.com/gionkunz/chartist-js/...ag/v0.11.4 and copy/paste code from dist/chartist.min.css into Custom CSS.
3. Add to Custom JavaScript, and modify as needed:
Code:
$(function() {
  var chart;

  grp.listen('0/0/1', function(obj, type) {
    var planid = 1;
    var groups = [ '32/0/8', '32/0/9', '32/0/10' ];
  
    var labels = [];
    var series = [];
  
    for (var group of groups) {
      var obj = grp.find(group);
      console.log(group, obj);
      labels.push(obj.name);
      series.push(obj.value);
    }
  
    var data = {
      labels: labels,
      series: series
    };

    var options = {
      width: '300px',
      height: '300px',
      donut: true,
      donutWidth: 50,
      donutSolid: true,
      startAngle: 270,
      showLabel: true
    };

    if (chart) {
      chart.update(data);
    }
    else {
      var el = $('<div class="chart"></div>').css({
        position: 'absolute',
        top: '400px',
        left: '200px'
      }).appendTo('#plan-' + planid);

      chart = new Chartist.Pie('.chart', data, options);
    }
  }, true);
});

0/0/1 is the address that triggers chart re-draw. planid (1) is the ID of the plan where the chart will be placed. 32/0/8..32/0/10 are the group addresses that will be visible on the chart. 300px is the chart size, 400px/200px is the position on the plan from the top left corner.
Note that this won't work in the editor, only in the view mode.
Reply


Messages In This Thread
chartist to display nice pie... - by domotiqa - 05.01.2022, 08:56
RE: chartist to display nice pie... - by jmir - 14.02.2022, 11:32
RE: chartist to display nice pie... - by jmir - 14.02.2022, 13:34
RE: chartist to display nice pie... - by jmir - 15.02.2022, 11:15
RE: chartist to display nice pie... - by Acla - 12.06.2023, 05:05
RE: chartist to display nice pie... - by JRP - 08.09.2022, 16:18
RE: chartist to display nice pie... - by admin - 12.06.2023, 12:22
RE: chartist to display nice pie... - by Acla - 12.06.2023, 15:44
RE: chartist to display nice pie... - by jmir - 25.03.2024, 14:49

Forum Jump: