Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set line chart data instead of updating it #413

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/charts/line/line-chart.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</div>
<div class="col-md-3">
<button ng-click="addDataPoint()">Add Data Point</button>
<button ng-click="resetData()">Reset Data</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -99,8 +100,8 @@
$scope.data = {
dataAvailable: true,
xData: dates,
yData0: ['Created', 12, 10,10, 62, 17, 10, 15, 13, 17, 10, 12, 10, 10, 12, 17, 16, 15, 13, 17, 10],
yData1: ['Deleted', 10, 17, 76,14, 10, 10, 10, 10, 10, 10, 10, 17, 17, 14, 10, 10, 10, 10, 10, 10]
yData0: ['Created', 12, 10, 10, 62, 17, 10, 15, 13, 17, 10, 12, 10, 10, 12, 17, 16, 15, 13, 17, 10],
yData1: ['Deleted', 10, 17, 76, 14, 10, 10, 10, 10, 10, 10, 10, 17, 17, 14, 10, 10, 10, 10, 10, 10]
};

$scope.custShowXAxis = false;
Expand All @@ -112,6 +113,14 @@
$scope.data.yData0.push(Math.round(Math.random() * 100));
$scope.data.yData1.push(Math.round(Math.random() * 100));
};

$scope.resetData = function () {
$scope.data = {
xData: dates,
yData0: ['Created', 12, 10, 10, 62],
yData1: ['Deleted', 10, 17, 76, 14]
};
};
});
</file>
</example>
Expand Down Expand Up @@ -225,7 +234,7 @@ angular.module('patternfly.charts').directive('pfLineChart', function (pfUtils)
scope.chartConfig.data.type = scope.setAreaChart ? "area" : "line";
});
scope.$watch('chartData', function () {
scope.chartConfig.data = pfUtils.merge(scope.chartConfig.data, scope.getLineData(scope.chartData));
scope.chartConfig.data = scope.getLineData(scope.chartData);
}, true);
}
};
Expand Down