|
230 | 230 | <line |
231 | 231 | data-cy="axis-x-tick" |
232 | 232 | v-if="FINAL_CONFIG.chart.grid.labels.xAxis.showCrosshairs" |
233 | | - :y1="drawingArea.bottom" |
234 | | - :y2="drawingArea.bottom + FINAL_CONFIG.chart.grid.labels.xAxis.crosshairSize" |
| 233 | + :y1="FINAL_CONFIG.chart.grid.labels.xAxis.crosshairsAlwaysAtZero ? zero - (zero === drawingArea.bottom ? 0 : FINAL_CONFIG.chart.grid.labels.xAxis.crosshairSize / 2) : drawingArea.bottom" |
| 234 | + :y2="FINAL_CONFIG.chart.grid.labels.xAxis.crosshairsAlwaysAtZero ? zero + (FINAL_CONFIG.chart.grid.labels.xAxis.crosshairSize / (zero === drawingArea.bottom ? 1 : 2)) : drawingArea.bottom + FINAL_CONFIG.chart.grid.labels.xAxis.crosshairSize" |
235 | 235 | :x1="drawingArea.left + (drawingArea.width / maxSeries) * i + (drawingArea.width / maxSeries / 2)" |
236 | 236 | :x2="drawingArea.left + (drawingArea.width / maxSeries) * i + (drawingArea.width / maxSeries / 2)" |
237 | 237 | :stroke="FINAL_CONFIG.chart.grid.stroke" |
238 | 238 | :stroke-width="1" |
239 | 239 | stroke-linecap="round" |
240 | | - :style="{ animation: 'none !important '}" |
| 240 | + :style="{ animation: 'none !important'}" |
241 | 241 | /> |
242 | 242 | </template> |
243 | 243 | </g> |
@@ -2138,7 +2138,15 @@ export default { |
2138 | 2138 | return result; |
2139 | 2139 | }, |
2140 | 2140 | barSet() { |
2141 | | - return this.activeSeriesWithStackRatios.filter(s => s.type === 'bar').map((datapoint, i) => { |
| 2141 | + const stackSeries = this.activeSeriesWithStackRatios |
| 2142 | + .filter(s => ['bar','line','plot'].includes(s.type)); |
| 2143 | + const totalSeries = stackSeries.length; |
| 2144 | + const gap = this.FINAL_CONFIG.chart.grid.labels.yAxis.gap; |
| 2145 | + const stacked = this.mutableConfig.isStacked; |
| 2146 | + const totalGap = stacked ? gap * (totalSeries - 1) : 0 |
| 2147 | + const usableHeight = this.drawingArea.height - totalGap; |
| 2148 | +
|
| 2149 | + return stackSeries.filter(s => s.type === 'bar').map((datapoint, i) => { |
2142 | 2150 | this.checkAutoScaleError(datapoint); |
2143 | 2151 | const min = this.scaleGroups[datapoint.scaleLabel].min; |
2144 | 2152 | const max = this.scaleGroups[datapoint.scaleLabel].max; |
@@ -2170,9 +2178,11 @@ export default { |
2170 | 2178 | const individualMax = individualScale.max + individualZero; |
2171 | 2179 | const autoScaleMax = autoScaleSteps.max + Math.abs(autoScaleZero); |
2172 | 2180 |
|
2173 | | - const yOffset = this.mutableConfig.isStacked ? (this.drawingArea.height * (1 - datapoint.cumulatedStackRatio)) : 0; |
2174 | | -
|
2175 | | - const individualHeight = this.mutableConfig.isStacked ? (this.drawingArea.height * datapoint.stackRatio) - this.FINAL_CONFIG.chart.grid.labels.yAxis.gap : this.drawingArea.height; |
| 2181 | + const origIdx = datapoint.stackIndex; |
| 2182 | + const flippedIdx = totalSeries - 1 - origIdx; |
| 2183 | + const flippedLowerRatio = stacked ? 1 - datapoint.cumulatedStackRatio : 0; |
| 2184 | + const yOffset = stacked ? usableHeight * flippedLowerRatio + gap * flippedIdx : 0; |
| 2185 | + const individualHeight = stacked ? usableHeight * datapoint.stackRatio : this.drawingArea.height; |
2176 | 2186 |
|
2177 | 2187 | const zeroPosition = this.drawingArea.bottom - yOffset - ((individualHeight) * individualZero / individualMax); |
2178 | 2188 | const autoScaleZeroPosition = this.drawingArea.bottom - yOffset - (individualHeight * autoScaleZero / autoScaleMax); |
@@ -2276,7 +2286,15 @@ export default { |
2276 | 2286 | }) |
2277 | 2287 | }, |
2278 | 2288 | lineSet() { |
2279 | | - return this.activeSeriesWithStackRatios.filter(s => s.type === 'line').map((datapoint) => { |
| 2289 | + const stackSeries = this.activeSeriesWithStackRatios |
| 2290 | + .filter(s => ['bar','line','plot'].includes(s.type)); |
| 2291 | + const totalSeries = stackSeries.length; |
| 2292 | + const gap = this.FINAL_CONFIG.chart.grid.labels.yAxis.gap; |
| 2293 | + const stacked = this.mutableConfig.isStacked; |
| 2294 | + const totalGap = stacked ? gap * (totalSeries - 1) : 0 |
| 2295 | + const usableHeight = this.drawingArea.height - totalGap; |
| 2296 | +
|
| 2297 | + return stackSeries.filter(s => s.type === 'line').map((datapoint, i) => { |
2280 | 2298 | this.checkAutoScaleError(datapoint); |
2281 | 2299 |
|
2282 | 2300 | const min = this.scaleGroups[datapoint.scaleLabel].min; |
@@ -2309,9 +2327,11 @@ export default { |
2309 | 2327 | const individualMax = individualScale.max + Math.abs(individualZero); |
2310 | 2328 | const autoScaleMax = autoScaleSteps.max + Math.abs(autoScaleZero); |
2311 | 2329 |
|
2312 | | - const yOffset = this.mutableConfig.isStacked ? (this.drawingArea.height * (1 - datapoint.cumulatedStackRatio)) : 0; |
2313 | | -
|
2314 | | - const individualHeight = this.mutableConfig.isStacked ? (this.drawingArea.height * datapoint.stackRatio) - this.FINAL_CONFIG.chart.grid.labels.yAxis.gap : this.drawingArea.height; |
| 2330 | + const origIdx = datapoint.stackIndex; |
| 2331 | + const flippedIdx = totalSeries - 1 - origIdx; |
| 2332 | + const flippedLowerRatio = stacked ? 1 - datapoint.cumulatedStackRatio : 0; |
| 2333 | + const yOffset = stacked ? usableHeight * flippedLowerRatio + gap * flippedIdx : 0; |
| 2334 | + const individualHeight = stacked ? usableHeight * datapoint.stackRatio : this.drawingArea.height; |
2315 | 2335 | |
2316 | 2336 | const zeroPosition = this.drawingArea.bottom - yOffset - ((individualHeight) * individualZero / individualMax); |
2317 | 2337 |
|
@@ -2453,7 +2473,14 @@ export default { |
2453 | 2473 | }); |
2454 | 2474 | }, |
2455 | 2475 | plotSet() { |
2456 | | - return this.activeSeriesWithStackRatios.filter(s => s.type === 'plot').map((datapoint) => { |
| 2476 | + const stackSeries = this.activeSeriesWithStackRatios.filter(s => ['bar','line','plot'].includes(s.type)); |
| 2477 | + const totalSeries = stackSeries.length; |
| 2478 | + const gap = this.FINAL_CONFIG.chart.grid.labels.yAxis.gap; |
| 2479 | + const stacked = this.mutableConfig.isStacked; |
| 2480 | + const totalGap = stacked ? gap * (totalSeries - 1) : 0; |
| 2481 | + const usableHeight = this.drawingArea.height - totalGap; |
| 2482 | +
|
| 2483 | + return stackSeries.filter(s => s.type === 'plot').map((datapoint) => { |
2457 | 2484 | this.checkAutoScaleError(datapoint); |
2458 | 2485 | const min = this.scaleGroups[datapoint.scaleLabel].min; |
2459 | 2486 | const max = this.scaleGroups[datapoint.scaleLabel].max; |
@@ -2486,9 +2513,11 @@ export default { |
2486 | 2513 | const individualMax = individualScale.max + individualZero; |
2487 | 2514 | const autoScaleMax = autoScaleSteps.max + Math.abs(autoScaleZero); |
2488 | 2515 | |
2489 | | - const yOffset = this.mutableConfig.isStacked ? (this.drawingArea.height * (1 - datapoint.cumulatedStackRatio)) : 0; |
2490 | | -
|
2491 | | - const individualHeight = this.mutableConfig.isStacked ? (this.drawingArea.height * datapoint.stackRatio) - this.FINAL_CONFIG.chart.grid.labels.yAxis.gap : this.drawingArea.height; |
| 2516 | + const origIdx = datapoint.stackIndex; |
| 2517 | + const flippedIdx = totalSeries - 1 - origIdx; |
| 2518 | + const flippedLowerRatio = stacked ? 1 - datapoint.cumulatedStackRatio : 0; |
| 2519 | + const yOffset = stacked ? usableHeight * flippedLowerRatio + gap * flippedIdx : 0; |
| 2520 | + const individualHeight = stacked ? usableHeight * datapoint.stackRatio : this.drawingArea.height; |
2492 | 2521 |
|
2493 | 2522 | const zeroPosition = this.drawingArea.bottom - yOffset - ((individualHeight) * individualZero / individualMax); |
2494 | 2523 | const autoScaleZeroPosition = this.drawingArea.bottom - yOffset - (individualHeight * autoScaleZero / autoScaleMax); |
|
0 commit comments