From e640b5e0bcc4b55789d159c77f5a374e24337fec Mon Sep 17 00:00:00 2001
From: Adrien Gallou
Date: Sun, 15 Nov 2015 10:10:13 +0100
Subject: [PATCH 1/2] fix yaxis attributes on jquery2
`data-graph-yaxis-X-*` attributes doesn't work
on jQuery 2 (but `data-graph-yaxisX-*` work).
`data-graph-yaxis-X-*` works on the master branch
of jQuery.
In order to have a version that work on all
jQury versions we have to support the `data-graph-yaxisX-*`
version that will be the new norm.
To avoid a Backward compatibility break, we need to
support both versions of the attribute.
* Now all `data-graph-yaxis` attributes could be written
with or without a dash before the axis number.
* There is tests on all the attributes, in both versions
* tests are executed on both jQuery 2 and jQuery 1
see issue #60
---
.travis.yml | 2 +-
jquery.highchartTable.js | 36 +++++---
tests/baseSpec.js | 22 ++++-
tests/yaxisAttributesSpec.js | 155 +++++++++++++++++++++++++++++++++++
4 files changed, 200 insertions(+), 15 deletions(-)
create mode 100644 tests/yaxisAttributesSpec.js
diff --git a/.travis.yml b/.travis.yml
index 765671d..cc4105b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,4 +3,4 @@ node_js:
- '0.11'
env:
- JQUERY_VERSION=1.11.3 HIGHCHARTS_VERSION=2.2.4
- - JQUERY_VERSION=1.11.1 HIGHCHARTS_VERSION=2.2.4
+ - JQUERY_VERSION=2.1.4 HIGHCHARTS_VERSION=2.2.4
diff --git a/jquery.highchartTable.js b/jquery.highchartTable.js
index 3c03126..3f07b25 100644
--- a/jquery.highchartTable.js
+++ b/jquery.highchartTable.js
@@ -265,30 +265,44 @@
});
+ var getYaxisAttr = function($table, yAxisNum, name) {
+ var oldConvention = $table.data('graph-yaxis-' + yAxisNum + '-' + name);
+ if (typeof oldConvention != 'undefined') {
+ return oldConvention;
+ }
+
+ return $table.data('graph-yaxis' + yAxisNum + '-' + name);
+ };
+
var yAxisConfig = [];
var yAxisNum;
for (yAxisNum=1 ; yAxisNum <= nbYaxis ; yAxisNum++) {
var yAxisConfigCurrentAxis = {
title: {
- text: typeof $table.data('graph-yaxis-'+yAxisNum+'-title-text') != 'undefined' ? $table.data('graph-yaxis-'+yAxisNum+'-title-text') : null
+ text: typeof getYaxisAttr($table, yAxisNum, 'title-text') != 'undefined' ? getYaxisAttr($table, yAxisNum, 'title-text') : null
},
- max: typeof $table.data('graph-yaxis-'+yAxisNum+'-max') != 'undefined' ? $table.data('graph-yaxis-'+yAxisNum+'-max') : null,
- min: typeof $table.data('graph-yaxis-'+yAxisNum+'-min') != 'undefined' ? $table.data('graph-yaxis-'+yAxisNum+'-min') : null,
- reversed: $table.data('graph-yaxis-'+yAxisNum+'-reversed') == '1',
- opposite: $table.data('graph-yaxis-'+yAxisNum+'-opposite') == '1',
- tickInterval: $table.data('graph-yaxis-'+yAxisNum+'-tick-interval') || null,
+ max: typeof getYaxisAttr($table, yAxisNum, 'max') != 'undefined' ? getYaxisAttr($table, yAxisNum, 'max') : null,
+ min: typeof getYaxisAttr($table, yAxisNum, 'min') != 'undefined' ? getYaxisAttr($table, yAxisNum, 'min') : null,
+ reversed: getYaxisAttr($table, yAxisNum, 'reversed') == '1',
+ opposite: getYaxisAttr($table, yAxisNum, 'opposite') == '1',
+ tickInterval: getYaxisAttr($table, yAxisNum, 'tick-interval') || null,
labels: {
- rotation: $table.data('graph-yaxis-'+yAxisNum+'-rotation') || 0
+ rotation: getYaxisAttr($table, yAxisNum, 'rotation') || 0
},
- startOnTick: $table.data('graph-yaxis-'+yAxisNum+'-start-on-tick') !== "0",
- endOnTick: $table.data('graph-yaxis-'+yAxisNum+'-end-on-tick') !== "0",
+ startOnTick: getYaxisAttr($table, yAxisNum, 'start-on-tick') != "0",
+ endOnTick: getYaxisAttr($table, yAxisNum, 'end-on-tick') != "0",
stackLabels : {
- enabled: $table.data('graph-yaxis-'+yAxisNum+'-stacklabels-enabled') == '1'
+ enabled: getYaxisAttr($table, yAxisNum, 'stacklabels-enabled') == '1'
},
- gridLineInterpolation: $table.data('graph-yaxis-'+yAxisNum+'-grid-line-interpolation') || null
+ gridLineInterpolation: getYaxisAttr($table, yAxisNum, 'grid-line-interpolation') || null
};
var callableYAxisFormatter = getCallable(table, 'graph-yaxis-'+yAxisNum+'-formatter-callback');
+
+ if (!callableYAxisFormatter) {
+ callableYAxisFormatter = getCallable(table, 'graph-yaxis'+yAxisNum+'-formatter-callback');
+ }
+
if (callableYAxisFormatter) {
yAxisConfigCurrentAxis.labels.formatter = function () {
return callableYAxisFormatter(this.value);
diff --git a/tests/baseSpec.js b/tests/baseSpec.js
index dc50b39..235be60 100644
--- a/tests/baseSpec.js
+++ b/tests/baseSpec.js
@@ -29,8 +29,10 @@ describe("Base test", function() {
' ' +
' ';
- $('#fixture').remove();
- $('body').append(htmlContent);
+ $('body')
+ .empty()
+ .append(htmlContent)
+ ;
});
@@ -48,7 +50,21 @@ describe("Base test", function() {
expect(highChartConfig.series[0].data[1].name).toBe('12000');
expect(highChartConfig.series[0].data[1].y).toBe(12000);
expect(highChartConfig.series[0].data[2].name).toBe('18000');
- expect(highChartConfig.series[0].data[2].y).toBe(18000);
+ expect(highChartConfig.series[0].data[2].y).toBe(18000)
+ expect(highChartConfig.yAxis[0].reversed).toBe(false);
+
+ expect(highChartConfig.yAxis[0].reversed).toBe(false);
+ expect(highChartConfig.yAxis[0].stackLabels.enabled).toBe(false);
+ expect(highChartConfig.yAxis[0].min).toBeNull();
+ expect(highChartConfig.yAxis[0].max).toBeNull();
+ expect(highChartConfig.yAxis[0].title.text).toBeNull();
+ expect(highChartConfig.yAxis[0].opposite).toBe(false);
+ expect(highChartConfig.yAxis[0].tickInterval).toBe(null);
+ expect(highChartConfig.yAxis[0].labels.rotation).toBe(0);
+ expect(highChartConfig.yAxis[0].gridLineInterpolation).toBeNull();
+ expect(highChartConfig.yAxis[0].startOnTick).toBe(true);
+ expect(highChartConfig.yAxis[0].endOnTick).toBe(true);
+ expect(highChartConfig.yAxis[0].labels.formatter).toBeUndefined();
})
.highchartTable()
;
diff --git a/tests/yaxisAttributesSpec.js b/tests/yaxisAttributesSpec.js
new file mode 100644
index 0000000..98e3035
--- /dev/null
+++ b/tests/yaxisAttributesSpec.js
@@ -0,0 +1,155 @@
+
+describe("Test yaxis ttributes", function() {
+
+ var fixture;
+
+ it("With numeric", function() {
+
+ if ($.fn.jquery.substr(0, 1) == 2) {
+ return;
+ }
+
+ graph_absInvertedFormatter = function (value) {
+ return Math.abs(value) * -1;
+ };
+
+ var htmlContent = ' ' +
+ 'Example of title' +
+ '' +
+ ' ' +
+ ' | Month | ' +
+ ' Sales | ' +
+ '
' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' | January | ' +
+ ' 8000 | ' +
+ '
' +
+ ' ' +
+ ' | February | ' +
+ ' 12000 | ' +
+ '
' +
+ ' ' +
+ ' | March | ' +
+ ' 18000 | ' +
+ '
' +
+ ' ' +
+ '
';
+
+ $('body')
+ .empty()
+ .append(htmlContent)
+ ;
+
+ var beforeRenderCalled = false;
+
+ $('table')
+ .bind('highchartTable.beforeRender', function(event, highChartConfig) {
+ beforeRenderCalled = true;
+ expect(highChartConfig.yAxis[0].reversed).toBe(true);
+ expect(highChartConfig.yAxis[0].stackLabels.enabled).toBe(true);
+ expect(highChartConfig.yAxis[0].min).toBe(1000);
+ expect(highChartConfig.yAxis[0].max).toBe(25000);
+ expect(highChartConfig.yAxis[0].title.text).toBe("title example");
+ expect(highChartConfig.yAxis[0].opposite).toBe(true);
+ expect(highChartConfig.yAxis[0].tickInterval).toBe(1000);
+ expect(highChartConfig.yAxis[0].labels.rotation).toBe(90);
+ expect(highChartConfig.yAxis[0].gridLineInterpolation).toBe("circle");
+ expect(highChartConfig.yAxis[0].startOnTick).toBe(false);
+ expect(highChartConfig.yAxis[0].endOnTick).toBe(false);
+ expect(highChartConfig.yAxis[0].labels.formatter).toBeDefined();
+
+ })
+ .highchartTable()
+ ;
+
+ expect(beforeRenderCalled).toBe(true);
+ });
+
+
+ it("Without numeric", function() {
+
+ graph_absInvertedFormatter = function (value) {
+ return Math.abs(value) * -1;
+ };
+
+ var htmlContent = ' ' +
+ 'Example of title' +
+ '' +
+ ' ' +
+ ' | Month | ' +
+ ' Sales | ' +
+ '
' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' | January | ' +
+ ' 8000 | ' +
+ '
' +
+ ' ' +
+ ' | February | ' +
+ ' 12000 | ' +
+ '
' +
+ ' ' +
+ ' | March | ' +
+ ' 18000 | ' +
+ '
' +
+ ' ' +
+ '
';
+
+ $('body')
+ .empty()
+ .append(htmlContent)
+ ;
+
+
+
+ var beforeRenderCalled = false;
+
+ $('table')
+ .bind('highchartTable.beforeRender', function(event, highChartConfig) {
+ beforeRenderCalled = true;
+ expect(highChartConfig.yAxis[0].reversed).toBe(true);
+ expect(highChartConfig.yAxis[0].stackLabels.enabled).toBe(true);
+ expect(highChartConfig.yAxis[0].min).toBe(1000);
+ expect(highChartConfig.yAxis[0].max).toBe(25000);
+ expect(highChartConfig.yAxis[0].title.text).toBe("title example");
+ expect(highChartConfig.yAxis[0].opposite).toBe(true);
+ expect(highChartConfig.yAxis[0].tickInterval).toBe(1000);
+ expect(highChartConfig.yAxis[0].labels.rotation).toBe(90);
+ expect(highChartConfig.yAxis[0].gridLineInterpolation).toBe("circle");
+ expect(highChartConfig.yAxis[0].startOnTick).toBe(false);
+ expect(highChartConfig.yAxis[0].endOnTick).toBe(false);
+ expect(highChartConfig.yAxis[0].labels.formatter).toBeDefined();
+ })
+ .highchartTable()
+ ;
+
+ expect(beforeRenderCalled).toBe(true);
+ });
+});
+
+
From 36f1f78521ec783ba1bf66fc036460bbd220ffe5 Mon Sep 17 00:00:00 2001
From: Adrien Gallou
Date: Sun, 15 Nov 2015 15:31:40 +0100
Subject: [PATCH 2/2] fix sauelabs credentials
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c908164..9b7de80 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,8 +3,8 @@ node_js:
- '0.11'
env:
global:
- - secure: G+VyUjYXpYO3djiUL62Vj/0PuQmWpHyyXZtKXW+Df77C45Uc+/G0DQL/YGn4tqc4DeAX5W5myTmfAm2q+B1fkg687HFH5HBHp3/RhY++KcitnLZ+8DlvBCIMuvUjgYdq1+pWr+kXg0OCybyyecqdXgRZ3FNTpatf6PIXC5a8PFA=
- - secure: boiNPr9oRstsVXgXKqs/XfgWPJDNQYCkGjJ8tnZmGF2SVTCK5fOmwycbDpRk1oAzjwHc6pXoiLvqgRySFBoebpz8rIWEbjmxp06+9sN9bw51Za0RPCM2g+4XEg2yU/bzmEj3ZyI/ZEEpm5AOcxhGSyjyQjWiK8sefUB6WV8YkcI=
+ - secure: CvvR0KZBaTnVfo3ylWPc/qssKzkay5rejVoHWjR7DrIHaesj3O17puOAr+jYJJ220Q4mn2RwpdTIyYAjjSxblq5g+F/MJMwslRh7mEYfdn39LnF30JYp6BkMrcygsJS8xAQ18i17lVMqqeMyJ/+Hu7GvWu1r6ZaWkr2HZ/P26v4=
+ - secure: gT/SPMZhtp3dNjS9VIKez/+sKzihE/5ffNtKczhTi71CQkvptgd9xdcLigidIgwaWptd3t8HwNFaUutx78xTIb40oP0mZNo95LiwoI6W7vzLyJjst2BVKz+hqj4Jg1P8FHkD5/fop4E/pL4lXmMB1p1Zd5QEebX6hcXgFz/ha7U=
matrix:
- JQUERY_VERSION=1.11.3 HIGHCHARTS_VERSION=2.2.4
- JQUERY_VERSION=2.1.4 HIGHCHARTS_VERSION=2.2.4