Skip to content

Commit b8691c9

Browse files
committedMay 12, 2015
Revert "Merge pull request chartjs#856 from tannerlinsley/editable-chart-config"
This reverts commit a8063de, reversing changes made to 7f513b8.
1 parent 4e3dd8a commit b8691c9

11 files changed

+24
-222
lines changed
 

‎samples/bar.html

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
<head>
44
<title>Bar Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
76
</head>
87
<body>
98
<div style="width: 50%">
109
<canvas id="canvas" height="450" width="600"></canvas>
1110
</div>
12-
<button id="randomizeData">Randomize Data</button>
11+
1312

1413
<script>
1514
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
16-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
1715

1816
var barChartData = {
1917
labels : ["January","February","March","April","May","June","July"],
@@ -42,16 +40,6 @@
4240
});
4341
}
4442

45-
$('#randomizeData').click(function(){
46-
barChartData.datasets[0].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
47-
barChartData.datasets[0].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
48-
49-
barChartData.datasets[1].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
50-
barChartData.datasets[1].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
51-
52-
window.myBar.update();
53-
});
54-
5543
</script>
5644
</body>
5745
</html>

‎samples/doughnut.html

+5-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<title>Doughnut Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
76
<style>
87
body{
98
padding: 0;
@@ -18,41 +17,37 @@
1817
<div id="canvas-holder">
1918
<canvas id="chart-area" width="500" height="500"/>
2019
</div>
21-
<button id="randomizeData">Randomize Data</button>
2220

2321

2422
<script>
2523

26-
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
27-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
28-
2924
var doughnutData = [
3025
{
31-
value: randomScalingFactor(),
26+
value: 300,
3227
color:"#F7464A",
3328
highlight: "#FF5A5E",
3429
label: "Red"
3530
},
3631
{
37-
value: randomScalingFactor(),
32+
value: 50,
3833
color: "#46BFBD",
3934
highlight: "#5AD3D1",
4035
label: "Green"
4136
},
4237
{
43-
value: randomScalingFactor(),
38+
value: 100,
4439
color: "#FDB45C",
4540
highlight: "#FFC870",
4641
label: "Yellow"
4742
},
4843
{
49-
value: randomScalingFactor(),
44+
value: 40,
5045
color: "#949FB1",
5146
highlight: "#A8B3C5",
5247
label: "Grey"
5348
},
5449
{
55-
value: randomScalingFactor(),
50+
value: 120,
5651
color: "#4D5360",
5752
highlight: "#616774",
5853
label: "Dark Grey"
@@ -65,14 +60,6 @@
6560
window.myDoughnut = new Chart(ctx).Doughnut(doughnutData, {responsive : true});
6661
};
6762

68-
$('#randomizeData').click(function(){
69-
$.each(doughnutData, function(i, piece){
70-
doughnutData[i].value = randomScalingFactor();
71-
doughnutData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
72-
});
73-
window.myDoughnut.update();
74-
});
75-
7663

7764

7865
</script>

‎samples/line.html

-14
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
<head>
44
<title>Line Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
76
</head>
87
<body>
98
<div style="width:30%">
109
<div>
1110
<canvas id="canvas" height="450" width="600"></canvas>
1211
</div>
1312
</div>
14-
<button id="randomizeData">Randomize Data</button>
1513

1614

1715
<script>
1816
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
19-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
20-
2117
var lineChartData = {
2218
labels : ["January","February","March","April","May","June","July"],
2319
datasets : [
@@ -52,16 +48,6 @@
5248
});
5349
}
5450

55-
$('#randomizeData').click(function(){
56-
lineChartData.datasets[0].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)';
57-
lineChartData.datasets[0].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
58-
59-
lineChartData.datasets[1].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)';
60-
lineChartData.datasets[1].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
61-
62-
window.myLine.update();
63-
});
64-
6551

6652
</script>
6753
</body>

‎samples/pie.html

+6-18
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,42 @@
33
<head>
44
<title>Pie Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
76
</head>
87
<body>
98
<div id="canvas-holder">
109
<canvas id="chart-area" width="300" height="300"/>
1110
</div>
12-
<button id="randomizeData">Randomize Data</button>
1311

14-
<script>
1512

16-
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
17-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
13+
<script>
1814

1915
var pieData = [
2016
{
21-
value: randomScalingFactor(),
17+
value: 300,
2218
color:"#F7464A",
2319
highlight: "#FF5A5E",
2420
label: "Red"
2521
},
2622
{
27-
value: randomScalingFactor(),
23+
value: 50,
2824
color: "#46BFBD",
2925
highlight: "#5AD3D1",
3026
label: "Green"
3127
},
3228
{
33-
value: randomScalingFactor(),
29+
value: 100,
3430
color: "#FDB45C",
3531
highlight: "#FFC870",
3632
label: "Yellow"
3733
},
3834
{
39-
value: randomScalingFactor(),
35+
value: 40,
4036
color: "#949FB1",
4137
highlight: "#A8B3C5",
4238
label: "Grey"
4339
},
4440
{
45-
value: randomScalingFactor(),
41+
value: 120,
4642
color: "#4D5360",
4743
highlight: "#616774",
4844
label: "Dark Grey"
@@ -55,14 +51,6 @@
5551
window.myPie = new Chart(ctx).Pie(pieData);
5652
};
5753

58-
$('#randomizeData').click(function(){
59-
$.each(pieData, function(i, piece){
60-
pieData[i].value = randomScalingFactor();
61-
pieData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
62-
});
63-
window.myPie.update();
64-
});
65-
6654

6755

6856
</script>

‎samples/polar-area.html

+5-18
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,42 @@
33
<head>
44
<title>Polar Area Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
76
</head>
87
<body>
98
<div id="canvas-holder" style="width:30%">
109
<canvas id="chart-area" width="300" height="300"/>
1110
</div>
12-
<button id="randomizeData">Randomize Data</button>
1311

1412

1513
<script>
1614

17-
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
18-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
19-
2015
var polarData = [
2116
{
22-
value: randomScalingFactor(),
17+
value: 300,
2318
color:"#F7464A",
2419
highlight: "#FF5A5E",
2520
label: "Red"
2621
},
2722
{
28-
value: randomScalingFactor(),
23+
value: 50,
2924
color: "#46BFBD",
3025
highlight: "#5AD3D1",
3126
label: "Green"
3227
},
3328
{
34-
value: randomScalingFactor(),
29+
value: 100,
3530
color: "#FDB45C",
3631
highlight: "#FFC870",
3732
label: "Yellow"
3833
},
3934
{
40-
value: randomScalingFactor(),
35+
value: 40,
4136
color: "#949FB1",
4237
highlight: "#A8B3C5",
4338
label: "Grey"
4439
},
4540
{
46-
value: randomScalingFactor(),
41+
value: 120,
4742
color: "#4D5360",
4843
highlight: "#616774",
4944
label: "Dark Grey"
@@ -58,14 +53,6 @@
5853
});
5954
};
6055

61-
$('#randomizeData').click(function(){
62-
$.each(polarData, function(i, piece){
63-
polarData[i].value = randomScalingFactor();
64-
polarData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
65-
});
66-
window.myPolarArea.update();
67-
});
68-
6956

7057

7158
</script>

‎samples/radar.html

+7-18
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
<head>
44
<title>Radar Chart</title>
55
<script src="../Chart.js"></script>
6-
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
6+
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
7+
<style>
8+
canvas{
9+
}
10+
</style>
711
</head>
812
<body>
913
<div style="width:30%">
1014
<canvas id="canvas" height="450" width="450"></canvas>
1115
</div>
12-
<button id="randomizeData">Randomize Data</button>
1316

1417

1518
<script>
16-
17-
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
18-
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
19-
2019
var radarChartData = {
2120
labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
2221
datasets: [
@@ -28,7 +27,7 @@
2827
pointStrokeColor: "#fff",
2928
pointHighlightFill: "#fff",
3029
pointHighlightStroke: "rgba(220,220,220,1)",
31-
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
30+
data: [65,59,90,81,56,55,40]
3231
},
3332
{
3433
label: "My Second dataset",
@@ -38,7 +37,7 @@
3837
pointStrokeColor: "#fff",
3938
pointHighlightFill: "#fff",
4039
pointHighlightStroke: "rgba(151,187,205,1)",
41-
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
40+
data: [28,48,40,19,96,27,100]
4241
}
4342
]
4443
};
@@ -49,16 +48,6 @@
4948
});
5049
}
5150

52-
$('#randomizeData').click(function(){
53-
radarChartData.datasets[0].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)';
54-
radarChartData.datasets[0].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
55-
56-
radarChartData.datasets[1].fillColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.3)';
57-
radarChartData.datasets[1].data = [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()];
58-
59-
window.myRadar.update();
60-
});
61-
6251
</script>
6352
</body>
6453
</html>

‎src/Chart.Bar.js

-26
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
defaults : defaultConfig,
4949
initialize: function(data){
5050

51-
// Save data as a source for updating of values & methods
52-
this.data = data;
53-
5451
//Expose options as a scope variable here so we can access it in the ScaleClass
5552
var options = this.options;
5653

@@ -143,29 +140,6 @@
143140
this.render();
144141
},
145142
update : function(){
146-
//Iterate through each of the datasets, and build this into a property of the chart
147-
helpers.each(this.data.datasets,function(dataset,datasetIndex){
148-
149-
helpers.extend(this.datasets[datasetIndex], {
150-
label : dataset.label || null,
151-
fillColor : dataset.fillColor,
152-
strokeColor : dataset.strokeColor,
153-
});
154-
155-
helpers.each(dataset.data,function(dataPoint,index){
156-
helpers.extend(this.datasets[datasetIndex].bars[index], {
157-
value : dataPoint,
158-
label : this.data.labels[index],
159-
datasetLabel: dataset.label,
160-
strokeColor : dataset.strokeColor,
161-
fillColor : dataset.fillColor,
162-
highlightFill : dataset.highlightFill || dataset.fillColor,
163-
highlightStroke : dataset.highlightStroke || dataset.strokeColor
164-
});
165-
},this);
166-
167-
},this);
168-
169143
this.scale.update();
170144
// Reset any highlight colours before updating.
171145
helpers.each(this.activeElements, function(activeElement){

‎src/Chart.Doughnut.js

-22
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
//Config is automatically merged by the core of Chart.js, and is available at this.options
4646
initialize: function(data){
4747

48-
// Save data as a source for updating of values & methods
49-
this.data = data;
50-
5148
//Declare segments as a static property to prevent inheriting across the Chart type prototype
5249
this.segments = [];
5350
this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2;
@@ -127,25 +124,6 @@
127124
},this);
128125
},
129126
update : function(){
130-
131-
// Map new data to data points
132-
if(this.data.length == this.segments.length){
133-
helpers.each(this.data, function(segment, i){
134-
helpers.extend(this.segments[i], {
135-
value : segment.value,
136-
fillColor : segment.color,
137-
highlightColor : segment.highlight || segment.color,
138-
showStroke : this.options.segmentShowStroke,
139-
strokeWidth : this.options.segmentStrokeWidth,
140-
strokeColor : this.options.segmentStrokeColor,
141-
label : segment.label
142-
});
143-
}, this);
144-
} else{
145-
// Data size changed without properly inserting, just redraw the chart
146-
this.initialize(this.data);
147-
}
148-
149127
this.calculateTotal(this.segments);
150128

151129
// Reset any highlight colours before updating.

‎src/Chart.Line.js

-28
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
name: "Line",
6363
defaults : defaultConfig,
6464
initialize: function(data){
65-
// Save data as a source for updating of values & methods
66-
this.data = data;
67-
6865
//Declare the extension of the default point, to cater for the options passed in to the constructor
6966
this.PointClass = Chart.Point.extend({
7067
offsetGridLines : this.options.offsetGridLines,
@@ -140,31 +137,6 @@
140137
this.render();
141138
},
142139
update : function(){
143-
//Iterate through each of the datasets, and build this into a property of the chart
144-
helpers.each(this.data.datasets,function(dataset,datasetIndex){
145-
146-
helpers.extend(this.datasets[datasetIndex], {
147-
label : dataset.label || null,
148-
fillColor : dataset.fillColor,
149-
strokeColor : dataset.strokeColor,
150-
pointColor : dataset.pointColor,
151-
pointStrokeColor : dataset.pointStrokeColor,
152-
});
153-
154-
helpers.each(dataset.data,function(dataPoint,index){
155-
helpers.extend(this.datasets[datasetIndex].points[index], {
156-
value : dataPoint,
157-
label : this.data.labels[index],
158-
datasetLabel: dataset.label,
159-
strokeColor : dataset.pointStrokeColor,
160-
fillColor : dataset.pointColor,
161-
highlightFill : dataset.pointHighlightFill || dataset.pointColor,
162-
highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor
163-
});
164-
},this);
165-
166-
},this);
167-
168140
this.scale.update();
169141
// Reset any highlight colours before updating.
170142
helpers.each(this.activeElements, function(activeElement){

‎src/Chart.PolarArea.js

-19
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
//Initialize is fired when the chart is initialized - Data is passed in as a parameter
6060
//Config is automatically merged by the core of Chart.js, and is available at this.options
6161
initialize: function(data){
62-
// Save data as a source for updating of values & methods
63-
this.data = data;
64-
6562
this.segments = [];
6663
//Declare segment class as a chart instance specific class, so it can share props for this instance
6764
this.SegmentArc = Chart.Arc.extend({
@@ -193,22 +190,6 @@
193190

194191
},
195192
update : function(){
196-
197-
// Map new data to data points
198-
if(this.data.length == this.segments.length){
199-
helpers.each(this.data, function(segment, i){
200-
helpers.extend(this.segments[i], {
201-
fillColor: segment.color,
202-
highlightColor: segment.highlight || segment.color,
203-
label: segment.label,
204-
value: segment.value,
205-
});
206-
},this);
207-
} else{
208-
// Data size changed without properly inserting, just redraw the chart
209-
this.initialize(this.data);
210-
}
211-
212193
this.calculateTotal(this.segments);
213194

214195
helpers.each(this.segments,function(segment){

‎src/Chart.Radar.js

-28
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
},
6868

6969
initialize: function(data){
70-
// Save data as a source for updating of values & methods
71-
this.data = data;
72-
7370
this.PointClass = Chart.Point.extend({
7471
strokeWidth : this.options.pointDotStrokeWidth,
7572
radius : this.options.pointDotRadius,
@@ -272,31 +269,6 @@
272269
this.update();
273270
},
274271
update : function(){
275-
//Iterate through each of the datasets, and build this into a property of the chart
276-
helpers.each(this.data.datasets,function(dataset,datasetIndex){
277-
278-
helpers.extend(this.datasets[datasetIndex], {
279-
label : dataset.label || null,
280-
fillColor : dataset.fillColor,
281-
strokeColor : dataset.strokeColor,
282-
pointColor : dataset.pointColor,
283-
pointStrokeColor : dataset.pointStrokeColor,
284-
});
285-
286-
helpers.each(dataset.data,function(dataPoint,index){
287-
helpers.extend(this.datasets[datasetIndex].points[index], {
288-
value : dataPoint,
289-
label : this.data.labels[index],
290-
datasetLabel: dataset.label,
291-
strokeColor : dataset.pointStrokeColor,
292-
fillColor : dataset.pointColor,
293-
highlightFill : dataset.pointHighlightFill || dataset.pointColor,
294-
highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor
295-
});
296-
},this);
297-
298-
},this);
299-
300272
this.eachPoints(function(point){
301273
point.save();
302274
});

0 commit comments

Comments
 (0)
Please sign in to comment.