jQuery BarGauge: Sequential Growth

Sequential growth of the segments one by one in the jqxBarGauge.

A live JavaScript/jQuery example of jqxBarGauge, the jQWidgets BarGauge component, with its complete source code below. It is one of 8 jqxBarGauge demos for jQuery.

jqxBarGauge API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxdraw.js, jqxbargauge.js, jqxcolorpicker.js, jqxradiobutton.js, jqxdropdownbutton.js, jqxscrollview.js, jqxbuttons.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(document).ready(function ()
{
    var arrayOfValues = [0, 0, 0, 0];
    var arrayA = [20, 0, 0, 0];
    var arrayB = [20, 60, 0, 0];
    var arrayC = [20, 60, 80, 0];
    var arrayD = [20, 60, 80, 100];
    var loop = 0;

    $('#barGauge').on('drawEnd', function ()
    {
        switch (loop)
        {
            case 0:
                $('#barGauge').jqxBarGauge('val', arrayA);
                break;
            case 1:
                $('#barGauge').jqxBarGauge('val', arrayB);
                break;
            case 2:
                $('#barGauge').jqxBarGauge('val', arrayC);
                break;
            case 3:
                $('#barGauge').jqxBarGauge('val', arrayD);
                break;
            default:
                console.log('Render time is finished.');
                break;
        }

        loop += 1;
    });

    $('#barGauge').jqxBarGauge({
        width: getWidth('barGauge'),
        height: getHeight('barGauge'),
        values: arrayOfValues,
        animationDuration: 300,
        relativeInnerRadius: 0.2,
        barSpacing: 14,
        startAngle: 180, endAngle: -180,
        colorScheme: 'scheme02',
        labels: { precision: 0, indent: 15, connectorWidth: 1 }
    });
});

body.html

<div id="barGauge"></div>

Learn more

More jQuery BarGauge demos