Skip to content

Commit e344a8a

Browse files
authored
Merge pull request #196 from graphieros/fix-xy-area-base
Fix xy area base y position when all values are negative
2 parents 149fb1c + 47440b9 commit e344a8a

File tree

6 files changed

+263
-232
lines changed

6 files changed

+263
-232
lines changed

TestingArena/ArenaVueUiXy.vue

Lines changed: 250 additions & 221 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "2.7.5",
4+
"version": "2.7.6-beta.0",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue 3 components library for eloquent data storytelling",
77
"keywords": [

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const components = ref([ //------|
119119
* Modify the index to display a component
120120
* [0] = VueUiXy
121121
*/
122-
const selectedComponent = ref(components.value[1]);
122+
const selectedComponent = ref(components.value[0]);
123123
124124
/**
125125
* Legacy testing arena where some non chart components can be tested

src/components/vue-ui-xy.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,9 @@ export default {
23192319
this.scaleGroups[datapoint.scaleLabel].autoScaleYLabels = autoScaleYLabels;
23202320
this.scaleGroups[datapoint.scaleLabel].unique = this.activeSeriesWithStackRatios.filter(el => el.scaleLabel === datapoint.scaleLabel).length === 1
23212321
2322+
const areaZeroPosition = this.mutableConfig.useIndividualScale ? datapoint.autoScaling ? autoScaleZeroPosition : zeroPosition : this.zero;
2323+
const adustedAreaZeroPosition = Math.max(Math.max(datapoint.autoScaling ? autoScaleZeroPosition : scaleYLabels.at(-1).y, this.drawingArea.top), areaZeroPosition);
2324+
23222325
return {
23232326
...datapoint,
23242327
yOffset,
@@ -2337,14 +2340,13 @@ export default {
23372340
? this.createIndividualAreaWithCuts(datapoint.autoScaling
23382341
? autoScalePlots
23392342
: plots,
2340-
datapoint.autoScaling ? autoScaleZeroPosition : zeroPosition,
2343+
adustedAreaZeroPosition,
23412344
)
23422345
: this.createIndividualArea(datapoint.autoScaling
23432346
? autoScalePlots.filter(p => p.value !== null)
23442347
: plots.filter(p => p.value !== null),
2345-
datapoint.autoScaling ? autoScaleZeroPosition : zeroPosition,)
2346-
: this.createArea(plots.filter(p => p.value !== null), yOffset),
2347-
2348+
adustedAreaZeroPosition)
2349+
: this.createIndividualArea(plots.filter(p => p.value !== null), adustedAreaZeroPosition),
23482350
curveAreas: !datapoint.useArea
23492351
? []
23502352
:createSmoothAreaSegments(
@@ -2355,7 +2357,7 @@ export default {
23552357
: this.FINAL_CONFIG.line.cutNullValues
23562358
? plots
23572359
: plots.filter(p => p.value !== null),
2358-
this.mutableConfig.useIndividualScale ? datapoint.autoScaling ? autoScaleZeroPosition : zeroPosition : this.zero,
2360+
adustedAreaZeroPosition,
23592361
this.FINAL_CONFIG.line.cutNullValues),
23602362
straight: datapoint.autoScaling ? autoScaleStraight : straight,
23612363
groupId: this.scaleGroups[datapoint.scaleLabel].groupId
@@ -3161,8 +3163,7 @@ export default {
31613163
}
31623164
}
31633165
},
3164-
createArea(plots, yOffset) {
3165-
const zero = this.mutableConfig.isStacked ? this.drawingArea.bottom - yOffset : this.drawingArea.bottom;
3166+
createArea(plots, zero) {
31663167
if(!plots[0]) return [-10,-10, '', -10, -10];
31673168
const start = { x: plots[0].x, y: zero };
31683169
const end = { x: plots.at(-1).x, y: zero };

src/useConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ export function useConfig() {
457457
showBaseline: false,
458458
},
459459
yAxis: {
460+
position: 'left',
460461
showBaseline: true,
461462
commonScaleSteps: 10,
462463
useIndividualScale: false,

0 commit comments

Comments
 (0)