Skip to content

Commit

Permalink
Merge branch 'master' into ts/logarithmicaxis
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Mar 27, 2020
2 parents 6c39dee + cccf5a0 commit 2ffff1c
Show file tree
Hide file tree
Showing 51 changed files with 1,518 additions and 711 deletions.
6 changes: 3 additions & 3 deletions changelog/highcharts/7.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
- Added [Organization Chart](https://www.highcharts.com/docs/chart-and-series-types/organization-chart) series type.
- Added [Item Chart](https://www.highcharts.com/docs/chart-and-series-types/item-chart) series type for visualizing item counts and parliaments.
- Added [Dependency Wheel](https://www.highcharts.com/docs/chart-and-series-types/dependency-wheel) series type.
- Added [Timeline](https://www.highcharts.com/docs/chart-and-series-types/timeline) series type.
- Added [Timeline](https://www.highcharts.com/docs/chart-and-series-types/timeline-series) series type.
- Added [3D Pyramid](https://www.highcharts.com/docs/chart-and-series-types/pyramid-3d) and [3D Funnel](https://www.highcharts.com/docs/chart-and-series-types/funnel-3d) series types.
- [Accessibility](https://www.highcharts.com/docs/accessibility/accessibility-module) - improved experience for screen reader users, support for dynamic data and drilldown, as well as support for voice input software.
- Added `inactive` states to series and points, allowing other series to be dimmed when the user is hovering the data or legend. To bring back the old series dimming behavior, set [plotOptions.series.states.inactive.opacity](https://api.highcharts.com/highcharts/plotOptions.series.states.inactive.opacity) to 1.
- Added [levels](https://api.highcharts.com/highcharts/plotOptions.series.sankey.levels) to sankey series.
- Added [levels](https://api.highcharts.com/highcharts/plotOptions.sankey.levels) to sankey series.
- Added `annotation.events`: `add`, `afterUpdate` and `remove`.
- Added full screen capabilities to exporting module.
- Added option [treemap.events.setRootNode](https://api.highcharts.com/highcharts/treemap.events.setRootNode).
- Added option [series.treemap.events.setRootNode](https://api.highcharts.com/highcharts/series.treemap.events.setRootNode).
- Added option [xAxis.margin](https://api.highcharts.com/highcharts/xAxis.margin) to ensure a distance between multiple axes on the same side.
- Added options [plotOptions.sankey.borderWidth](https://api.highcharts.com/highcharts/plotOptions.sankey.borderWidth) and `sankey.borderColor` for sankey nodes.
- Added force directed algorithm for improved packing of packed bubble charts.
Expand Down
4 changes: 2 additions & 2 deletions js/modules/accessibility/components/InfoRegionsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ extend(InfoRegionsComponent.prototype, /** @lends Highcharts.InfoRegionsComponen
return this.getCategoryAxisRangeDesc(axis);
}
// Use time range, not from-to?
if (axis.isDatetimeAxis && (axis.min === 0 || axis.dataMin === 0)) {
if (axis.dateTime && (axis.min === 0 || axis.dataMin === 0)) {
return this.getAxisTimeLengthDesc(axis);
}
// Just use from and to.
Expand Down Expand Up @@ -545,7 +545,7 @@ extend(InfoRegionsComponent.prototype, /** @lends Highcharts.InfoRegionsComponen
getAxisFromToDescription: function (axis) {
var chart = this.chart, dateRangeFormat = chart.options.accessibility
.screenReaderSection.axisRangeDateFormat, format = function (axisKey) {
return axis.isDatetimeAxis ? chart.time.dateFormat(dateRangeFormat, axis[axisKey]) : axis[axisKey];
return axis.dateTime ? chart.time.dateFormat(dateRangeFormat, axis[axisKey]) : axis[axisKey];
};
return chart.langFormat('accessibility.axis.rangeFromTo', {
chart: chart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function getSeriesAxisDescriptionText(series, axisCollection) {
* The description as string.
*/
function getPointA11yTimeDescription(point) {
var series = point.series, chart = series.chart, a11yOptions = chart.options.accessibility.point || {}, hasDateXAxis = series.xAxis && series.xAxis.isDatetimeAxis;
var series = point.series, chart = series.chart, a11yOptions = chart.options.accessibility.point || {}, hasDateXAxis = series.xAxis && series.xAxis.dateTime;
if (hasDateXAxis) {
var tooltipDateFormat = Tooltip.prototype.getXDateFormat.call({
getDateFormat: Tooltip.prototype.getDateFormat,
Expand Down
2 changes: 1 addition & 1 deletion js/modules/accessibility/utils/chartUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getAxisDescription(axis) {
axis.axisTitle && axis.axisTitle.textStr ||
axis.options.id ||
axis.categories && 'categories' ||
axis.isDatetimeAxis && 'Time' ||
axis.dateTime && 'Time' ||
'values'));
}
/**
Expand Down
12 changes: 11 additions & 1 deletion js/modules/boost/wgl-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import GLVertexBuffer from './wgl-vbuffer.js';
import Color from '../../parts/Color.js';
var color = Color.parse;
import U from '../../parts/Utilities.js';
var isNumber = U.isNumber, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
var isNumber = U.isNumber, isObject = U.isObject, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
var win = H.win, doc = win.document;
/* eslint-disable valid-jsdoc */
/**
Expand Down Expand Up @@ -411,6 +411,16 @@ function GLRenderer(postRenderCallback) {
// pcolor[1] /= 255.0;
// pcolor[2] /= 255.0;
// }
// Handle the point.color option (#5999)
var pointOptions = rawData && rawData[i];
if (!useRaw && isObject(pointOptions, true)) {
if (pointOptions.color) {
pcolor = color(pointOptions.color).rgba;
pcolor[0] /= 255.0;
pcolor[1] /= 255.0;
pcolor[2] /= 255.0;
}
}
if (useRaw) {
x = d[0];
y = d[1];
Expand Down
3 changes: 2 additions & 1 deletion js/modules/dumbbell.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ seriesType('dumbbell', 'arearange', {
*/
getColumnMetrics: function () {
var metrics = colProto.getColumnMetrics.apply(this, arguments);
metrics.offset = metrics.offset + metrics.width / 2;
metrics.offset += metrics.width / 2;
return metrics;
},
translatePoint: areaRangeProto.translate,
Expand Down Expand Up @@ -247,6 +247,7 @@ seriesType('dumbbell', 'arearange', {
shapeArgs.x = point.plotX - pointWidth / 2;
point.tooltipPos = null;
});
this.columnMetrics.offset -= this.columnMetrics.width / 2;
},
seriesDrawPoints: areaRangeProto.drawPoints,
/**
Expand Down
6 changes: 3 additions & 3 deletions js/modules/export-data.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Highcharts.Chart.prototype.getDataRows = function (multiLevelHeaders) {
}
if (item instanceof Highcharts.Axis) {
return (item.options.title && item.options.title.text) ||
(item.isDatetimeAxis ? 'DateTime' : 'Category');
(item.dateTime ? 'DateTime' : 'Category');
}
if (multiLevelHeaders) {
return {
Expand All @@ -333,7 +333,7 @@ Highcharts.Chart.prototype.getDataRows = function (multiLevelHeaders) {
series.chart[axisName][pIdx] :
series[axisName];
categoryMap[prop] = (axis && axis.categories) || [];
dateTimeValueAxisMap[prop] = (axis && axis.isDatetimeAxis);
dateTimeValueAxisMap[prop] = (axis && axis.dateTime);
});
return {
categoryMap: categoryMap,
Expand Down Expand Up @@ -459,7 +459,7 @@ Highcharts.Chart.prototype.getDataRows = function (multiLevelHeaders) {
row) {
var category = row.name;
if (xAxis && !defined(category)) {
if (xAxis.isDatetimeAxis) {
if (xAxis.dateTime) {
if (row.x instanceof Date) {
row.x = row.x.getTime();
}
Expand Down
2 changes: 1 addition & 1 deletion js/modules/parallel-coordinates.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ function addFormattedValue(proceed) {
if (labelFormat) {
formattedValue = format(labelFormat, extend(this, { value: this.y }), chart);
}
else if (yAxis.isDatetimeAxis) {
else if (yAxis.dateTime) {
formattedValue = chart.time.dateFormat(chart.time.resolveDTLFormat(yAxisOptions.dateTimeLabelFormats[yAxis.tickPositions.info.unitName]).main, this.y);
}
else if (yAxisOptions.categories) {
Expand Down
155 changes: 96 additions & 59 deletions js/modules/series-label.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import H from '../parts/Globals.js';
* https://jsfiddle.net/highcharts/y5A37/
*/
import U from '../parts/Utilities.js';
var addEvent = U.addEvent, animObject = U.animObject, extend = U.extend, fireEvent = U.fireEvent, isNumber = U.isNumber, pick = U.pick, syncTimeout = U.syncTimeout;
var addEvent = U.addEvent, animObject = U.animObject, extend = U.extend, fireEvent = U.fireEvent, format = U.format, isNumber = U.isNumber, pick = U.pick, syncTimeout = U.syncTimeout;
import '../parts/Chart.js';
import '../parts/Series.js';
var labelDistance = 3, Series = H.Series, SVGRenderer = H.SVGRenderer, Chart = H.Chart;
Expand Down Expand Up @@ -92,6 +92,26 @@ H.setOptions({
* connector.
*/
connectorNeighbourDistance: 24,
/**
* A format string for the label, with support for a subset of
* HTML. Variables are enclosed by curly brackets. Available
* variables are `name`, `options.xxx`, `color` and other
* members from the `series` object. Use this option also to set
* a static text for the label.
*
* @type string
* @since next
*/
format: void 0,
/**
* Callback function to format each of the series' labels. The
* `this` keyword refers to the series object. By default the
* `formatter` is undefined and the `series.name` is rendered.
*
* @type {Highcharts.FormatterCallbackFunction<Series>}
* @since next
*/
formatter: void 0,
/**
* For area-like series, allow the font size to vary so that
* small areas get a smaller font size. The default applies this
Expand Down Expand Up @@ -464,10 +484,11 @@ Chart.prototype.drawSeriesLabels = function () {
});
});
chart.series.forEach(function (series) {
if (!series.xAxis && !series.yAxis) {
var labelOptions = series.options.label;
if (!labelOptions || (!series.xAxis && !series.yAxis)) {
return;
}
var bBox, x, y, results = [], clearPoint, i, best, labelOptions = series.options.label, inverted = chart.inverted, paneLeft = (inverted ? series.yAxis.pos : series.xAxis.pos), paneTop = (inverted ? series.xAxis.pos : series.yAxis.pos), paneWidth = chart.inverted ? series.yAxis.len : series.xAxis.len, paneHeight = chart.inverted ? series.xAxis.len : series.yAxis.len, points = series.interpolatedPoints, onArea = pick(labelOptions.onArea, !!series.area), label = series.labelBySeries, isNew = !label, minFontSize = labelOptions.minFontSize, maxFontSize = labelOptions.maxFontSize, dataExtremes, areaMin, areaMax, colorClass = 'highcharts-color-' + pick(series.colorIndex, 'none');
var bBox, x, y, results = [], clearPoint, i, best, inverted = chart.inverted, paneLeft = (inverted ? series.yAxis.pos : series.xAxis.pos), paneTop = (inverted ? series.xAxis.pos : series.yAxis.pos), paneWidth = chart.inverted ? series.yAxis.len : series.xAxis.len, paneHeight = chart.inverted ? series.xAxis.len : series.yAxis.len, points = series.interpolatedPoints, onArea = pick(labelOptions.onArea, !!series.area), label = series.labelBySeries, isNew = !label, minFontSize = labelOptions.minFontSize, maxFontSize = labelOptions.maxFontSize, dataExtremes, areaMin, areaMax, colorClass = 'highcharts-color-' + pick(series.colorIndex, 'none');
// Stay within the area data bounds (#10038)
if (onArea && !inverted) {
dataExtremes = [
Expand Down Expand Up @@ -497,8 +518,15 @@ Chart.prototype.drawSeriesLabels = function () {
}
if (series.visible && !series.isSeriesBoosting && points) {
if (!label) {
var labelText = series.name;
if (typeof labelOptions.format === 'string') {
labelText = format(labelOptions.format, series, chart);
}
else if (labelOptions.formatter) {
labelText = labelOptions.formatter.call(series);
}
series.labelBySeries = label = chart.renderer
.label(series.name, 0, -9999, 'connector')
.label(labelText, 0, -9999, 'connector')
.addClass('highcharts-series-label ' +
'highcharts-series-label-' + series.index + ' ' +
(series.options.className || '') +
Expand All @@ -508,7 +536,12 @@ Chart.prototype.drawSeriesLabels = function () {
color: onArea ?
chart.renderer.getContrast(series.color) :
series.color
}, series.options.label.style));
}, labelOptions.style || {}));
label.attr({
opacity: chart.renderer.forExport ? 1 : 0,
stroke: series.color,
'stroke-width': 1
});
}
// Adapt label sizes to the sum of the data
if (minFontSize && maxFontSize) {
Expand All @@ -519,9 +552,6 @@ Chart.prototype.drawSeriesLabels = function () {
label
.attr({
padding: 0,
opacity: chart.renderer.forExport ? 1 : 0,
stroke: series.color,
'stroke-width': 1,
zIndex: 3
})
.add();
Expand Down Expand Up @@ -605,7 +635,7 @@ Chart.prototype.drawSeriesLabels = function () {
});
// Move it if needed
var dist = Math.sqrt(Math.pow(Math.abs(best.x - label.x), 2), Math.pow(Math.abs(best.y - label.y), 2));
if (dist) {
if (dist && series.labelBySeries) {
// Move fast and fade in - pure animation movement is
// distractive...
var attr = {
Expand All @@ -623,32 +653,36 @@ Chart.prototype.drawSeriesLabels = function () {
};
attr = {};
}
// Default initial animation to a fraction of the series
// animation (#9396)
var animationOptions = void 0;
if (isNew) {
animationOptions = animObject(series.options.animation);
// @todo: Safely remove any cast after merging #13005
animationOptions.duration *= 0.2;
}
series.labelBySeries
.attr(extend(attr, {
anchorX: best.connectorPoint &&
best.connectorPoint.plotX + paneLeft,
anchorY: best.connectorPoint &&
best.connectorPoint.plotY + paneTop
}))
.animate(anim, isNew ?
// Default initial animation to a fraction of
// the series animation (#9396)
animObject(series.options.animation).duration * 0.2 :
// On updating, default to the general chart
// animation
chart.renderer.globalAnimation);
.animate(anim, animationOptions);
// Record closest point to stick to for sync redraw
series.options.kdNow = true;
series.buildKDTree();
var closest = series.searchPoint({
chartX: best.x,
chartY: best.y
}, true);
label.closest = [
closest,
best.x - closest.plotX,
best.y - closest.plotY
];
if (closest) {
label.closest = [
closest,
best.x - (closest.plotX || 0),
best.y - (closest.plotY || 0)
];
}
}
}
else {
Expand All @@ -670,47 +704,50 @@ Chart.prototype.drawSeriesLabels = function () {
* @function drawLabels
*/
function drawLabels(e) {
var chart = this, delay = animObject(chart.renderer.globalAnimation).duration;
chart.labelSeries = [];
chart.labelSeriesMaxSum = 0;
U.clearTimeout(chart.seriesLabelTimer);
// Which series should have labels
chart.series.forEach(function (series) {
var options = series.options.label, label = series.labelBySeries, closest = label && label.closest;
if (options.enabled &&
series.visible &&
(series.graph || series.area) &&
!series.isSeriesBoosting) {
chart.labelSeries.push(series);
if (options.minFontSize && options.maxFontSize) {
series.sum = series.yData.reduce(function (pv, cv) {
return (pv || 0) + (cv || 0);
}, 0);
chart.labelSeriesMaxSum = Math.max(chart.labelSeriesMaxSum, series.sum);
}
// The labels are processing heavy, wait until the animation is done
if (e.type === 'load') {
delay = Math.max(delay, animObject(series.options.animation).duration);
}
// Keep the position updated to the axis while redrawing
if (closest) {
if (typeof closest[0].plotX !== 'undefined') {
label.animate({
x: closest[0].plotX + closest[1],
y: closest[0].plotY + closest[2]
});
if (this.renderer) {
var chart = this, delay = animObject(chart.renderer.globalAnimation).duration;
chart.labelSeries = [];
chart.labelSeriesMaxSum = 0;
U.clearTimeout(chart.seriesLabelTimer);
// Which series should have labels
chart.series.forEach(function (series) {
var options = series.options.label, label = series.labelBySeries, closest = label && label.closest;
if (options.enabled &&
series.visible &&
(series.graph || series.area) &&
!series.isSeriesBoosting) {
chart.labelSeries.push(series);
if (options.minFontSize && options.maxFontSize) {
series.sum = series.yData.reduce(function (pv, cv) {
return (pv || 0) + (cv || 0);
}, 0);
chart.labelSeriesMaxSum = Math.max(chart.labelSeriesMaxSum, series.sum);
}
else {
label.attr({ opacity: 0 });
// The labels are processing heavy, wait until the animation is
// done
if (e.type === 'load') {
delay = Math.max(delay, animObject(series.options.animation).duration);
}
// Keep the position updated to the axis while redrawing
if (closest) {
if (typeof closest[0].plotX !== 'undefined') {
label.animate({
x: closest[0].plotX + closest[1],
y: closest[0].plotY + closest[2]
});
}
else {
label.attr({ opacity: 0 });
}
}
}
}
});
chart.seriesLabelTimer = syncTimeout(function () {
if (chart.series && chart.labelSeries) { // #7931, chart destroyed
chart.drawSeriesLabels();
}
}, chart.renderer.forExport || !delay ? 0 : delay);
});
chart.seriesLabelTimer = syncTimeout(function () {
if (chart.series && chart.labelSeries) { // #7931, chart destroyed
chart.drawSeriesLabels();
}
}, chart.renderer.forExport || !delay ? 0 : delay);
}
}
// Leave both events, we handle animation differently (#9815)
addEvent(Chart, 'load', drawLabels);
Expand Down

0 comments on commit 2ffff1c

Please sign in to comment.