Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes #11, adds History.md for publishing release notes
  • Loading branch information
Alex Young committed Dec 3, 2011
1 parent 793f9eb commit c4586d0
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 37 deletions.
52 changes: 52 additions & 0 deletions History.md
@@ -0,0 +1,52 @@
0.3.7 / 2011-11-28
==================

* If `labels` is manually supplied, the number of items will be used to determine the horizontal grid positions

0.3.6 / 2011-11-28
==================

* Added grouped bar graphs, for documentation see [Grouped Bar Graphs](http://alexyoung.github.com/ico/)
* Updated documentation to include details on each graph's options

0.3.5 / 2011-11-26
==================

* Added `max_bar_width` option for controlling the maximum width a bar can be
* Added `bar_padding` for controlling the padding between bars
* Added `bar_width` for forcing a given bar width

These options also apply to horizontal bar graphs.

0.3.4.1 / 2011-11-08
====================

* Added `bar_labels` option that displays values above the standard bar graphs

0.3.3 / 2011-09-30
==================

* Added `label_step` and `label_count` options so numerical labels can be controlled

0.3.2 / 2011-08-30
==================

* No longer extending native prototypes

0.3.1 / 2011-08-24
==================

* Bug fix for LineGraph, migrated tests to QUnit, moved Jakefile.js to Makefile

0.3.0 / 2011-03-09
==================

* Passing default JSHint, and a minified version is now available
* Added documentation and published it to [alexyoung.github.com/ico/](http://alexyoung.github.com/ico/)
* Split project into separate files, added build script, fixes for `HorizontalBarGraph`

0.2.2 / 2011-03-01
==================

* `Ico.SparkLine` will now work correctly, particularly in IE6

14 changes: 0 additions & 14 deletions README.textile
Expand Up @@ -11,20 +11,6 @@ h3. Support

Donations to support future development are welcome and appreciated: "Donate":https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=support%40helicoid%2enet&lc=GB&item_name=Helicoid%20Limited&no_note=0&cn=Add%20special%20instructions%20to%20the%20seller&no_shipping=2&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted

h3. News

* [2011-11-28] 0.3.6: Added grouped bar graphs, for documentation see "Grouped Bar Graphs":http://alexyoung.github.com/ico/
* [2011-11-26] Updated documentation to include details on each graph's options
* [2011-11-26] 0.3.5: Added <code>max_bar_width</code> option for controlling the maximum width a bar can be, <code>bar_padding</code> for controlling the padding between bars, and <code>bar_width</code> for forcing a given bar width. These options also apply to horizontal bar graphs
* [2011-11-08] 0.3.4.1: Added <code>bar_labels</code> option that displays values above the standard bar graphs
* [2011-09-30] 0.3.3: Added <code>label_step</code> and <code>label_count</code> options so numerical labels can be controlled
* [2011-08-30] 0.3.2: No longer extending native prototypes
* [2011-08-24] 0.3.1: Bug fix for LineGraph, migrated tests to QUnit, moved Jakefile.js to Makefile
* [2011-03-09] Passing default JSHint, and a minified version is now available
* [2011-03-09] Added documentation and published it to http://alexyoung.github.com/ico/
* [2011-03-09] 0.3.0 released: Split project into separate files, added build script, fixes for HorizontalBarGraph
* [2011-03-01] 0.2.2 released: Ico.SparkLine will now work correctly, particularly in IE6

h3. Targeted graph types

* Sparklines
Expand Down
34 changes: 27 additions & 7 deletions docs/ico.js
Expand Up @@ -277,10 +277,18 @@ Ico.Base = {
* @param {Integer} end A number to end at
* @returns {Array} An array of values
*/
makeRange: function(start, end) {
makeRange: function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
values.push(i);
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return values;
}
Expand Down Expand Up @@ -331,7 +339,6 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.options = {
width: parseInt(getStyle(element, 'width'), 10),
height: parseInt(getStyle(element, 'height'), 10),
labels: this.makeRange(1, this.data_size + 1), // Label data
plot_padding: 10, // Padding for the graph line/bar plots
font_size: 10, // Label font size
show_horizontal_labels: true,
Expand Down Expand Up @@ -371,7 +378,17 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.graph_height = this.options.height - (this.y_padding);

this.step = this.calculateStep();

this.grid_step = this.step;

if (this.options.labels) {
if (!this.grouped) {
this.grid_step = this.graph_width / this.options.labels.length;
this.snap_to_grid = true;
}
} else {
this.options.labels = this.makeRange(1, this.data_size + 1);
}

if (this.options.bar_labels) {
// TODO: Improve this so extra padding is used instead
this.range += this.normaliser.step;
Expand Down Expand Up @@ -554,12 +571,13 @@ Helpers.extend(Ico.BaseGraph.prototype, {
if (this.options.show_horizontal_labels) {
var x = this.x_padding_left + this.options.plot_padding + this.grid_start_offset,
x_labels = this.grouped ? this.flat_data.length : this.options.labels.length,
i;
i,
step = this.grid_step || this.step;

for (i = 0; i < x_labels; i++) {
pathString += 'M' + x + ',' + this.y_padding_top;
pathString += 'L' + x +',' + (this.y_padding_top + this.graph_height);
x = x + this.step;
x = x + step;
}

x = x - this.options.plot_padding - 1;
Expand Down Expand Up @@ -692,7 +710,8 @@ Helpers.extend(Ico.BaseGraph.prototype, {
},

drawHorizontalLabels: function() {
this.drawMarkers(this.options.labels, [1, 0], this.step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
var step = this.snap_to_grid ? this.grid_step : this.step;
this.drawMarkers(this.options.labels, [1, 0], step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
}
});
/**
Expand All @@ -711,6 +730,7 @@ Helpers.extend(Ico.BarGraph.prototype, {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;

// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
Expand Down
2 changes: 1 addition & 1 deletion docs/ico.min.js

Large diffs are not rendered by default.

34 changes: 27 additions & 7 deletions ico.js
Expand Up @@ -277,10 +277,18 @@ Ico.Base = {
* @param {Integer} end A number to end at
* @returns {Array} An array of values
*/
makeRange: function(start, end) {
makeRange: function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
values.push(i);
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return values;
}
Expand Down Expand Up @@ -331,7 +339,6 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.options = {
width: parseInt(getStyle(element, 'width'), 10),
height: parseInt(getStyle(element, 'height'), 10),
labels: this.makeRange(1, this.data_size + 1), // Label data
plot_padding: 10, // Padding for the graph line/bar plots
font_size: 10, // Label font size
show_horizontal_labels: true,
Expand Down Expand Up @@ -371,7 +378,17 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.graph_height = this.options.height - (this.y_padding);

this.step = this.calculateStep();

this.grid_step = this.step;

if (this.options.labels) {
if (!this.grouped) {
this.grid_step = this.graph_width / this.options.labels.length;
this.snap_to_grid = true;
}
} else {
this.options.labels = this.makeRange(1, this.data_size + 1);
}

if (this.options.bar_labels) {
// TODO: Improve this so extra padding is used instead
this.range += this.normaliser.step;
Expand Down Expand Up @@ -554,12 +571,13 @@ Helpers.extend(Ico.BaseGraph.prototype, {
if (this.options.show_horizontal_labels) {
var x = this.x_padding_left + this.options.plot_padding + this.grid_start_offset,
x_labels = this.grouped ? this.flat_data.length : this.options.labels.length,
i;
i,
step = this.grid_step || this.step;

for (i = 0; i < x_labels; i++) {
pathString += 'M' + x + ',' + this.y_padding_top;
pathString += 'L' + x +',' + (this.y_padding_top + this.graph_height);
x = x + this.step;
x = x + step;
}

x = x - this.options.plot_padding - 1;
Expand Down Expand Up @@ -692,7 +710,8 @@ Helpers.extend(Ico.BaseGraph.prototype, {
},

drawHorizontalLabels: function() {
this.drawMarkers(this.options.labels, [1, 0], this.step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
var step = this.snap_to_grid ? this.grid_step : this.step;
this.drawMarkers(this.options.labels, [1, 0], step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
}
});
/**
Expand All @@ -711,6 +730,7 @@ Helpers.extend(Ico.BarGraph.prototype, {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;

// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
Expand Down
2 changes: 1 addition & 1 deletion ico.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/base.js
Expand Up @@ -60,10 +60,18 @@ Ico.Base = {
* @param {Integer} end A number to end at
* @returns {Array} An array of values
*/
makeRange: function(start, end) {
makeRange: function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
values.push(i);
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return values;
}
Expand Down
1 change: 1 addition & 0 deletions src/graphs/bar.js
Expand Up @@ -14,6 +14,7 @@ Helpers.extend(Ico.BarGraph.prototype, {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;

// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
Expand Down
21 changes: 16 additions & 5 deletions src/graphs/base.js
Expand Up @@ -44,7 +44,6 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.options = {
width: parseInt(getStyle(element, 'width'), 10),
height: parseInt(getStyle(element, 'height'), 10),
labels: this.makeRange(1, this.data_size + 1), // Label data
plot_padding: 10, // Padding for the graph line/bar plots
font_size: 10, // Label font size
show_horizontal_labels: true,
Expand Down Expand Up @@ -84,7 +83,17 @@ Helpers.extend(Ico.BaseGraph.prototype, {
this.graph_height = this.options.height - (this.y_padding);

this.step = this.calculateStep();

this.grid_step = this.step;

if (this.options.labels) {
if (!this.grouped) {
this.grid_step = this.graph_width / this.options.labels.length;
this.snap_to_grid = true;
}
} else {
this.options.labels = this.makeRange(1, this.data_size + 1);
}

if (this.options.bar_labels) {
// TODO: Improve this so extra padding is used instead
this.range += this.normaliser.step;
Expand Down Expand Up @@ -267,12 +276,13 @@ Helpers.extend(Ico.BaseGraph.prototype, {
if (this.options.show_horizontal_labels) {
var x = this.x_padding_left + this.options.plot_padding + this.grid_start_offset,
x_labels = this.grouped ? this.flat_data.length : this.options.labels.length,
i;
i,
step = this.grid_step || this.step;

for (i = 0; i < x_labels; i++) {
pathString += 'M' + x + ',' + this.y_padding_top;
pathString += 'L' + x +',' + (this.y_padding_top + this.graph_height);
x = x + this.step;
x = x + step;
}

x = x - this.options.plot_padding - 1;
Expand Down Expand Up @@ -405,6 +415,7 @@ Helpers.extend(Ico.BaseGraph.prototype, {
},

drawHorizontalLabels: function() {
this.drawMarkers(this.options.labels, [1, 0], this.step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
var step = this.snap_to_grid ? this.grid_step : this.step;
this.drawMarkers(this.options.labels, [1, 0], step, this.options.plot_padding, [0, (this.options.font_size + 7) * -1]);
}
});

0 comments on commit c4586d0

Please sign in to comment.