forked from highcharts/highcharts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test, linted and adapted to pass in Safari.
- Loading branch information
1 parent
44deb74
commit 0bb91ed
Showing
1 changed file
with
73 additions
and
72 deletions.
There are no files selected for viewing
145 changes: 73 additions & 72 deletions
145
samples/unit-tests/drilldown/activedatalabelstyle/demo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,87 @@ | ||
QUnit.test('activeDataLabelStyle', function (assert) { | ||
var getDataLabelFill = function (point) { | ||
return point.dataLabel.element.childNodes[0].style.fill; | ||
}; | ||
var chart = Highcharts.chart('container', { | ||
chart: { | ||
type: 'column' | ||
}, | ||
plotOptions: { | ||
series: { | ||
dataLabels: { | ||
enabled: true, | ||
inside: true | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: [{ | ||
drilldown: 'fruits', | ||
y: 20, | ||
color: '#000000' | ||
}] | ||
}], | ||
drilldown: { | ||
series: [{ | ||
id: 'fruits', | ||
data: [2] | ||
}] | ||
} | ||
}) | ||
series = series = chart.series[0] | ||
point = series.points[0]; | ||
assert.strictEqual( | ||
getDataLabelFill(point), | ||
'rgb(13, 35, 58)', | ||
function getDataLabelFill(point) { | ||
return point.dataLabel.element.childNodes[0].style.fill; | ||
} | ||
var chart = Highcharts.chart('container', { | ||
chart: { | ||
type: 'column' | ||
}, | ||
plotOptions: { | ||
series: { | ||
dataLabels: { | ||
enabled: true, | ||
inside: true | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: [{ | ||
drilldown: 'fruits', | ||
y: 20, | ||
color: '#000000' | ||
}] | ||
}], | ||
drilldown: { | ||
series: [{ | ||
id: 'fruits', | ||
data: [2] | ||
}] | ||
} | ||
}), | ||
|
||
series = chart.series[0], | ||
point = series.points[0]; | ||
|
||
|
||
assert.ok( | ||
getDataLabelFill(point) === 'rgb(13, 35, 58)' || getDataLabelFill(point) === '#0d233a', | ||
'activeDataLabelStyle.color default to rgb(13, 35, 58)' | ||
); | ||
|
||
// @notice Would have been nice with a chart.update. | ||
// @notice activeDataLabelStyle should probably be possible to override on a series or point level. | ||
chart.destroy(); | ||
chart = Highcharts.chart('container', { | ||
chart: { | ||
type: 'column' | ||
}, | ||
plotOptions: { | ||
series: { | ||
dataLabels: { | ||
enabled: true, | ||
inside: true | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: [{ | ||
drilldown: 'fruits', | ||
y: 20, | ||
color: '#000000' | ||
}] | ||
}], | ||
drilldown: { | ||
activeDataLabelStyle: { | ||
color: 'contrast' | ||
}, | ||
series: [{ | ||
id: 'fruits', | ||
data: [2] | ||
}] | ||
} | ||
}), | ||
series = chart.series[0], | ||
point = series.points[0]; | ||
assert.strictEqual( | ||
getDataLabelFill(point), | ||
'rgb(255, 255, 255)', | ||
chart = Highcharts.chart('container', { | ||
chart: { | ||
type: 'column' | ||
}, | ||
plotOptions: { | ||
series: { | ||
dataLabels: { | ||
enabled: true, | ||
inside: true | ||
} | ||
} | ||
}, | ||
series: [{ | ||
data: [{ | ||
drilldown: 'fruits', | ||
y: 20, | ||
color: '#000000' | ||
}] | ||
}], | ||
drilldown: { | ||
activeDataLabelStyle: { | ||
color: 'contrast' | ||
}, | ||
series: [{ | ||
id: 'fruits', | ||
data: [2] | ||
}] | ||
} | ||
}); | ||
series = chart.series[0]; | ||
point = series.points[0]; | ||
|
||
assert.ok( | ||
getDataLabelFill(point) === 'rgb(255, 255, 255)' || getDataLabelFill(point) === '#ffffff', | ||
'activeDataLabelStyle.color contrast to black' | ||
); | ||
point.update({ | ||
color: '#FFFFFF' | ||
color: '#FFFFFF' | ||
}); | ||
assert.strictEqual( | ||
getDataLabelFill(point), | ||
'rgb(0, 0, 0)', | ||
assert.ok( | ||
getDataLabelFill(point) === 'rgb(0, 0, 0)' || getDataLabelFill(point) === '#000000', | ||
'activeDataLabelStyle.color contrast to white' | ||
); | ||
}); |