Skip to content

Commit 30aecad

Browse files
committed
Set line chart data instead of updating it
1 parent 976cc00 commit 30aecad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/charts/line/line-chart.directive.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
</div>
6262
<div class="col-md-3">
6363
<button ng-click="addDataPoint()">Add Data Point</button>
64+
<button ng-click="resetData()">Reset Data</button>
6465
</div>
6566
</div>
6667
</div>
@@ -99,8 +100,8 @@
99100
$scope.data = {
100101
dataAvailable: true,
101102
xData: dates,
102-
yData0: ['Created', 12, 10,10, 62, 17, 10, 15, 13, 17, 10, 12, 10, 10, 12, 17, 16, 15, 13, 17, 10],
103-
yData1: ['Deleted', 10, 17, 76,14, 10, 10, 10, 10, 10, 10, 10, 17, 17, 14, 10, 10, 10, 10, 10, 10]
103+
yData0: ['Created', 12, 10, 10, 62, 17, 10, 15, 13, 17, 10, 12, 10, 10, 12, 17, 16, 15, 13, 17, 10],
104+
yData1: ['Deleted', 10, 17, 76, 14, 10, 10, 10, 10, 10, 10, 10, 17, 17, 14, 10, 10, 10, 10, 10, 10]
104105
};
105106
106107
$scope.custShowXAxis = false;
@@ -112,6 +113,14 @@
112113
$scope.data.yData0.push(Math.round(Math.random() * 100));
113114
$scope.data.yData1.push(Math.round(Math.random() * 100));
114115
};
116+
117+
$scope.resetData = function () {
118+
$scope.data = {
119+
xData: dates,
120+
yData0: ['Created', 12, 10, 10, 62],
121+
yData1: ['Deleted', 10, 17, 76, 14]
122+
};
123+
};
115124
});
116125
</file>
117126
</example>
@@ -225,7 +234,7 @@ angular.module('patternfly.charts').directive('pfLineChart', function (pfUtils)
225234
scope.chartConfig.data.type = scope.setAreaChart ? "area" : "line";
226235
});
227236
scope.$watch('chartData', function () {
228-
scope.chartConfig.data = pfUtils.merge(scope.chartConfig.data, scope.getLineData(scope.chartData));
237+
scope.chartConfig.data = scope.getLineData(scope.chartData);
229238
}, true);
230239
}
231240
};

0 commit comments

Comments
 (0)