Sha256: 83fd1fd1edb35dfef336ce6a56ff557b0ebcb7c3bbe9c059f30e136a0d179620

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

Dasht.chart_init = function(el, options) {
    var chart = $(el).find(".chart");
    var chart_el = chart.get()[0];
    var old_data = 0;


    // Set the value height to be tile height minus title height.
    Dasht.fill_tile($(el).find(".title"), true, false);
    Dasht.fill_tile(chart);

    // Create some empty values.
    var labels = [];
    var data = [];
    for (var i = 0; i < options.periods; i++) {
        labels.push("");
        data.push(0);
    }

    // Create the chart.
    var chart_data = {
        labels: labels,
        datasets: [
            {
                fillColor: "rgba(255,255,255,0.2)",
                strokeColor: "rgba(255,255,255,0.4)",
                data: data
            }
        ]
    };

    var chart_options = {
        showScale: false,
        showTooltips: false,
        pointDot : false
    }

    var ctx = $(".chart").get(0).getContext("2d");
    var chart = new Chart(ctx).Line(chart_data, chart_options);

    // Handle value updates.
    setTimeout(function() {
        Dasht.get_value(options, function(new_data) {
            if (_.isEqual(old_data, new_data)) return;
            // Update chart.
            for (var i = 0; i < options.periods; i++) {
                chart.datasets[0].points[i].value = new_data[i];
            }
            chart.update();

            old_data = new_data;
        });
    }, 1000);
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dasht-0.1.9 assets/plugins/chart.js
dasht-0.1.8 assets/plugins/chart.js
dasht-0.1.7 assets/plugins/chart.js
dasht-0.1.6 assets/plugins/chart.js
dasht-0.1.5 assets/plugins/chart.js
dasht-0.1.4 assets/plugins/chart.js
dasht-0.1.3 assets/plugins/chart.js
dasht-0.1.2 assets/plugins/chart.js
dasht-0.1.1 assets/plugins/chart.js