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

Controller Driven Charts #1219

Merged
merged 36 commits into from
Jun 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
89574b6
Prototype controller + some of line chart converted
etimberg Jun 14, 2015
9751e8f
Created a generic base class to be used by rectangular charts. Modifi…
etimberg Jun 14, 2015
68ae022
Fix the broken scatter chart. Introduced the concept of a canvas cont…
etimberg Jun 14, 2015
886c996
Drop the base class in favour of an expanded canvas controller. Renam…
etimberg Jun 14, 2015
0fa2ac4
Bar chart now uses the rectangular canvas & element controllers.
etimberg Jun 14, 2015
81c66c8
Fix duplicate property
etimberg Jun 14, 2015
3f9afb1
More core file separation, and no duplicate copyrights
tannerlinsley Jun 15, 2015
4047440
Git thinks the core file is new now haha
tannerlinsley Jun 15, 2015
d73dae0
No hardcoded chart type methods
tannerlinsley Jun 15, 2015
d811812
Little tweaks
tannerlinsley Jun 15, 2015
43f2c01
Charts become config blocks (themes, if you will :)
tannerlinsley Jun 15, 2015
aaa2484
Controller function organization
tannerlinsley Jun 15, 2015
b0ece8b
New controllers, bar drawing (with errors)
tannerlinsley Jun 15, 2015
257bdb2
Hybrid Line and Bar chart - Line Now drawing
tannerlinsley Jun 15, 2015
051ef81
Merge pull request #1 from etimberg/feature/controllers-tanner
etimberg Jun 15, 2015
872c9d5
Hover macros, type defaults, and cleanup
tannerlinsley Jun 15, 2015
9f92379
Line now draws
tannerlinsley Jun 15, 2015
8e3d3c2
Fix animations
etimberg Jun 15, 2015
b21061c
Remove hover styles
etimberg Jun 15, 2015
d3538a1
use inLabelRange when tooltips are in label mode
etimberg Jun 15, 2015
22c40fe
Fix 2 bar samples
etimberg Jun 15, 2015
fa1b0db
Apply correct hover styles
etimberg Jun 15, 2015
74f161b
Core improvements, arc & doughnut partially working
tannerlinsley Jun 16, 2015
36de623
Merge remote-tracking branch 'origin/feature/controllers' into featur…
tannerlinsley Jun 16, 2015
2aa4896
Doughnut/Pie accurate radii
tannerlinsley Jun 16, 2015
76e060c
Better getElementAtEvent function
tannerlinsley Jun 16, 2015
8b3424b
Responsive used proper "each" from helpers
tannerlinsley Jun 16, 2015
5759f41
Pie used new doughnut controller
tannerlinsley Jun 16, 2015
ef1acfa
Build single scales in core
tannerlinsley Jun 16, 2015
4c749e7
Single scale again.
tannerlinsley Jun 16, 2015
42648d0
Build radial scale details inside itself
tannerlinsley Jun 16, 2015
2d5eb6d
Radar chart and radialLinear scale
tannerlinsley Jun 16, 2015
9023057
Old doughnuts are no good.
tannerlinsley Jun 16, 2015
c0ccae1
No logging
tannerlinsley Jun 16, 2015
1f302f0
Fixed polar-area sample
tannerlinsley Jun 16, 2015
db98180
Polar Area Draws, but has scale resizing issues
tannerlinsley Jun 16, 2015
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
11,700 changes: 5,391 additions & 6,309 deletions Chart.js

Large diffs are not rendered by default.

38 changes: 5 additions & 33 deletions Chart.min.js

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ var gulp = require('gulp'),

var srcDir = './src/';
/*
* Usage : gulp build --types=Bar,Line,Doughnut
* Output: - A built Chart.js file with Core and types Bar, Line and Doughnut concatenated together
* - A minified version of this code, in Chart.min.js
* Usage : gulp build --types=Bar,Line,Doughnut
* Output: - A built Chart.js file with Core and types Bar, Line and Doughnut concatenated together
* - A minified version of this code, in Chart.min.js
*/

gulp.task('build', function() {

var srcFiles = [
'./src/core/core.js',
'./src/core/core.helpers.js',
'./src/core/core.chart.js',
'./src/core/core.element.js',
'./src/core/**',
'./src/controllers/**',
'./src/scales/**',
'./src/elements/**',
'./src/charts/**',
'./src/**',
'./src/charts/chart.bar.js',
'./node_modules/color/dist/color.min.js'
],
isCustom = !!(util.env.types),
Expand All @@ -48,9 +51,9 @@ gulp.task('build', function() {
});

/*
* Usage : gulp bump
* Prompts: Version increment to bump
* Output: - New version number written into package.json & bower.json
* Usage : gulp bump
* Prompts: Version increment to bump
* Output: - New version number written into package.json & bower.json
*/

gulp.task('bump', function(complete) {
Expand Down
3 changes: 2 additions & 1 deletion samples/bar-multi-axis.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar({
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
responsive: true,
Expand Down
3 changes: 2 additions & 1 deletion samples/bar-stacked.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar({
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
responsive: true,
Expand Down
3 changes: 2 additions & 1 deletion samples/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar({
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
responsive: true,
Expand Down
63 changes: 63 additions & 0 deletions samples/combo-bar-line.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!doctype html>
<html>

<head>
<title>Bar Chart</title>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../Chart.js"></script>
</head>

<body>
<div style="width: 50%">
<canvas id="canvas" height="450" width="600"></canvas>
</div>
<button id="randomizeData">Randomize Data</button>
<script>
var randomScalingFactor = function() {
return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100);
};
var randomColorFactor = function() {
return Math.round(Math.random() * 255);
};

var barChartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
type: 'line',
label: 'Dataset 1',
backgroundColor: "rgba(220,220,220,0.5)",
data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
}, {
label: 'Dataset 2',
backgroundColor: "rgba(151,187,205,0.5)",
data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
}, {
label: 'Dataset 3',
backgroundColor: "rgba(151,187,205,0.5)",
data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
}]

};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
responsive: true,
}
});
};

$('#randomizeData').click(function() {
$.each(barChartData.datasets, function(i, dataset) {
dataset.backgroundColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
dataset.data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()];

});
window.myBar.update();
});
</script>
</body>

</html>
4 changes: 3 additions & 1 deletion samples/doughnut.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
};

var config = {
type: 'doughnut',
data: {
datasets: [{
data: [
Expand Down Expand Up @@ -93,7 +94,8 @@

window.onload = function() {
var ctx = document.getElementById("chart-area").getContext("2d");
window.myDoughnut = new Chart(ctx).Doughnut(config);
window.myDoughnut = new Chart(ctx, config);
console.log(window.myDoughnut);
};

$('#randomizeData').click(function() {
Expand Down
3 changes: 2 additions & 1 deletion samples/line.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
};

var config = {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
Expand Down Expand Up @@ -64,7 +65,7 @@

window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(config);
window.myLine = new Chart(ctx, config);
};

$('#randomizeData').click(function() {
Expand Down
3 changes: 2 additions & 1 deletion samples/pie.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
};

var config = {
type: 'pie',
data: {
datasets: [{
data: [
Expand Down Expand Up @@ -83,7 +84,7 @@

window.onload = function() {
var ctx = document.getElementById("chart-area").getContext("2d");
window.myPie = new Chart(ctx).Pie(config);
window.myPie = new Chart(ctx, config);
};

$('#randomizeData').click(function() {
Expand Down
19 changes: 10 additions & 9 deletions samples/polar-area.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
};

var config = {
type: 'polarArea',
data: {
datasets: [{
data: [
Expand All @@ -37,23 +38,23 @@
"#949FB1",
"#4D5360",
],
labels: [
"Red",
"Green",
"Yellow",
"Grey",
"Dark Grey"
]
}],
labels: [
"Red",
"Green",
"Yellow",
"Grey",
"Dark Grey"
]
},
options: {
responsive: true
}
};

window.onload = function() {
var ctx = document.getElementById("chart-area").getContext("2d");
window.myPolarArea = new Chart(ctx).PolarArea(config);
var ctx = document.getElementById("chart-area");
window.myPolarArea = new Chart(ctx, config);
};

$('#randomizeData').click(function() {
Expand Down
6 changes: 2 additions & 4 deletions samples/radar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
};

var config = {
type: 'radar',
data: {
labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
datasets: [{
Expand All @@ -36,14 +37,11 @@
pointHighlightStroke: "rgba(151,187,205,1)",
data: [null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
}]
},
options: {
responsive: true
}
};

window.onload = function() {
window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(config);
window.myRadar = new Chart(document.getElementById("canvas"), config);
};

$('#randomizeData').click(function() {
Expand Down
Loading