Skip to content

Commit

Permalink
Fixed #4870, column width calculation not correct on logarithmic X axis.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Dec 22, 2015
1 parent 3869e88 commit 2d5d73c
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 14 deletions.
6 changes: 4 additions & 2 deletions gulpfile.js
Expand Up @@ -265,7 +265,7 @@ gulp.task('filesize', function () {

exec('git stash', function (error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
console.log('Error in stash: ' + error);
}

closureCompiler.compile(
Expand All @@ -275,7 +275,9 @@ gulp.task('filesize', function () {
if (result) {
oldSize = gzipSize.sync(result);
report();
exec('git stash apply && git stash drop');
exec('git stash apply && git stash drop', function (error) {
console.log(colors.red('Error in stash apply: ' + error));
});
} else {
console.log('Compilation error: ' + error);
}
Expand Down
10 changes: 7 additions & 3 deletions js/highcharts.src.js
Expand Up @@ -2,7 +2,7 @@
// @compilation_level SIMPLE_OPTIMIZATIONS

/**
* @license Highcharts JS v4.2.0-modified (2015-12-21)
* @license Highcharts JS v4.2.0-modified (2015-12-22)
*
* (c) 2009-2014 Torstein Honsi
*
Expand Down Expand Up @@ -13947,6 +13947,7 @@
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis.val2lin,
min,
max;

Expand Down Expand Up @@ -13982,8 +13983,11 @@


// Find the closest distance between processed points
for (i = processedXData.length - 1; i >= 0; i--) {
distance = processedXData[i] - processedXData[i - 1];
i = processedXData.length;
while (--i) {
distance = xAxis.isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];

if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) {
closestPointRange = distance;
Expand Down
10 changes: 7 additions & 3 deletions js/highmaps.src.js
@@ -1,5 +1,5 @@
/**
* @license Highmaps JS v4.2.0-modified (2015-12-21)
* @license Highmaps JS v4.2.0-modified (2015-12-22)
*
* (c) 2011-2014 Torstein Honsi
*
Expand Down Expand Up @@ -13440,6 +13440,7 @@
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis.val2lin,
min,
max;

Expand Down Expand Up @@ -13475,8 +13476,11 @@


// Find the closest distance between processed points
for (i = processedXData.length - 1; i >= 0; i--) {
distance = processedXData[i] - processedXData[i - 1];
i = processedXData.length;
while (--i) {
distance = xAxis.isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];

if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) {
closestPointRange = distance;
Expand Down
12 changes: 8 additions & 4 deletions js/highstock.src.js
Expand Up @@ -2,7 +2,7 @@
// @compilation_level SIMPLE_OPTIMIZATIONS

/**
* @license Highstock JS v4.2.0-modified (2015-12-21)
* @license Highstock JS v4.2.0-modified (2015-12-22)
*
* (c) 2009-2014 Torstein Honsi
*
Expand Down Expand Up @@ -13947,6 +13947,7 @@
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis.val2lin,
min,
max;

Expand Down Expand Up @@ -13982,8 +13983,11 @@


// Find the closest distance between processed points
for (i = processedXData.length - 1; i >= 0; i--) {
distance = processedXData[i] - processedXData[i - 1];
i = processedXData.length;
while (--i) {
distance = xAxis.isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];

if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) {
closestPointRange = distance;
Expand Down Expand Up @@ -19889,7 +19893,7 @@
* End ordinal axis logic *
*****************************************************************************/
/**
* Highstock JS v4.2.0-modified (2015-12-21)
* Highstock JS v4.2.0-modified (2015-12-22)
* Highcharts Broken Axis module
*
* License: www.highcharts.com/license
Expand Down
8 changes: 6 additions & 2 deletions js/parts/Series.js
Expand Up @@ -515,6 +515,7 @@ Series.prototype = {
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis.val2lin,
min,
max;

Expand Down Expand Up @@ -550,8 +551,11 @@ Series.prototype = {


// Find the closest distance between processed points
for (i = processedXData.length - 1; i >= 0; i--) {
distance = processedXData[i] - processedXData[i - 1];
i = processedXData.length;
while (--i) {
distance = xAxis.isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];

if (distance > 0 && (closestPointRange === UNDEFINED || distance < closestPointRange)) {
closestPointRange = distance;
Expand Down
@@ -0,0 +1,5 @@
---
resources:
- https://code.jquery.com/qunit/qunit-1.19.0.js
- https://code.jquery.com/qunit/qunit-1.19.0.css
...
@@ -0,0 +1,8 @@
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>

<div id="qunit"></div>
<div id="qunit-fixture"></div>


<div id="container" style="width: 600px; margin: 0 auto;"></div>
59 changes: 59 additions & 0 deletions samples/issues/highcharts-4.2.1/4870-log-xaxis-pointwidth/demo.js
@@ -0,0 +1,59 @@

$(function () {
QUnit.test('Automatic column width on log X axis', function (assert) {
var chart = Highcharts.chart('container', {

"xAxis": {
type: 'logarithmic'
},
"series": [{

"type": "column",
//"pointWidth": 10,
"data": [{
"x": 1,
"y": 1
}, {

"x": 2,
"y": 2
}, {

"x": 3,
"y": 3
}, {

"x": 4,
"y": 4
}, {

"x": 5,
"y": 5
}]
}]
});

var bBox3 = chart.series[0].points[3].graphic.getBBox(),
bBox4 = chart.series[0].points[4].graphic.getBBox();

assert.strictEqual(
typeof bBox3.x,
'number',
'Box is ok'
);
assert.strictEqual(
typeof bBox3.width,
'number',
'Box is ok'
);
assert.strictEqual(
typeof bBox4.x,
'number',
'Box is ok'
);
assert.ok(
bBox3.x + bBox3.width < bBox4.x,
'No overlapping points'
);
});
});

0 comments on commit 2d5d73c

Please sign in to comment.