diff --git a/samples/react/area/multi-axis-with-seriesname-arrays.html b/samples/react/area/multi-axis-with-seriesname-arrays.html new file mode 100644 index 000000000..9ead62ad0 --- /dev/null +++ b/samples/react/area/multi-axis-with-seriesname-arrays.html @@ -0,0 +1,227 @@ + + + + + + + Multi-YAxis-with-seriesName-arrays + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ <div id="chart"> + <ReactApexChart options={this.state.options} series={this.state.series} type="area" height={350} /> +</div> +
+ + + + + + diff --git a/samples/react/boxPlot/boxplot-scatter.html b/samples/react/boxPlot/boxplot-scatter.html index 2d134025b..82e83845f 100644 --- a/samples/react/boxPlot/boxplot-scatter.html +++ b/samples/react/boxPlot/boxplot-scatter.html @@ -118,10 +118,6 @@ x: new Date('2020-01-01').getTime(), y: 27 }, - { - x: new Date('2020-01-01').getTime(), - y: 78 - }, { x: new Date('2021-01-01').getTime(), y: 15 diff --git a/samples/react/column/stacked-column-with-line-new.html b/samples/react/column/stacked-column-with-line-new.html new file mode 100644 index 000000000..a215c4392 --- /dev/null +++ b/samples/react/column/stacked-column-with-line-new.html @@ -0,0 +1,338 @@ + + + + + + + Stacked Column with line - new config style + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ <div id="chart"> + <ReactApexChart options={this.state.options} series={this.state.series} type="line" height={350} /> +</div> +
+ + + + + + diff --git a/samples/react/column/stacked-column-with-line.html b/samples/react/column/stacked-column-with-line.html index 8f492f46e..d7f344757 100644 --- a/samples/react/column/stacked-column-with-line.html +++ b/samples/react/column/stacked-column-with-line.html @@ -60,7 +60,7 @@
<div id="chart"> - <ReactApexChart options={this.state.options} series={this.state.series} type="line" /> + <ReactApexChart options={this.state.options} series={this.state.series} type="line" height={350} /> </div>
@@ -230,10 +230,10 @@ '#d5e2eb' ], chart: { - height: '350', + height: 350, width: '90%', type: 'line', - stacked: 'true', + stacked: true, zoom: { enabled: true, type: 'x' @@ -333,7 +333,7 @@ return (
- +
diff --git a/samples/source/area/multi-axis-with-seriesname-arrays.xml b/samples/source/area/multi-axis-with-seriesname-arrays.xml new file mode 100644 index 000000000..2761459d9 --- /dev/null +++ b/samples/source/area/multi-axis-with-seriesname-arrays.xml @@ -0,0 +1,140 @@ +Multi-YAxis-with-seriesName-arrays + + + + + + + +chart: { + type: 'area', + height: 350, + stacked: false +}, +colors: ['#00EE00', '#008800', '#FF0000', '#AA00FF'], +dataLabels: { + enabled: false +}, +stroke: { + curve: 'monotoneCubic', + width: [4, 4, 2, 2], + dashArray: [0, 0, 2, 2] +}, +legend: { + position: 'top', + horizontalAlign: 'left' +}, +yaxis: [ + { + seriesName: ['Broccoli', 'Spinach'], + axisTicks: { + show: true, + color: '#008800' + }, + axisBorder: { + show: true, + color: '#008800' + }, + labels: { + style: { + colors: '#008800', + }, + formatter: (val) => { + let ref = val.toFixed(0); + return val == ref ? val : '' + } + }, + title: { + text: "Vegetables", + style: { + color: '#008800' + } + }, + }, + { + seriesName: ['Plums','Apples'], + opposite: true, + axisTicks: { + show: true, + color: '#FF0000' + }, + axisBorder: { + show: true, + color: '#FF0000' + }, + labels: { + style: { + colors: '#FF0000', + }, + formatter: (val) => { + let ref = val.toFixed(0); + return val == ref ? val : '' + } + }, + title: { + text: "Fruit", + style: { + color: '#FF0000' + } + }, + } +], +xaxis: { + type: 'datetime' +} + + + +[{ + name: 'Broccoli', + data: data1 + }, + { + name: 'Spinach', + data: data2 + }, + { + name: 'Apples', + data: data3 + }, + { + name: 'Plums', + data: data4 + }] + + + \ No newline at end of file diff --git a/samples/source/boxPlot/boxplot-scatter.xml b/samples/source/boxPlot/boxplot-scatter.xml index ce2c6e6c2..25b6cbd7d 100644 --- a/samples/source/boxPlot/boxplot-scatter.xml +++ b/samples/source/boxPlot/boxplot-scatter.xml @@ -73,10 +73,6 @@ tooltip: { x: new Date('2020-01-01').getTime(), y: 27 }, - { - x: new Date('2020-01-01').getTime(), - y: 78 - }, { x: new Date('2021-01-01').getTime(), y: 15 diff --git a/samples/source/column/stacked-column-with-line-new.xml b/samples/source/column/stacked-column-with-line-new.xml new file mode 100644 index 000000000..a72848cc6 --- /dev/null +++ b/samples/source/column/stacked-column-with-line-new.xml @@ -0,0 +1,246 @@ +Stacked Column with line - new config style + + + +colors: [ + '#6a6ba5', + '#f9a867', + '#2a6b9b', + '#6c98b7', + '#abc4d6', + '#d5e2eb' +], +chart: { + height: 350, + width: '90%', + type: 'line', + stacked: true, + zoom: { + enabled: true, + type: 'x' + } +}, +tooltip: { + followCursor: true, + shared: false +}, +responsive: [ + { + breakpoint: 480 + } +], +markers: { + size: 0, + fillOpacity: 0, + strokeOpacity: 0 +}, +stroke: { + width: 2 +}, +xaxis: { + categories: [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + type: 'numeric', + tickPlacement: 'on', + tickAmount: 'dataPoints', + labels: { + showDuplicates: false, + formatter: function(value) { + return value.toFixed(0) + } + } +}, +yaxis: [ + { + seriesName: 'Line', + opposite: true + }, + { + seriesName: ['Bar1','Bar2','Bar3','bar4'] + } +], +legend: { + showForSingleSeries: true +}, +fill: { + opacity: 1 +} + + + +[ + { + "name": "Line", + "type": "line", + "data": [ + 37, + 38.3, + 33.01, + 30, + 29.7, + 30, + 35.2, + 44, + 45, + 41, + 22, + 22.5, + 29.1, + 25.5, + 41.2, + 43.8, + 39, + 23, + 26, + 22, + 34, + 37, + 43, + 41, + 17 + ] + }, + { + "name": "Bar1", + "type": "bar", + "data": [ + -1.57, + -1.83, + -0.29, + 2, + 0.23, + 3, + 0, + -0.77, + 0, + 0, + 0, + -0.16, + -0.5, + -0.75, + -0.93, + -0.93, + -0.45, + 0, + 0, + -0.23, + -0.95, + -1.12, + -0.51, + 0.76 + ] + }, + { + "name": "Bar2", + "type": "bar", + "data": [ + -2.99, + -0.43, + 0.39, + 2.8, + 0.23, + 1.2, + -0.06, + -2.96, + -2.74, + -2.58, + -1.79, + -2.16, + -1.9, + -1.75, + -2, + -2.16, + -1.75, + -1.9, + -2.74, + -2.58, + -3.8, + -1.24, + -0.01, + 1.89 + ] + }, + { + "name": "Bar3", + "type": "bar", + "data": [ + 0.09, + 4, + 4.83, + 6.86, + 3.86, + 5, + 1.7, + -1.21, + 0, + 0.02, + 0.07, + -0.15, + -0.09, + 0, + -0.61, + -1.75, + 0, + -0.43, + -1.5, + -0.66, + -3.06, + 0.06, + 0.15, + 1.48 + ] + }, + { + "name": "bar4", + "type": "bar", + "data": [ + 5.95, + 5.86, + 0.92, + -1.2, + -2.73, + -0.32, + 0.12, + -0.55, + 0.78, + 0, + -1.73, + -2.52, + -1.26, + -0.8, + -0.75, + 0, + -3, + 0, + 0.29, + 0.3 + ] + } +] + + diff --git a/samples/source/column/stacked-column-with-line.xml b/samples/source/column/stacked-column-with-line.xml index 0794df8ef..8de817a2e 100644 --- a/samples/source/column/stacked-column-with-line.xml +++ b/samples/source/column/stacked-column-with-line.xml @@ -11,10 +11,10 @@ colors: [ '#d5e2eb' ], chart: { - height: '350', + height: 350, width: '90%', type: 'line', - stacked: 'true', + stacked: true, zoom: { enabled: true, type: 'x' diff --git a/samples/vanilla-js/area/multi-axis-with-seriesname-arrays.html b/samples/vanilla-js/area/multi-axis-with-seriesname-arrays.html new file mode 100644 index 000000000..9ec436d83 --- /dev/null +++ b/samples/vanilla-js/area/multi-axis-with-seriesname-arrays.html @@ -0,0 +1,194 @@ + + + + + + + Multi-YAxis-with-seriesName-arrays + + + + + + + + + + + + + + + + + +
+ + + + + + diff --git a/samples/vanilla-js/boxPlot/boxplot-scatter.html b/samples/vanilla-js/boxPlot/boxplot-scatter.html index bf82ca98b..e6afca287 100644 --- a/samples/vanilla-js/boxPlot/boxplot-scatter.html +++ b/samples/vanilla-js/boxPlot/boxplot-scatter.html @@ -102,10 +102,6 @@ x: new Date('2020-01-01').getTime(), y: 27 }, - { - x: new Date('2020-01-01').getTime(), - y: 78 - }, { x: new Date('2021-01-01').getTime(), y: 15 diff --git a/samples/vanilla-js/column/stacked-column-with-line-new.html b/samples/vanilla-js/column/stacked-column-with-line-new.html new file mode 100644 index 000000000..5cb4fbe4e --- /dev/null +++ b/samples/vanilla-js/column/stacked-column-with-line-new.html @@ -0,0 +1,305 @@ + + + + + + + Stacked Column with line - new config style + + + + + + + + + + + + + + + + + +
+ + + + + + diff --git a/samples/vanilla-js/column/stacked-column-with-line.html b/samples/vanilla-js/column/stacked-column-with-line.html index 8d75be7b5..b8b523268 100644 --- a/samples/vanilla-js/column/stacked-column-with-line.html +++ b/samples/vanilla-js/column/stacked-column-with-line.html @@ -213,10 +213,10 @@ '#d5e2eb' ], chart: { - height: '350', + height: 350, width: '90%', type: 'line', - stacked: 'true', + stacked: true, zoom: { enabled: true, type: 'x' diff --git a/samples/vue/area/multi-axis-with-seriesname-arrays.html b/samples/vue/area/multi-axis-with-seriesname-arrays.html new file mode 100644 index 000000000..9f39d03bc --- /dev/null +++ b/samples/vue/area/multi-axis-with-seriesname-arrays.html @@ -0,0 +1,213 @@ + + + + + + + Multi-YAxis-with-seriesName-arrays + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+ <div id="chart"> + <apexchart type="area" height="350" :options="chartOptions" :series="series"></apexchart> + </div> +
+ + + + + diff --git a/samples/vue/boxPlot/boxplot-scatter.html b/samples/vue/boxPlot/boxplot-scatter.html index 49eff533d..b2951bb1a 100644 --- a/samples/vue/boxPlot/boxplot-scatter.html +++ b/samples/vue/boxPlot/boxplot-scatter.html @@ -121,10 +121,6 @@ x: new Date('2020-01-01').getTime(), y: 27 }, - { - x: new Date('2020-01-01').getTime(), - y: 78 - }, { x: new Date('2021-01-01').getTime(), y: 15 diff --git a/samples/vue/column/stacked-column-with-line-new.html b/samples/vue/column/stacked-column-with-line-new.html new file mode 100644 index 000000000..6b2ffcc81 --- /dev/null +++ b/samples/vue/column/stacked-column-with-line-new.html @@ -0,0 +1,324 @@ + + + + + + + Stacked Column with line - new config style + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+ <div id="chart"> + <apexchart type="line" height="350" :options="chartOptions" :series="series"></apexchart> + </div> +
+ + + + + diff --git a/samples/vue/column/stacked-column-with-line.html b/samples/vue/column/stacked-column-with-line.html index 3e02979e8..ffe23f678 100644 --- a/samples/vue/column/stacked-column-with-line.html +++ b/samples/vue/column/stacked-column-with-line.html @@ -55,14 +55,14 @@
- +
<div id="chart"> - <apexchart type="line" :options="chartOptions" :series="series"></apexchart> + <apexchart type="line" height="350" :options="chartOptions" :series="series"></apexchart> </div>
@@ -233,10 +233,10 @@ '#d5e2eb' ], chart: { - height: '350', + height: 350, width: '90%', type: 'line', - stacked: 'true', + stacked: true, zoom: { enabled: true, type: 'x' diff --git a/src/modules/CoreUtils.js b/src/modules/CoreUtils.js index 187ea1d73..bd89aa474 100644 --- a/src/modules/CoreUtils.js +++ b/src/modules/CoreUtils.js @@ -390,17 +390,17 @@ class CoreUtils { // Some config objects can be array - and we need to extend them correctly static extendArrayProps(configInstance, options, w) { - if (options.yaxis) { + if (options?.yaxis) { options = configInstance.extendYAxis(options, w) } - if (options.annotations) { + if (options?.annotations) { if (options.annotations.yaxis) { options = configInstance.extendYAxisAnnotations(options) } - if (options.annotations.xaxis) { + if (options?.annotations?.xaxis) { options = configInstance.extendXAxisAnnotations(options) } - if (options.annotations.points) { + if (options?.annotations?.points) { options = configInstance.extendPointAnnotations(options) } } diff --git a/src/modules/Range.js b/src/modules/Range.js index 391d549cb..5242d7d78 100644 --- a/src/modules/Range.js +++ b/src/modules/Range.js @@ -309,10 +309,6 @@ class Range { if (gl.isMultipleYAxis) { this.scales.setMultipleYScales() gl.minY = lowestYInAllSeries - gl.yAxisScale.forEach((scale, i) => { - gl.minYArr[i] = scale.niceMin - gl.maxYArr[i] = scale.niceMax - }) } else { this.scales.setYScaleForIndex(0, gl.minY, gl.maxY) gl.minY = gl.yAxisScale[0].niceMin diff --git a/src/modules/Scales.js b/src/modules/Scales.js index 0093af163..e0fdbea61 100644 --- a/src/modules/Scales.js +++ b/src/modules/Scales.js @@ -231,9 +231,15 @@ export default class Scales { // Allow a half-stepSize shift if series doesn't cross the X axis // to ensure graph doesn't clip. Not if it does cross, in order // to keep the 0 aligned with a grid line in multi axis charts. - let shift = stepSize / (yMax - yMin > yMax ? 1 : 2) - yMin = shift * Math.floor(yMin / shift) - yMax = yMin + stepSize * tiks + let shift = stepSize / ((yMax - yMin > yMax) ? 1 : 2) + let tMin = shift * Math.floor(yMin / shift) + if (Math.abs(tMin - yMin) <= shift / 2) { + yMin = tMin + yMax = yMin + stepSize * tiks + } else { + yMax = shift * Math.ceil(yMax / shift) + yMin = yMax - stepSize * tiks + } } else { yMin = stepSize * Math.floor(yMin / stepSize) yMax = stepSize * Math.ceil(yMax / stepSize) @@ -483,13 +489,13 @@ export default class Scales { gl.yAxisScale[index] = [] } - let diff = Math.abs(maxY - minY) + let range = Math.abs(maxY - minY) - if (y.logarithmic && diff <= 5) { + if (y.logarithmic && range <= 5) { gl.invalidLogScale = true } - if (y.logarithmic && diff > 5) { + if (y.logarithmic && range > 5) { gl.allSeriesCollapsed = false gl.yAxisScale[index] = y.forceNiceScale ? this.logarithmicScaleNice(minY, maxY, y.logBase) @@ -539,175 +545,178 @@ export default class Scales { const gl = this.w.globals const cnf = this.w.config - const minYArr = gl.minYArr.concat([]) - const maxYArr = gl.maxYArr.concat([]) + const minYArr = gl.minYArr + const maxYArr = gl.maxYArr - let scalesIndices = [] + let axisSeriesMap = [] + let unassignedSeriesIndices = [] + cnf.series.forEach((s, i) => {unassignedSeriesIndices.push(i)}) + let unassignedYAxisIndices = [] // here, we loop through the yaxis array and find the item which has "seriesName" property - cnf.yaxis.forEach((yaxe, i) => { - let index = i - cnf.series.forEach((s, si) => { - // if seriesName matches and that series is not collapsed, we use that scale - // fix issue #1215 - // proceed even if si is in gl.collapsedSeriesIndices - if (s.name === yaxe.seriesName) { - index = si - - if (i !== si) { - scalesIndices.push({ - index: si, - similarIndex: i, - alreadyExists: true, - }) - } else { - scalesIndices.push({ - index: si, - }) - } + cnf.yaxis.forEach((yaxe, yi) => { + // Allow seriesName to be either a string (for backward compatibility), + // in which case, handle multiple yaxes referencing the same series. + // or an array of strings so that a yaxis can reference multiple series. + // Feature request #4237 + if (yaxe.seriesName) { + let seriesNames = [] + if (Array.isArray(yaxe.seriesName)) { + seriesNames = yaxe.seriesName + } else { + seriesNames.push(yaxe.seriesName) } - }) - - let minY = minYArr[index] - let maxY = maxYArr[index] - - this.setYScaleForIndex(i, minY, maxY) + axisSeriesMap[yi] = [] + seriesNames.forEach((name) => { + cnf.series.forEach((s, si) => { + // if seriesName matches we use that scale. + if (s.name === name) { + axisSeriesMap[yi].push(si) + let remove = unassignedSeriesIndices.indexOf(si) + unassignedSeriesIndices.splice(remove, 1) + } + }) + }) + } else { + unassignedYAxisIndices.push(yi) + } }) - - this.sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) - } - - sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) { - const cnf = this.w.config - const gl = this.w.globals - - // we got the scalesIndices array in the above code, but we need to filter out the items which doesn't have same scales - let similarIndices = [] - scalesIndices.forEach((scale) => { - if (scale.alreadyExists) { - if (typeof similarIndices[scale.index] === 'undefined') { - similarIndices[scale.index] = [] - } - similarIndices[scale.index].push(scale.index) - similarIndices[scale.index].push(scale.similarIndex) + // All series referenced directly by yaxes have been assigned to those axes. + // Any series so far unassigned will be assigned to any yaxes that have yet + // to reference series directly, one-for-one in order of appearance, with + // all left-over series assigned to the last such yaxis. This captures the + // default single and multiaxis config options which simply includes zero, + // one or as many yaxes as there are series but do not reference them by name. + let lastUnassignedYAxis + unassignedYAxisIndices.forEach((yi) => { + lastUnassignedYAxis = yi + axisSeriesMap[yi] = [] + if (unassignedSeriesIndices) { + axisSeriesMap[yi].push([unassignedSeriesIndices[0]]) + unassignedSeriesIndices.shift() } }) - function intersect(a, b) { - return a.filter((value) => b.indexOf(value) !== -1) + if (lastUnassignedYAxis) { + unassignedSeriesIndices.forEach((i) => { + axisSeriesMap[lastUnassignedYAxis].push(i) + }) } - gl.yAxisSameScaleIndices = similarIndices - - similarIndices.forEach((si, i) => { - similarIndices.forEach((sj, j) => { - if (i !== j) { - if (intersect(si, sj).length > 0) { - similarIndices[i] = similarIndices[i].concat(similarIndices[j]) - } - } - }) - }) + this.sameScaleInMultipleAxes(minYArr, maxYArr, axisSeriesMap) + } - // then, we remove duplicates from the similarScale array - let uniqueSimilarIndices = similarIndices.map((item) => { - return item.filter((i, pos) => item.indexOf(i) === pos) - }) + sameScaleInMultipleAxes(minYArr, maxYArr, axisSeriesMap) { + const cnf = this.w.config + const gl = this.w.globals - // sort further to remove whole duplicate arrays later - let sortedIndices = uniqueSimilarIndices.map((s) => s.sort()) - - // remove undefined items - similarIndices = similarIndices.filter((s) => !!s) - - let indices = sortedIndices.slice() - let stringIndices = indices.map((ind) => JSON.stringify(ind)) - indices = indices.filter( - (ind, p) => stringIndices.indexOf(JSON.stringify(ind)) === p - ) - - let sameScaleMinYArr = [] - let sameScaleMaxYArr = [] - minYArr.forEach((minYValue, yi) => { - indices.forEach((scale, i) => { - // we compare only the yIndex which exists in the indices array - if (scale.indexOf(yi) > -1) { - if (typeof sameScaleMinYArr[i] === 'undefined') { - sameScaleMinYArr[i] = [] - sameScaleMaxYArr[i] = [] + // The current config method to map multiple series to a y axis is to + // include one yaxis config per series but set each yaxis seriesName to the + // same series name. This relies on indexing equivalence to map series to + // an axis: series[n] => yaxis[n]. This needs to be retained for compatibility. + // But we introduce an alternative that explicitly configures yaxis elements + // with the series that will be referenced to them (seriesName: []). This + // only requires including the yaxis elements that will be seen on the chart. + // Old way: + // ya: s + // 0: 0 + // 1: 1 + // 2: 1 + // 3: 1 + // 4: 1 + // Axes 0..4 are all scaled and all will be rendered unless the axes are + // show: false. If the chart is stacked, it's assumed that series 1..4 are + // the contributing series. This is not particularly intuitive. + // New way: + // ya: s + // 0: [0] + // 1: [1,2,3,4] + // If the chart is stacked, it can be assumed that any axis with multiple + // series is stacked. + + // First things first, convert the old to the new. + let emptyAxes = [] + axisSeriesMap.forEach((axisSeries, ai) => { + for (let si = ai + 1; si < axisSeriesMap.length; si++) { + let iter = axisSeries.values() + for (const val of iter) { + let i = axisSeriesMap[si].indexOf(val) + if (i !== -1) { + axisSeries.push(si) // add series index to current yaxis + axisSeriesMap[si].splice(i, 1) // remove it from its old yaxis } - sameScaleMinYArr[i].push({ - key: yi, - value: minYValue, - }) - sameScaleMaxYArr[i].push({ - key: yi, - value: maxYArr[yi], - }) } - }) - }) - - let sameScaleMin = Array.apply(null, Array(indices.length)).map( - Number.prototype.valueOf, - Number.MIN_VALUE - ) - let sameScaleMax = Array.apply(null, Array(indices.length)).map( - Number.prototype.valueOf, - -Number.MAX_VALUE - ) - - sameScaleMinYArr.forEach((s, i) => { - s.forEach((sc, j) => { - sameScaleMin[i] = Math.min(sc.value, sameScaleMin[i]) - }) - }) - - sameScaleMaxYArr.forEach((s, i) => { - s.forEach((sc, j) => { - sameScaleMax[i] = Math.max(sc.value, sameScaleMax[i]) - }) - }) - - minYArr.forEach((min, i) => { - sameScaleMaxYArr.forEach((s, si) => { - let minY = sameScaleMin[si] - let maxY = sameScaleMax[si] - - if (cnf.chart.stacked) { - // for stacked charts, we need to add the values - maxY = 0 - - s.forEach((ind, k) => { - // fix incorrectly adjust y scale issue #1215 - if (ind.value !== -Number.MAX_VALUE) { - maxY += ind.value - } - if (minY !== Number.MIN_VALUE) { - minY += sameScaleMinYArr[si][k].value - } - }) + if (axisSeriesMap[si].length < 1 && emptyAxes.indexOf(si) === -1) { + emptyAxes.push(si) } + } + }) + for (let i = emptyAxes.length - 1; i >= 0; i--) { + axisSeriesMap.splice(emptyAxes[i], 1) + } - s.forEach((ind, k) => { - if (s[k].key === i) { - if (cnf.yaxis[i].min !== undefined) { - if (typeof cnf.yaxis[i].min === 'function') { - minY = cnf.yaxis[i].min(gl.minY) - } else { - minY = cnf.yaxis[i].min - } - } - if (cnf.yaxis[i].max !== undefined) { - if (typeof cnf.yaxis[i].max === 'function') { - maxY = cnf.yaxis[i].max(gl.maxY) + // Compute min..max for each yaxis + // + axisSeriesMap.forEach((axisSeries, ai) => { + let minY = Number.MAX_VALUE + let maxY = -Number.MAX_VALUE + if (cnf.chart.stacked) { + let sumSeries = gl.seriesX[axisSeries[0]].map((x) => Number.MIN_VALUE) + let posSeries = gl.seriesX[axisSeries[0]].map((x) => Number.MIN_VALUE) + let negSeries = gl.seriesX[axisSeries[0]].map((x) => Number.MIN_VALUE) + // The first series bound to the axis sets the type for stacked series + let seriesType = cnf.series[axisSeries[0]].type + for (let i = 0; i < axisSeries.length; i++) { + // Sum all series for this yaxis at each corresponding datapoint + // For bar and column charts we need to keep positive and negative + // values separate. + let si = axisSeries[i] + if (gl.collapsedSeriesIndices.indexOf(si) === -1) { + for (let j = 0; j < gl.series[si].length; j++) { + let val = gl.series[si][j] + if (val >= 0) { + posSeries[j] += val } else { - maxY = cnf.yaxis[i].max + negSeries[j] += val } + sumSeries[j] += val } - - this.setYScaleForIndex(i, minY, maxY) } - }) + } + if (seriesType === 'bar') { + minY = Math.min.apply(null, negSeries) + maxY = Math.max.apply(null, posSeries) + } else { + minY = Math.min.apply(null, sumSeries) + maxY = Math.max.apply(null, sumSeries) + } + } else { + for (let i = 0; i < axisSeries.length; i++) { + minY = Math.min(minY, minYArr[axisSeries[i]]) + } + for (let i = 0; i < axisSeries.length; i++) { + maxY = Math.max(maxY, maxYArr[axisSeries[i]]) + } + } + if (cnf.yaxis[ai].min !== undefined) { + if (typeof cnf.yaxis[ai].min === 'function') { + minY = cnf.yaxis[ai].min(minY) + } else { + minY = cnf.yaxis[ai].min + } + } + if (cnf.yaxis[ai].max !== undefined) { + if (typeof cnf.yaxis[ai].max === 'function') { + maxY = cnf.yaxis[ai].max(maxY) + } else { + maxY = cnf.yaxis[ai].max + } + } + // Set the scale for this yaxis + this.setYScaleForIndex(ai, minY, maxY) + // Set individual series min and max to nice values + axisSeries.forEach((si) => { + minYArr[si] = gl.yAxisScale[ai].niceMin + maxYArr[si] = gl.yAxisScale[ai].niceMax }) }) } diff --git a/src/modules/settings/Globals.js b/src/modules/settings/Globals.js index b0d7e276d..fb2b20939 100644 --- a/src/modules/settings/Globals.js +++ b/src/modules/settings/Globals.js @@ -136,7 +136,6 @@ export default class Globals { goldenPadding: 35, // this value is used at a lot of places for spacing purpose invalidLogScale: false, // if a user enabled log scale but the data provided is not valid to generate a log scale, turn on this flag ignoreYAxisIndexes: [], // when series are being collapsed in multiple y axes, ignore certain index - yAxisSameScaleIndices: [], maxValsInArrayIndex: 0, radialSize: 0, selection: undefined, diff --git a/src/modules/tooltip/AxesTooltip.js b/src/modules/tooltip/AxesTooltip.js index 320e7d43e..eb5a88397 100644 --- a/src/modules/tooltip/AxesTooltip.js +++ b/src/modules/tooltip/AxesTooltip.js @@ -74,16 +74,6 @@ class AxesTooltip { ? `apexcharts-yaxistooltip apexcharts-yaxistooltip-${i} apexcharts-yaxistooltip-right` : `apexcharts-yaxistooltip apexcharts-yaxistooltip-${i} apexcharts-yaxistooltip-left` - w.globals.yAxisSameScaleIndices.map((samescales, ssi) => { - samescales.map((s, si) => { - if (si === i) { - tooltipCssClass += w.config.yaxis[si].show - ? ` ` - : ` apexcharts-yaxistooltip-hidden` - } - }) - }) - let renderTo = w.globals.dom.elWrap let yaxisTooltip = w.globals.dom.baseEl.querySelector( diff --git a/tests/e2e/snapshots/area/area-datetime.png b/tests/e2e/snapshots/area/area-datetime.png index 838828af0..14a2cf48c 100644 Binary files a/tests/e2e/snapshots/area/area-datetime.png and b/tests/e2e/snapshots/area/area-datetime.png differ diff --git a/tests/e2e/snapshots/area/area-github-style.png b/tests/e2e/snapshots/area/area-github-style.png index fdc5eda4f..afb40fd57 100644 Binary files a/tests/e2e/snapshots/area/area-github-style.png and b/tests/e2e/snapshots/area/area-github-style.png differ diff --git a/tests/e2e/snapshots/area/area-spline.png b/tests/e2e/snapshots/area/area-spline.png index 0abd9c7d2..9151869bd 100644 Binary files a/tests/e2e/snapshots/area/area-spline.png and b/tests/e2e/snapshots/area/area-spline.png differ diff --git a/tests/e2e/snapshots/area/area-with-missing-data.png b/tests/e2e/snapshots/area/area-with-missing-data.png index 0edeccf21..4b88fc693 100644 Binary files a/tests/e2e/snapshots/area/area-with-missing-data.png and b/tests/e2e/snapshots/area/area-with-missing-data.png differ diff --git a/tests/e2e/snapshots/area/area-with-negative.png b/tests/e2e/snapshots/area/area-with-negative.png index c7586f8bc..fe2efde9a 100644 Binary files a/tests/e2e/snapshots/area/area-with-negative.png and b/tests/e2e/snapshots/area/area-with-negative.png differ diff --git a/tests/e2e/snapshots/area/basic-area.png b/tests/e2e/snapshots/area/basic-area.png index 58249577b..419c28f88 100644 Binary files a/tests/e2e/snapshots/area/basic-area.png and b/tests/e2e/snapshots/area/basic-area.png differ diff --git a/tests/e2e/snapshots/area/multi-axis-with-seriesname-arrays.png b/tests/e2e/snapshots/area/multi-axis-with-seriesname-arrays.png new file mode 100644 index 000000000..d51696af2 Binary files /dev/null and b/tests/e2e/snapshots/area/multi-axis-with-seriesname-arrays.png differ diff --git a/tests/e2e/snapshots/area/stacked-area.png b/tests/e2e/snapshots/area/stacked-area.png index 776908089..75e2c259b 100644 Binary files a/tests/e2e/snapshots/area/stacked-area.png and b/tests/e2e/snapshots/area/stacked-area.png differ diff --git a/tests/e2e/snapshots/area/timeseries-with-irregular-data.png b/tests/e2e/snapshots/area/timeseries-with-irregular-data.png index 03c372698..1ac212524 100644 Binary files a/tests/e2e/snapshots/area/timeseries-with-irregular-data.png and b/tests/e2e/snapshots/area/timeseries-with-irregular-data.png differ diff --git a/tests/e2e/snapshots/bar/bar-with-custom-data-labels.png b/tests/e2e/snapshots/bar/bar-with-custom-data-labels.png index 24a9a370a..73c889135 100644 Binary files a/tests/e2e/snapshots/bar/bar-with-custom-data-labels.png and b/tests/e2e/snapshots/bar/bar-with-custom-data-labels.png differ diff --git a/tests/e2e/snapshots/bar/bar-with-images.png b/tests/e2e/snapshots/bar/bar-with-images.png index 118a3111a..dd5af2eb1 100644 Binary files a/tests/e2e/snapshots/bar/bar-with-images.png and b/tests/e2e/snapshots/bar/bar-with-images.png differ diff --git a/tests/e2e/snapshots/bar/bar-with-markers.png b/tests/e2e/snapshots/bar/bar-with-markers.png index bdeb2ff55..174f1f5db 100644 Binary files a/tests/e2e/snapshots/bar/bar-with-markers.png and b/tests/e2e/snapshots/bar/bar-with-markers.png differ diff --git a/tests/e2e/snapshots/bar/bar-with-negative.png b/tests/e2e/snapshots/bar/bar-with-negative.png index 0ba374a9f..05fecaf6f 100644 Binary files a/tests/e2e/snapshots/bar/bar-with-negative.png and b/tests/e2e/snapshots/bar/bar-with-negative.png differ diff --git a/tests/e2e/snapshots/bar/basic-bar.png b/tests/e2e/snapshots/bar/basic-bar.png index c9fbfdecc..d5711eb51 100644 Binary files a/tests/e2e/snapshots/bar/basic-bar.png and b/tests/e2e/snapshots/bar/basic-bar.png differ diff --git a/tests/e2e/snapshots/bar/grouped-bar.png b/tests/e2e/snapshots/bar/grouped-bar.png index ba1f1f6d3..a3ab2dd4a 100644 Binary files a/tests/e2e/snapshots/bar/grouped-bar.png and b/tests/e2e/snapshots/bar/grouped-bar.png differ diff --git a/tests/e2e/snapshots/bar/grouped-stacked-bar.png b/tests/e2e/snapshots/bar/grouped-stacked-bar.png index bc8c05ef3..361eb1b07 100644 Binary files a/tests/e2e/snapshots/bar/grouped-stacked-bar.png and b/tests/e2e/snapshots/bar/grouped-stacked-bar.png differ diff --git a/tests/e2e/snapshots/bar/patterned-bar.png b/tests/e2e/snapshots/bar/patterned-bar.png index 7aa573d74..b584a0a4c 100644 Binary files a/tests/e2e/snapshots/bar/patterned-bar.png and b/tests/e2e/snapshots/bar/patterned-bar.png differ diff --git a/tests/e2e/snapshots/bar/reversed-bar.png b/tests/e2e/snapshots/bar/reversed-bar.png index 2b435573f..4c6e45dda 100644 Binary files a/tests/e2e/snapshots/bar/reversed-bar.png and b/tests/e2e/snapshots/bar/reversed-bar.png differ diff --git a/tests/e2e/snapshots/bar/stacked-bar-100.png b/tests/e2e/snapshots/bar/stacked-bar-100.png index 31090ba89..797ce2651 100644 Binary files a/tests/e2e/snapshots/bar/stacked-bar-100.png and b/tests/e2e/snapshots/bar/stacked-bar-100.png differ diff --git a/tests/e2e/snapshots/bar/stacked-bar.png b/tests/e2e/snapshots/bar/stacked-bar.png index 5f676a55d..404a5c3f3 100644 Binary files a/tests/e2e/snapshots/bar/stacked-bar.png and b/tests/e2e/snapshots/bar/stacked-bar.png differ diff --git a/tests/e2e/snapshots/boxPlot/basic.png b/tests/e2e/snapshots/boxPlot/basic.png index 5e8d6a5f9..bb7ca44ee 100644 Binary files a/tests/e2e/snapshots/boxPlot/basic.png and b/tests/e2e/snapshots/boxPlot/basic.png differ diff --git a/tests/e2e/snapshots/boxPlot/boxplot-scatter.png b/tests/e2e/snapshots/boxPlot/boxplot-scatter.png index 605c23f73..142b1e3b0 100644 Binary files a/tests/e2e/snapshots/boxPlot/boxplot-scatter.png and b/tests/e2e/snapshots/boxPlot/boxplot-scatter.png differ diff --git a/tests/e2e/snapshots/boxPlot/horizontal-boxplot.png b/tests/e2e/snapshots/boxPlot/horizontal-boxplot.png index 45467994a..5342a4b3d 100644 Binary files a/tests/e2e/snapshots/boxPlot/horizontal-boxplot.png and b/tests/e2e/snapshots/boxPlot/horizontal-boxplot.png differ diff --git a/tests/e2e/snapshots/bubble/3d-bubble.png b/tests/e2e/snapshots/bubble/3d-bubble.png index 36437de67..97b5807d2 100644 Binary files a/tests/e2e/snapshots/bubble/3d-bubble.png and b/tests/e2e/snapshots/bubble/3d-bubble.png differ diff --git a/tests/e2e/snapshots/bubble/simple-bubble.png b/tests/e2e/snapshots/bubble/simple-bubble.png index b0f1d352b..450ec0030 100644 Binary files a/tests/e2e/snapshots/bubble/simple-bubble.png and b/tests/e2e/snapshots/bubble/simple-bubble.png differ diff --git a/tests/e2e/snapshots/candlestick/basic.png b/tests/e2e/snapshots/candlestick/basic.png index 16234f3ac..514036f55 100644 Binary files a/tests/e2e/snapshots/candlestick/basic.png and b/tests/e2e/snapshots/candlestick/basic.png differ diff --git a/tests/e2e/snapshots/candlestick/candlestick-bar.png b/tests/e2e/snapshots/candlestick/candlestick-bar.png index 37829742c..9aa732451 100644 Binary files a/tests/e2e/snapshots/candlestick/candlestick-bar.png and b/tests/e2e/snapshots/candlestick/candlestick-bar.png differ diff --git a/tests/e2e/snapshots/candlestick/candlestick-category.png b/tests/e2e/snapshots/candlestick/candlestick-category.png index e0afb0725..e40981940 100644 Binary files a/tests/e2e/snapshots/candlestick/candlestick-category.png and b/tests/e2e/snapshots/candlestick/candlestick-category.png differ diff --git a/tests/e2e/snapshots/candlestick/candlestick-line.png b/tests/e2e/snapshots/candlestick/candlestick-line.png index 6877e09fc..c3c216e62 100644 Binary files a/tests/e2e/snapshots/candlestick/candlestick-line.png and b/tests/e2e/snapshots/candlestick/candlestick-line.png differ diff --git a/tests/e2e/snapshots/column/basic-column.png b/tests/e2e/snapshots/column/basic-column.png index 54dfed32d..fd07fa0b7 100644 Binary files a/tests/e2e/snapshots/column/basic-column.png and b/tests/e2e/snapshots/column/basic-column.png differ diff --git a/tests/e2e/snapshots/column/column-with-data-labels.png b/tests/e2e/snapshots/column/column-with-data-labels.png index 6a1cb326d..c8fb56391 100644 Binary files a/tests/e2e/snapshots/column/column-with-data-labels.png and b/tests/e2e/snapshots/column/column-with-data-labels.png differ diff --git a/tests/e2e/snapshots/column/column-with-group-label.png b/tests/e2e/snapshots/column/column-with-group-label.png index 445549f5d..f189e77a4 100644 Binary files a/tests/e2e/snapshots/column/column-with-group-label.png and b/tests/e2e/snapshots/column/column-with-group-label.png differ diff --git a/tests/e2e/snapshots/column/column-with-markers.png b/tests/e2e/snapshots/column/column-with-markers.png index 92209b01e..ec5b46eb8 100644 Binary files a/tests/e2e/snapshots/column/column-with-markers.png and b/tests/e2e/snapshots/column/column-with-markers.png differ diff --git a/tests/e2e/snapshots/column/column-with-negative.png b/tests/e2e/snapshots/column/column-with-negative.png index 80caeaf16..dcd6953eb 100644 Binary files a/tests/e2e/snapshots/column/column-with-negative.png and b/tests/e2e/snapshots/column/column-with-negative.png differ diff --git a/tests/e2e/snapshots/column/column-with-rotated-data-labels.png b/tests/e2e/snapshots/column/column-with-rotated-data-labels.png index f1be2c4fb..34604745a 100644 Binary files a/tests/e2e/snapshots/column/column-with-rotated-data-labels.png and b/tests/e2e/snapshots/column/column-with-rotated-data-labels.png differ diff --git a/tests/e2e/snapshots/column/column-with-rotated-labels.png b/tests/e2e/snapshots/column/column-with-rotated-labels.png index c51d1b1b3..aede3c42f 100644 Binary files a/tests/e2e/snapshots/column/column-with-rotated-labels.png and b/tests/e2e/snapshots/column/column-with-rotated-labels.png differ diff --git a/tests/e2e/snapshots/column/data-color.png b/tests/e2e/snapshots/column/data-color.png index 09a438f91..1b705129b 100644 Binary files a/tests/e2e/snapshots/column/data-color.png and b/tests/e2e/snapshots/column/data-color.png differ diff --git a/tests/e2e/snapshots/column/distributed-columns.png b/tests/e2e/snapshots/column/distributed-columns.png new file mode 100644 index 000000000..0934af729 Binary files /dev/null and b/tests/e2e/snapshots/column/distributed-columns.png differ diff --git a/tests/e2e/snapshots/column/dumbbell-chart.png b/tests/e2e/snapshots/column/dumbbell-chart.png new file mode 100644 index 000000000..1060befa5 Binary files /dev/null and b/tests/e2e/snapshots/column/dumbbell-chart.png differ diff --git a/tests/e2e/snapshots/column/dynamic-loaded-chart.png b/tests/e2e/snapshots/column/dynamic-loaded-chart.png new file mode 100644 index 000000000..546708245 Binary files /dev/null and b/tests/e2e/snapshots/column/dynamic-loaded-chart.png differ diff --git a/tests/e2e/snapshots/column/grouped-stacked-column.png b/tests/e2e/snapshots/column/grouped-stacked-column.png new file mode 100644 index 000000000..42c59e12d Binary files /dev/null and b/tests/e2e/snapshots/column/grouped-stacked-column.png differ diff --git a/tests/e2e/snapshots/column/range-column.png b/tests/e2e/snapshots/column/range-column.png index d6f61da4d..db6f2dcf3 100644 Binary files a/tests/e2e/snapshots/column/range-column.png and b/tests/e2e/snapshots/column/range-column.png differ diff --git a/tests/e2e/snapshots/column/stacked-column-100.png b/tests/e2e/snapshots/column/stacked-column-100.png index fff50d359..d5b655c42 100644 Binary files a/tests/e2e/snapshots/column/stacked-column-100.png and b/tests/e2e/snapshots/column/stacked-column-100.png differ diff --git a/tests/e2e/snapshots/column/stacked-column-with-line-new.png b/tests/e2e/snapshots/column/stacked-column-with-line-new.png new file mode 100644 index 000000000..c5f6bcb6c Binary files /dev/null and b/tests/e2e/snapshots/column/stacked-column-with-line-new.png differ diff --git a/tests/e2e/snapshots/column/stacked-column-with-line.png b/tests/e2e/snapshots/column/stacked-column-with-line.png index 8f8c4671f..eabbf0775 100644 Binary files a/tests/e2e/snapshots/column/stacked-column-with-line.png and b/tests/e2e/snapshots/column/stacked-column-with-line.png differ diff --git a/tests/e2e/snapshots/column/stacked-column.png b/tests/e2e/snapshots/column/stacked-column.png index 803a1e2c4..8a5599ea0 100644 Binary files a/tests/e2e/snapshots/column/stacked-column.png and b/tests/e2e/snapshots/column/stacked-column.png differ diff --git a/tests/e2e/snapshots/funnel/funnel.png b/tests/e2e/snapshots/funnel/funnel.png index 89b66ae6b..33d7a46c1 100644 Binary files a/tests/e2e/snapshots/funnel/funnel.png and b/tests/e2e/snapshots/funnel/funnel.png differ diff --git a/tests/e2e/snapshots/funnel/pyramid.png b/tests/e2e/snapshots/funnel/pyramid.png index a659cceae..4ce77f457 100644 Binary files a/tests/e2e/snapshots/funnel/pyramid.png and b/tests/e2e/snapshots/funnel/pyramid.png differ diff --git a/tests/e2e/snapshots/heatmap/basic.png b/tests/e2e/snapshots/heatmap/basic.png index e9588d42e..65942296c 100644 Binary files a/tests/e2e/snapshots/heatmap/basic.png and b/tests/e2e/snapshots/heatmap/basic.png differ diff --git a/tests/e2e/snapshots/heatmap/color-range.png b/tests/e2e/snapshots/heatmap/color-range.png index c0e707253..fc01ccbb2 100644 Binary files a/tests/e2e/snapshots/heatmap/color-range.png and b/tests/e2e/snapshots/heatmap/color-range.png differ diff --git a/tests/e2e/snapshots/heatmap/image-fill.png b/tests/e2e/snapshots/heatmap/image-fill.png index 371fbc546..b67f20a56 100644 Binary files a/tests/e2e/snapshots/heatmap/image-fill.png and b/tests/e2e/snapshots/heatmap/image-fill.png differ diff --git a/tests/e2e/snapshots/heatmap/multiple-color-scales-flipped.png b/tests/e2e/snapshots/heatmap/multiple-color-scales-flipped.png index 8402f6034..3be08d189 100644 Binary files a/tests/e2e/snapshots/heatmap/multiple-color-scales-flipped.png and b/tests/e2e/snapshots/heatmap/multiple-color-scales-flipped.png differ diff --git a/tests/e2e/snapshots/heatmap/multiple-color.png b/tests/e2e/snapshots/heatmap/multiple-color.png index 85f13321c..a1d4babbc 100644 Binary files a/tests/e2e/snapshots/heatmap/multiple-color.png and b/tests/e2e/snapshots/heatmap/multiple-color.png differ diff --git a/tests/e2e/snapshots/heatmap/rounded.png b/tests/e2e/snapshots/heatmap/rounded.png index 217416ba1..da236e1b9 100644 Binary files a/tests/e2e/snapshots/heatmap/rounded.png and b/tests/e2e/snapshots/heatmap/rounded.png differ diff --git a/tests/e2e/snapshots/line/basic-line.png b/tests/e2e/snapshots/line/basic-line.png index 1868cb592..366bccfda 100644 Binary files a/tests/e2e/snapshots/line/basic-line.png and b/tests/e2e/snapshots/line/basic-line.png differ diff --git a/tests/e2e/snapshots/line/brush-charts.png b/tests/e2e/snapshots/line/brush-charts.png index 55e68b1f0..b8c114ddc 100644 Binary files a/tests/e2e/snapshots/line/brush-charts.png and b/tests/e2e/snapshots/line/brush-charts.png differ diff --git a/tests/e2e/snapshots/line/dashed-line.png b/tests/e2e/snapshots/line/dashed-line.png index 387bb9d7f..73d11868b 100644 Binary files a/tests/e2e/snapshots/line/dashed-line.png and b/tests/e2e/snapshots/line/dashed-line.png differ diff --git a/tests/e2e/snapshots/line/gradient-line.png b/tests/e2e/snapshots/line/gradient-line.png index d515194ce..573a84890 100644 Binary files a/tests/e2e/snapshots/line/gradient-line.png and b/tests/e2e/snapshots/line/gradient-line.png differ diff --git a/tests/e2e/snapshots/line/line-with-annotations.png b/tests/e2e/snapshots/line/line-with-annotations.png index 1edc472a8..1899ff15d 100644 Binary files a/tests/e2e/snapshots/line/line-with-annotations.png and b/tests/e2e/snapshots/line/line-with-annotations.png differ diff --git a/tests/e2e/snapshots/line/line-with-data-labels.png b/tests/e2e/snapshots/line/line-with-data-labels.png index 1b356b333..7e1613eb3 100644 Binary files a/tests/e2e/snapshots/line/line-with-data-labels.png and b/tests/e2e/snapshots/line/line-with-data-labels.png differ diff --git a/tests/e2e/snapshots/line/line-with-image.png b/tests/e2e/snapshots/line/line-with-image.png index 4124106e6..3b74af54e 100644 Binary files a/tests/e2e/snapshots/line/line-with-image.png and b/tests/e2e/snapshots/line/line-with-image.png differ diff --git a/tests/e2e/snapshots/line/line-with-missing-data.png b/tests/e2e/snapshots/line/line-with-missing-data.png index 37dd15b36..ce3c2af7b 100644 Binary files a/tests/e2e/snapshots/line/line-with-missing-data.png and b/tests/e2e/snapshots/line/line-with-missing-data.png differ diff --git a/tests/e2e/snapshots/line/logarithmic-line.png b/tests/e2e/snapshots/line/logarithmic-line.png index bc655345b..f2d19bd08 100644 Binary files a/tests/e2e/snapshots/line/logarithmic-line.png and b/tests/e2e/snapshots/line/logarithmic-line.png differ diff --git a/tests/e2e/snapshots/line/realtime.png b/tests/e2e/snapshots/line/realtime.png index bfa75db88..6cdd56c3c 100644 Binary files a/tests/e2e/snapshots/line/realtime.png and b/tests/e2e/snapshots/line/realtime.png differ diff --git a/tests/e2e/snapshots/line/stepline.png b/tests/e2e/snapshots/line/stepline.png index 12fd229a8..0507ef269 100644 Binary files a/tests/e2e/snapshots/line/stepline.png and b/tests/e2e/snapshots/line/stepline.png differ diff --git a/tests/e2e/snapshots/line/syncing-charts.png b/tests/e2e/snapshots/line/syncing-charts.png index 8975211a9..ca6aedadf 100644 Binary files a/tests/e2e/snapshots/line/syncing-charts.png and b/tests/e2e/snapshots/line/syncing-charts.png differ diff --git a/tests/e2e/snapshots/line/zoomable-timeseries.png b/tests/e2e/snapshots/line/zoomable-timeseries.png index 6a9e49fff..b2cdd94a5 100644 Binary files a/tests/e2e/snapshots/line/zoomable-timeseries.png and b/tests/e2e/snapshots/line/zoomable-timeseries.png differ diff --git a/tests/e2e/snapshots/misc/annotations-example.png b/tests/e2e/snapshots/misc/annotations-example.png index ed12ce32d..3762cad81 100644 Binary files a/tests/e2e/snapshots/misc/annotations-example.png and b/tests/e2e/snapshots/misc/annotations-example.png differ diff --git a/tests/e2e/snapshots/misc/axios.png b/tests/e2e/snapshots/misc/axios.png index 374305827..00fa17cca 100644 Binary files a/tests/e2e/snapshots/misc/axios.png and b/tests/e2e/snapshots/misc/axios.png differ diff --git a/tests/e2e/snapshots/misc/custom-legend.png b/tests/e2e/snapshots/misc/custom-legend.png index 4b00b57df..7d765c567 100644 Binary files a/tests/e2e/snapshots/misc/custom-legend.png and b/tests/e2e/snapshots/misc/custom-legend.png differ diff --git a/tests/e2e/snapshots/misc/jquery.png b/tests/e2e/snapshots/misc/jquery.png index 374305827..00fa17cca 100644 Binary files a/tests/e2e/snapshots/misc/jquery.png and b/tests/e2e/snapshots/misc/jquery.png differ diff --git a/tests/e2e/snapshots/misc/minMaxPoints.png b/tests/e2e/snapshots/misc/minMaxPoints.png index 58fb4afc7..4318ad996 100644 Binary files a/tests/e2e/snapshots/misc/minMaxPoints.png and b/tests/e2e/snapshots/misc/minMaxPoints.png differ diff --git a/tests/e2e/snapshots/misc/range-annotations-inverted-axis-example.png b/tests/e2e/snapshots/misc/range-annotations-inverted-axis-example.png index fd027c06d..8f7c4c308 100644 Binary files a/tests/e2e/snapshots/misc/range-annotations-inverted-axis-example.png and b/tests/e2e/snapshots/misc/range-annotations-inverted-axis-example.png differ diff --git a/tests/e2e/snapshots/mixed/duplicate-labels.png b/tests/e2e/snapshots/mixed/duplicate-labels.png index 9644d4292..2f1cd2d46 100644 Binary files a/tests/e2e/snapshots/mixed/duplicate-labels.png and b/tests/e2e/snapshots/mixed/duplicate-labels.png differ diff --git a/tests/e2e/snapshots/mixed/line-area.png b/tests/e2e/snapshots/mixed/line-area.png index 60789ebc3..520b0e07f 100644 Binary files a/tests/e2e/snapshots/mixed/line-area.png and b/tests/e2e/snapshots/mixed/line-area.png differ diff --git a/tests/e2e/snapshots/mixed/line-column-area.png b/tests/e2e/snapshots/mixed/line-column-area.png index 409aee65e..133f2f507 100644 Binary files a/tests/e2e/snapshots/mixed/line-column-area.png and b/tests/e2e/snapshots/mixed/line-column-area.png differ diff --git a/tests/e2e/snapshots/mixed/line-column.png b/tests/e2e/snapshots/mixed/line-column.png index 28b5b9d1e..da6efdb12 100644 Binary files a/tests/e2e/snapshots/mixed/line-column.png and b/tests/e2e/snapshots/mixed/line-column.png differ diff --git a/tests/e2e/snapshots/mixed/line-scatter.png b/tests/e2e/snapshots/mixed/line-scatter.png index 7a2b57362..54649b1bc 100644 Binary files a/tests/e2e/snapshots/mixed/line-scatter.png and b/tests/e2e/snapshots/mixed/line-scatter.png differ diff --git a/tests/e2e/snapshots/mixed/multiple-yaxes.png b/tests/e2e/snapshots/mixed/multiple-yaxes.png index 4d2291c4d..7db84b3ac 100644 Binary files a/tests/e2e/snapshots/mixed/multiple-yaxes.png and b/tests/e2e/snapshots/mixed/multiple-yaxes.png differ diff --git a/tests/e2e/snapshots/pie/donut-update.png b/tests/e2e/snapshots/pie/donut-update.png index afd806651..b725406f2 100644 Binary files a/tests/e2e/snapshots/pie/donut-update.png and b/tests/e2e/snapshots/pie/donut-update.png differ diff --git a/tests/e2e/snapshots/pie/donut-with-pattern.png b/tests/e2e/snapshots/pie/donut-with-pattern.png index ca442a1da..72b17abce 100644 Binary files a/tests/e2e/snapshots/pie/donut-with-pattern.png and b/tests/e2e/snapshots/pie/donut-with-pattern.png differ diff --git a/tests/e2e/snapshots/pie/gradient-donut.png b/tests/e2e/snapshots/pie/gradient-donut.png index af09a5795..2bdb02200 100644 Binary files a/tests/e2e/snapshots/pie/gradient-donut.png and b/tests/e2e/snapshots/pie/gradient-donut.png differ diff --git a/tests/e2e/snapshots/pie/monochrome-pie.png b/tests/e2e/snapshots/pie/monochrome-pie.png index 317df1aad..c75766fd3 100644 Binary files a/tests/e2e/snapshots/pie/monochrome-pie.png and b/tests/e2e/snapshots/pie/monochrome-pie.png differ diff --git a/tests/e2e/snapshots/pie/pie-with-image.png b/tests/e2e/snapshots/pie/pie-with-image.png index 0daddb148..a6ba27c25 100644 Binary files a/tests/e2e/snapshots/pie/pie-with-image.png and b/tests/e2e/snapshots/pie/pie-with-image.png differ diff --git a/tests/e2e/snapshots/pie/semi-donut.png b/tests/e2e/snapshots/pie/semi-donut.png index fbe8189f9..12a2fe4bb 100644 Binary files a/tests/e2e/snapshots/pie/semi-donut.png and b/tests/e2e/snapshots/pie/semi-donut.png differ diff --git a/tests/e2e/snapshots/pie/simple-donut.png b/tests/e2e/snapshots/pie/simple-donut.png index 90250126e..8a9b49bd9 100644 Binary files a/tests/e2e/snapshots/pie/simple-donut.png and b/tests/e2e/snapshots/pie/simple-donut.png differ diff --git a/tests/e2e/snapshots/pie/simple-pie.png b/tests/e2e/snapshots/pie/simple-pie.png index e089cddc2..373044ef4 100644 Binary files a/tests/e2e/snapshots/pie/simple-pie.png and b/tests/e2e/snapshots/pie/simple-pie.png differ diff --git a/tests/e2e/snapshots/polarArea/basic-polar-area.png b/tests/e2e/snapshots/polarArea/basic-polar-area.png index 0ec2d5a6d..9bbe58d69 100644 Binary files a/tests/e2e/snapshots/polarArea/basic-polar-area.png and b/tests/e2e/snapshots/polarArea/basic-polar-area.png differ diff --git a/tests/e2e/snapshots/polarArea/polar-area-monochrome.png b/tests/e2e/snapshots/polarArea/polar-area-monochrome.png index 767d82d64..d0008ce52 100644 Binary files a/tests/e2e/snapshots/polarArea/polar-area-monochrome.png and b/tests/e2e/snapshots/polarArea/polar-area-monochrome.png differ diff --git a/tests/e2e/snapshots/radar/basic-radar.png b/tests/e2e/snapshots/radar/basic-radar.png index 2a661e59e..a6c79e534 100644 Binary files a/tests/e2e/snapshots/radar/basic-radar.png and b/tests/e2e/snapshots/radar/basic-radar.png differ diff --git a/tests/e2e/snapshots/radar/radar-multiple-series.png b/tests/e2e/snapshots/radar/radar-multiple-series.png index 50efbea65..390aff01f 100644 Binary files a/tests/e2e/snapshots/radar/radar-multiple-series.png and b/tests/e2e/snapshots/radar/radar-multiple-series.png differ diff --git a/tests/e2e/snapshots/radar/radar-with-polygon-fill.png b/tests/e2e/snapshots/radar/radar-with-polygon-fill.png index 2a6d88e13..c50b1a1d7 100644 Binary files a/tests/e2e/snapshots/radar/radar-with-polygon-fill.png and b/tests/e2e/snapshots/radar/radar-with-polygon-fill.png differ diff --git a/tests/e2e/snapshots/radialBar/circle-chart-multiple.png b/tests/e2e/snapshots/radialBar/circle-chart-multiple.png index fbc1a7b2f..901900cd0 100644 Binary files a/tests/e2e/snapshots/radialBar/circle-chart-multiple.png and b/tests/e2e/snapshots/radialBar/circle-chart-multiple.png differ diff --git a/tests/e2e/snapshots/radialBar/circle-chart-with-image.png b/tests/e2e/snapshots/radialBar/circle-chart-with-image.png index b738343a4..ee449ac5f 100644 Binary files a/tests/e2e/snapshots/radialBar/circle-chart-with-image.png and b/tests/e2e/snapshots/radialBar/circle-chart-with-image.png differ diff --git a/tests/e2e/snapshots/radialBar/circle-chart.png b/tests/e2e/snapshots/radialBar/circle-chart.png index 95fea3ded..14d87d7a8 100644 Binary files a/tests/e2e/snapshots/radialBar/circle-chart.png and b/tests/e2e/snapshots/radialBar/circle-chart.png differ diff --git a/tests/e2e/snapshots/radialBar/circle-custom-angle.png b/tests/e2e/snapshots/radialBar/circle-custom-angle.png index 1657afd83..f85a4c33a 100644 Binary files a/tests/e2e/snapshots/radialBar/circle-custom-angle.png and b/tests/e2e/snapshots/radialBar/circle-custom-angle.png differ diff --git a/tests/e2e/snapshots/radialBar/circle-gradient.png b/tests/e2e/snapshots/radialBar/circle-gradient.png index a72e8ffe8..e5f4dc823 100644 Binary files a/tests/e2e/snapshots/radialBar/circle-gradient.png and b/tests/e2e/snapshots/radialBar/circle-gradient.png differ diff --git a/tests/e2e/snapshots/radialBar/semi-circle-chart.png b/tests/e2e/snapshots/radialBar/semi-circle-chart.png index 5cf09b827..7ac68f03c 100644 Binary files a/tests/e2e/snapshots/radialBar/semi-circle-chart.png and b/tests/e2e/snapshots/radialBar/semi-circle-chart.png differ diff --git a/tests/e2e/snapshots/radialBar/stroked-gauge.png b/tests/e2e/snapshots/radialBar/stroked-gauge.png index 1326a9861..54071d8fa 100644 Binary files a/tests/e2e/snapshots/radialBar/stroked-gauge.png and b/tests/e2e/snapshots/radialBar/stroked-gauge.png differ diff --git a/tests/e2e/snapshots/rangeArea/basic-range-area.png b/tests/e2e/snapshots/rangeArea/basic-range-area.png index c83aaa9c7..1c0ef3ebc 100644 Binary files a/tests/e2e/snapshots/rangeArea/basic-range-area.png and b/tests/e2e/snapshots/rangeArea/basic-range-area.png differ diff --git a/tests/e2e/snapshots/rangeArea/range-area-line-combo.png b/tests/e2e/snapshots/rangeArea/range-area-line-combo.png index 6bd2fe32b..37e865cc0 100644 Binary files a/tests/e2e/snapshots/rangeArea/range-area-line-combo.png and b/tests/e2e/snapshots/rangeArea/range-area-line-combo.png differ diff --git a/tests/e2e/snapshots/scatter/scatter-basic.png b/tests/e2e/snapshots/scatter/scatter-basic.png index 6e5114630..1c997cae3 100644 Binary files a/tests/e2e/snapshots/scatter/scatter-basic.png and b/tests/e2e/snapshots/scatter/scatter-basic.png differ diff --git a/tests/e2e/snapshots/scatter/scatter-datetime.png b/tests/e2e/snapshots/scatter/scatter-datetime.png index e96354ed9..6745a4b7d 100644 Binary files a/tests/e2e/snapshots/scatter/scatter-datetime.png and b/tests/e2e/snapshots/scatter/scatter-datetime.png differ diff --git a/tests/e2e/snapshots/scatter/scatter-images.png b/tests/e2e/snapshots/scatter/scatter-images.png index 707447721..cc3e07747 100644 Binary files a/tests/e2e/snapshots/scatter/scatter-images.png and b/tests/e2e/snapshots/scatter/scatter-images.png differ diff --git a/tests/e2e/snapshots/sparklines/sparklines.png b/tests/e2e/snapshots/sparklines/sparklines.png index cb5fbc7eb..ae4fb038e 100644 Binary files a/tests/e2e/snapshots/sparklines/sparklines.png and b/tests/e2e/snapshots/sparklines/sparklines.png differ diff --git a/tests/e2e/snapshots/timelines/advanced.png b/tests/e2e/snapshots/timelines/advanced.png index ba57dc544..10161b7d7 100644 Binary files a/tests/e2e/snapshots/timelines/advanced.png and b/tests/e2e/snapshots/timelines/advanced.png differ diff --git a/tests/e2e/snapshots/timelines/brush-rangebars.png b/tests/e2e/snapshots/timelines/brush-rangebars.png index 52a122d25..79540c52f 100644 Binary files a/tests/e2e/snapshots/timelines/brush-rangebars.png and b/tests/e2e/snapshots/timelines/brush-rangebars.png differ diff --git a/tests/e2e/snapshots/timelines/controlling-colors.png b/tests/e2e/snapshots/timelines/controlling-colors.png index 9428aad4c..8964c6e09 100644 Binary files a/tests/e2e/snapshots/timelines/controlling-colors.png and b/tests/e2e/snapshots/timelines/controlling-colors.png differ diff --git a/tests/e2e/snapshots/timelines/dumbbell-chart-horizontal.png b/tests/e2e/snapshots/timelines/dumbbell-chart-horizontal.png index c29fbca0d..1f571df7b 100644 Binary files a/tests/e2e/snapshots/timelines/dumbbell-chart-horizontal.png and b/tests/e2e/snapshots/timelines/dumbbell-chart-horizontal.png differ diff --git a/tests/e2e/snapshots/timelines/multi-series-group-rows.png b/tests/e2e/snapshots/timelines/multi-series-group-rows.png index 6bf6b5669..170d2527f 100644 Binary files a/tests/e2e/snapshots/timelines/multi-series-group-rows.png and b/tests/e2e/snapshots/timelines/multi-series-group-rows.png differ diff --git a/tests/e2e/snapshots/timelines/multi-series.png b/tests/e2e/snapshots/timelines/multi-series.png index 191d9a1f8..0dc005679 100644 Binary files a/tests/e2e/snapshots/timelines/multi-series.png and b/tests/e2e/snapshots/timelines/multi-series.png differ diff --git a/tests/e2e/snapshots/timelines/simple.png b/tests/e2e/snapshots/timelines/simple.png index 1d96b4e28..e2d4ef1d6 100644 Binary files a/tests/e2e/snapshots/timelines/simple.png and b/tests/e2e/snapshots/timelines/simple.png differ diff --git a/tests/e2e/snapshots/treemap/basic.png b/tests/e2e/snapshots/treemap/basic.png index 3e0bca8d9..8f3decd5b 100644 Binary files a/tests/e2e/snapshots/treemap/basic.png and b/tests/e2e/snapshots/treemap/basic.png differ diff --git a/tests/e2e/snapshots/treemap/color-scale.png b/tests/e2e/snapshots/treemap/color-scale.png index d08ff0712..460c0ccf6 100644 Binary files a/tests/e2e/snapshots/treemap/color-scale.png and b/tests/e2e/snapshots/treemap/color-scale.png differ diff --git a/tests/e2e/snapshots/treemap/distributed.png b/tests/e2e/snapshots/treemap/distributed.png index 517e08bca..a820abacc 100644 Binary files a/tests/e2e/snapshots/treemap/distributed.png and b/tests/e2e/snapshots/treemap/distributed.png differ diff --git a/tests/e2e/snapshots/treemap/multi-dimensional.png b/tests/e2e/snapshots/treemap/multi-dimensional.png index 9070d27f8..4b74fb56f 100644 Binary files a/tests/e2e/snapshots/treemap/multi-dimensional.png and b/tests/e2e/snapshots/treemap/multi-dimensional.png differ diff --git a/tests/unit/multiple-scales.spec.js b/tests/unit/multiple-scales.spec.js index 61652f910..bbf189302 100644 --- a/tests/unit/multiple-scales.spec.js +++ b/tests/unit/multiple-scales.spec.js @@ -118,4 +118,264 @@ describe('Multiple Y-axis Scales', () => { } ]) }) + + it('should associate multiple series to multiple yaxes according to seriesName array spec', () => { + const chart = createChartWithOptions({ + chart: { + type: 'line' + }, + series: [ + { + name: 'Series A', + data: logData + }, + { + name: 'Series B', + data: logData + }, + { + name: 'Series C', + data: logData + }, + { + name: 'Series D', + data: logData + } + ], + yaxis: [ + { + seriesName: ['Series A','Series B'], + min: 1000000, + max: 500000000, + tickAmount: 5, + }, + { + seriesName: ['Series C','Series D'], + min: 1000000, + max: 500000000, + opposite: true + } + ] + }) + + const minYArr = chart.w.globals.minYArr + const maxYArr = chart.w.globals.maxYArr + const yAxisScale = chart.w.globals.yAxisScale + + expect(minYArr).toEqual([1000000, 1000000, 1000000, 1000000]) + + expect(maxYArr).toEqual([500000000, 500000000, 500000000, 500000000]) + + expect(yAxisScale).toEqual([ + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000,100800000,200600000,300400000,400200000,500000000,] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + } + ]) + }) + + it('should associate series to yaxes according to seriesName then assign remainder to last free axis', () => { + const chart = createChartWithOptions({ + chart: { + type: 'line' + }, + series: [ + { + name: 'Series A', + data: logData + }, + { + name: 'Series B', + data: logData + }, + { + name: 'Series C', + data: logData + }, + { + name: 'Series D', + data: logData + } + ], + yaxis: [ + { + seriesName: ['Series A','Series B'], + min: 1000000, + max: 500000000, + tickAmount: 5, + }, + { + min: 1000000, + max: 500000000, + opposite: true + } + ] + }) + + const minYArr = chart.w.globals.minYArr + const maxYArr = chart.w.globals.maxYArr + const yAxisScale = chart.w.globals.yAxisScale + + expect(minYArr).toEqual([1000000, 1000000, 1000000, 1000000]) + + expect(maxYArr).toEqual([500000000, 500000000, 500000000, 500000000]) + + expect(yAxisScale).toEqual([ + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000,100800000,200600000,300400000,400200000,500000000,] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + } + ]) + }) + + it('should associate series to yaxes according to seriesName then assign remainder one-for-one', () => { + const chart = createChartWithOptions({ + chart: { + type: 'line' + }, + series: [ + { + name: 'Series A', + data: logData + }, + { + name: 'Series B', + data: logData + }, + { + name: 'Series C', + data: logData + }, + { + name: 'Series D', + data: logData + } + ], + yaxis: [ + { + seriesName: ['Series A','Series B'], + min: 1000000, + max: 500000000, + tickAmount: 5, + }, + { + min: 1000000, + max: 500000000, + opposite: true + }, + { + min: 1000000, + max: 500000000, + opposite: true + } + ] + }) + + const minYArr = chart.w.globals.minYArr + const maxYArr = chart.w.globals.maxYArr + const yAxisScale = chart.w.globals.yAxisScale + + expect(minYArr).toEqual([1000000, 1000000, 1000000, 1000000]) + + expect(maxYArr).toEqual([500000000, 500000000, 500000000, 500000000]) + + expect(yAxisScale).toEqual([ + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000,100800000,200600000,300400000,400200000,500000000,] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + } + ]) + }) + + it('should associate series to yaxes according to seriesName before assigning remainder one-for-one', () => { + const chart = createChartWithOptions({ + chart: { + type: 'line' + }, + series: [ + { + name: 'Series A', + data: logData + }, + { + name: 'Series B', + data: logData + }, + { + name: 'Series C', + data: logData + }, + { + name: 'Series D', + data: logData + } + ], + yaxis: [ + { + min: 1000000, + max: 500000000, + tickAmount: 5 + }, + { + seriesName: ['Series A','Series B'], + min: 1000000, + max: 500000000 + }, + { + min: 1000000, + max: 500000000, + opposite: true + } + ] + }) + + const minYArr = chart.w.globals.minYArr + const maxYArr = chart.w.globals.maxYArr + const yAxisScale = chart.w.globals.yAxisScale + + expect(minYArr).toEqual([1000000, 1000000, 1000000, 1000000]) + + expect(maxYArr).toEqual([500000000, 500000000, 500000000, 500000000]) + + expect(yAxisScale).toEqual([ + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000,100800000,200600000,300400000,400200000,500000000,] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + }, + { + niceMax: 500000000, + niceMin: 1000000, + result: [1000000, 100800000, 200600000, 300400000, 400200000, 500000000] + } + ]) + }) })