Skip to content

includeZero Y axis doenst work #16

@catiamatos1991

Description

@catiamatos1991

I need all my dygraphs start at 0. And for that I tried to add to graph options and nothing happen.. my graphs still show negative values... I tried to add to my directive and doenst work either. What can i do?

Directive:

(function() {
    var app = angular.module('dashboard.view', []);

    app.directive('dygraph', function(){
        return {
            restrict: 'E',
            scope: {
                data    : '=',
                options : '=?'
            },
            template: '<div style="width: 100%"></div>',
            link: function (scope, elem, attrs) {
                var div = elem.children()[0];
                scope.options.width = elem.parent()[0];
                scope.options.axes.y.includeZero = true;
                var graph = new Dygraph(div, scope.data, scope.options);

            }

       };
    });

})();

Graph Options:

var options = {
                        labels: labels,
                        showRangeSelector: true,
                        legend: 'always',
                        ylabel: units,
                        title: graphTitle,
                        includeZero: true,
                        axes: {
                            y: {
                                valueFormatter: function (value, opts, seriesName, dygraph, row, col) {
                                    if (seriesName == "Sysmode") {
                                        return modemSysmode[value];
                                    } else if (seriesName == "Roaming") {
                                        return modemRoaming[value];
                                    } 
                                    return value;
                                },
                                includeZero: true
                            }
                        },
                        underlayCallback: function(canvas, area, g) {

                            for (var i=0; i<highlightArea.length; i++) {
                                var left = g.toDomXCoord(highlightArea[i][0]);
                                var right = g.toDomXCoord(highlightArea[i][1]);

                                canvas.fillStyle = "rgba(217, 101, 87, 0.2)";
                                canvas.fillRect(left, area.y, right - left, area.h);
                            }
                        }
                    }

If I debug my options the value includeZero appears with true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions