Skip to content

Commit a30f9b8

Browse files
yaacovjeff-phillips-18
authored andcommitted
Set line chart data instead of updating it
1 parent 69dceb3 commit a30f9b8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
</div>
6363
<div class="col-md-3">
6464
<button ng-click="addDataPoint()">Add Data Point</button>
65+
<button ng-click="resetData()">Reset Data</button>
6566
</div>
6667
</div>
6768
</div>
@@ -100,8 +101,8 @@
100101
$scope.data = {
101102
dataAvailable: true,
102103
xData: dates,
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]
104+
yData0: ['Created', 12, 10, 10, 62, 17, 10, 15, 13, 17, 10, 12, 10, 10, 12, 17, 16, 15, 13, 17, 10],
105+
yData1: ['Deleted', 10, 17, 76, 14, 10, 10, 10, 10, 10, 10, 10, 17, 17, 14, 10, 10, 10, 10, 10, 10]
105106
};
106107
107108
$scope.custShowXAxis = false;
@@ -113,6 +114,14 @@
113114
$scope.data.yData0.push(Math.round(Math.random() * 100));
114115
$scope.data.yData1.push(Math.round(Math.random() * 100));
115116
};
117+
118+
$scope.resetData = function () {
119+
$scope.data = {
120+
xData: dates,
121+
yData0: ['Created', 12, 10, 10, 62],
122+
yData1: ['Deleted', 10, 17, 76, 14]
123+
};
124+
};
116125
});
117126
</file>
118127
</example>
@@ -188,7 +197,7 @@ angular.module('patternfly.charts').component('pfLineChart', {
188197
}
189198

190199
// Convert the given data to C3 chart format
191-
ctrl.config.data = pfUtils.merge(ctrl.config.data, ctrl.getLineData(ctrl.chartData));
200+
ctrl.config.data = ctrl.getLineData(ctrl.chartData);
192201

193202
// Override defaults with callers specifications
194203
ctrl.defaultConfig = pfUtils.merge(ctrl.defaultConfig, ctrl.config);

0 commit comments

Comments
 (0)