7676 stroke-linecap =" round"
7777 />
7878 </template >
79- <template v-else >
79+ <template v-else-if = " chartConfig . chart . grid . showHorizontalLines " >
8080 <g v-for =" grid in allScales" >
8181 <template v-if =" grid .id === selectedScale " >
8282 <line
9090 stroke-linecap =" round"
9191 />
9292 </template >
93+ <template v-else >
94+ <line
95+ v-for =" l in grid.yLabels"
96+ :x1 =" drawingArea.left"
97+ :x2 =" drawingArea.right"
98+ :y1 =" l.y"
99+ :y2 =" l.y"
100+ :stroke =" chartConfig.chart.grid.stroke"
101+ :stroke-width =" 0.5"
102+ stroke-linecap =" round"
103+ />
104+ </template >
93105 </g >
94106 </template >
95107 <g v-if =" chartConfig.chart.grid.showVerticalLines" data-cy =" xy-grid-vertical-lines" >
529541 v-for =" el in allScales"
530542 :x1 =" el.x"
531543 :x2 =" el.x"
532- :y1 =" drawingArea.top"
533- :y2 =" drawingArea.bottom"
544+ :y1 =" chartConfig.chart.grid.labels.yAxis.stacked ? (drawingArea.bottom - el.yOffset - el.individualHeight) : drawingArea.top"
545+ :y2 =" chartConfig.chart.grid.labels.yAxis.stacked ? (drawingArea.bottom - el.yOffset) : drawingArea.bottom"
534546 :stroke =" el.color"
535547 :stroke-width =" chartConfig.chart.grid.stroke"
536548 stroke-linecap =" round"
541553 :fill =" el.color"
542554 :font-size =" chartConfig.chart.grid.labels.fontSize"
543555 text-anchor =" middle"
544- :transform =" `translate(${el.x - chartConfig.chart.grid.labels.yAxis.labelWidth + 5}, ${drawingArea.top + drawingArea.height / 2}) rotate(-90)`"
556+ :transform =" `translate(${el.x - chartConfig.chart.grid.labels.yAxis.labelWidth + 5}, ${chartConfig.chart.grid.labels.yAxis.stacked ? drawingArea.bottom - el.yOffset - (el.individualHeight / 2) : drawingArea.top + drawingArea.height / 2}) rotate(-90)`"
545557 >
546558 {{ el.name }} {{ el.scaleLabel ? `- ${el.scaleLabel}` : '' }}
547559 </text >
597609 </g >
598610
599611 <!-- Y LABELS MOUSE TRAPS -->
600- <template v-if =" chartConfig .chart .grid .labels .yAxis .useIndividualScale " >
612+ <template v-if =" chartConfig .chart .grid .labels .yAxis .useIndividualScale && ! chartConfig . chart . grid . labels . yAxis . stacked " >
601613 <rect
602614 v-for =" trap in allScales"
603615 :x =" trap.x - chartConfig.chart.grid.labels.yAxis.labelWidth"
@@ -989,7 +1001,9 @@ export default {
9891001 zero: l .zeroPosition ,
9901002 max: l .individualMax ,
9911003 scaleLabel: l .scaleLabel || " " ,
992- id: l .id
1004+ id: l .id ,
1005+ yOffset: l .yOffset || 0 ,
1006+ individualHeight: l .individualHeight || this .drawingArea .height
9931007 }
9941008 });
9951009 const bars = this .barSet .map (b => {
@@ -1000,7 +1014,9 @@ export default {
10001014 zero: b .zeroPosition ,
10011015 max: b .individualMax ,
10021016 scaleLabel: b .scaleLabel || " " ,
1003- id: b .id
1017+ id: b .id ,
1018+ yOffset: b .yOffset || 0 ,
1019+ individualHeight: b .individualHeight || this .drawingArea .height
10041020 }
10051021 });
10061022 const plots = this .plotSet .map (p => {
@@ -1011,7 +1027,9 @@ export default {
10111027 zero: p .zeroPosition ,
10121028 max: p .individualMax ,
10131029 scaleLabel: p .scaleLabel || " " ,
1014- id: p .id
1030+ id: p .id ,
1031+ yOffset: p .yOffset || 0 ,
1032+ individualHeight: p .individualHeight || this .drawingArea .height
10151033 }
10161034 });
10171035 const len = [... lines, ... bars, ... plots].flatMap (el => el).length ;
@@ -1022,10 +1040,12 @@ export default {
10221040 name: el .name ,
10231041 color: el .color ,
10241042 scale: el .scale ,
1025- x: (this .drawingArea .left / len) * (i+ 1 ),
1043+ yOffset: el .yOffset ,
1044+ individualHeight: el .individualHeight ,
1045+ x: this .chartConfig .chart .grid .labels .yAxis .stacked ? this .drawingArea .left : (this .drawingArea .left / len) * (i+ 1 ),
10261046 yLabels: el .scale .ticks .map (t => {
10271047 return {
1028- y: t >= 0 ? el .zero - (this . drawingArea . height * (t / el .max )) : el .zero + (this . drawingArea . height * Math .abs (t) / el .max ),
1048+ y: t >= 0 ? el .zero - (el . individualHeight * (t / el .max )) : el .zero + (el . individualHeight * Math .abs (t) / el .max ),
10291049 value: t
10301050 }
10311051 })
@@ -1131,6 +1151,7 @@ export default {
11311151 absoluteDataset () {
11321152 return this .safeDataset .map ((datapoint , i ) => {
11331153 return {
1154+ absoluteIndex: i,
11341155 ... datapoint,
11351156 series: datapoint .series .map (plot => plot + this .relativeZero ),
11361157 absoluteValues: datapoint .series ,
@@ -1149,18 +1170,25 @@ export default {
11491170 const individualScale = this .calculateNiceScale (individualExtremes .min , individualExtremes .max , scaleSteps)
11501171 const individualZero = individualScale .min >= 0 ? 0 : Math .abs (individualScale .min );
11511172 const individualMax = individualScale .max + individualZero;
1152- const zeroPosition = this .drawingArea .bottom - (this .drawingArea .height * individualZero / individualMax);
1173+ const yOffset = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) * datapoint .absoluteIndex : 0 ;
1174+
1175+ const individualHeight = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) - this .chartConfig .chart .grid .labels .yAxis .gap : this .drawingArea .height ;
1176+ const zeroPosition = this .drawingArea .bottom - yOffset - ((individualHeight) * individualZero / individualMax);
11531177 return {
11541178 individualScale,
1179+ yOffset,
1180+ individualHeight,
11551181 zeroPosition,
11561182 individualMax,
11571183 ... datapoint,
11581184 plots: datapoint .series .map ((plot , j ) => {
11591185 const yRatio = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale ? ((datapoint .absoluteValues [j] + individualZero) / individualMax) : this .ratioToMax (plot)
11601186
11611187 return {
1188+ yOffset,
1189+ individualHeight,
11621190 x: (this .drawingArea .left - this .slot .bar / 2 + this .slot .bar * i) + (this .slot .bar * j * this .absoluteDataset .filter (ds => ds .type === ' bar' ).filter (s => ! this .segregatedSeries .includes (s .id )).length ),
1163- y: this .drawingArea .bottom - ( this . drawingArea . height * yRatio),
1191+ y: this .drawingArea .bottom - yOffset - (individualHeight * yRatio),
11641192 value: datapoint .absoluteValues [j],
11651193 zeroPosition,
11661194 individualMax,
@@ -1169,6 +1197,9 @@ export default {
11691197 }
11701198 })
11711199 },
1200+ activeSeriesLength () {
1201+ return this .absoluteDataset .length
1202+ },
11721203 lineSet () {
11731204 return this .absoluteDataset .filter (s => s .type === ' line' ).filter (s => ! this .segregatedSeries .includes (s .id )).map ((datapoint ) => {
11741205 const individualExtremes = {
@@ -1180,26 +1211,34 @@ export default {
11801211 const individualScale = this .calculateNiceScale (individualExtremes .min , individualExtremes .max , scaleSteps)
11811212 const individualZero = (individualScale .min >= 0 ? 0 : Math .abs (individualScale .min ))
11821213 const individualMax = individualScale .max + Math .abs (individualZero)
1183- const zeroPosition = this .drawingArea .bottom - (this .drawingArea .height * individualZero / individualMax);
1214+
1215+ const yOffset = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) * datapoint .absoluteIndex : 0 ;
1216+
1217+ const individualHeight = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) - this .chartConfig .chart .grid .labels .yAxis .gap : this .drawingArea .height ;
1218+ const zeroPosition = this .drawingArea .bottom - yOffset - ((individualHeight) * individualZero / individualMax);
11841219
11851220 const plots = datapoint .series .map ((plot , j ) => {
1186- const yRatio = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale ? ((datapoint .absoluteValues [j] + Math .abs (individualZero)) / individualMax) : this .ratioToMax (plot)
1221+ const yRatio = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale
1222+ ? ((datapoint .absoluteValues [j] + Math .abs (individualZero)) / individualMax)
1223+ : this .ratioToMax (plot)
11871224
11881225 return {
11891226 x: (this .drawingArea .left + (this .slot .line / 2 )) + (this .slot .line * j),
1190- y: this .drawingArea .bottom - ( this . drawingArea . height * yRatio),
1227+ y: this .drawingArea .bottom - yOffset - (individualHeight * yRatio),
11911228 value: datapoint .absoluteValues [j],
11921229 }
11931230 });
11941231 const curve = this .createSmoothPath (plots);
11951232 return {
1233+ yOffset,
1234+ individualHeight,
11961235 individualScale,
11971236 individualMax,
11981237 zeroPosition,
11991238 ... datapoint,
12001239 curve,
12011240 plots,
1202- area: ! datapoint .useArea ? ' ' : this .chartConfig .chart .grid .labels .yAxis .useIndividualScale ? this .createIndividualArea (plots, this . drawingArea . bottom ) : this .createArea (plots)
1241+ area: ! datapoint .useArea ? ' ' : this .chartConfig .chart .grid .labels .yAxis .useIndividualScale ? this .createIndividualArea (plots, zeroPosition ) : this .createArea (plots)
12031242 }
12041243 })
12051244 },
@@ -1215,9 +1254,14 @@ export default {
12151254 const individualZero = individualScale .min >= 0 ? 0 : Math .abs (individualScale .min );
12161255 const individualMax = individualScale .max + individualZero;
12171256
1218- const zeroPosition = this .drawingArea .bottom - (this .drawingArea .height * individualZero / individualMax);
1257+ const yOffset = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) * datapoint .absoluteIndex : 0 ;
1258+
1259+ const individualHeight = this .chartConfig .chart .grid .labels .yAxis .stacked ? (this .drawingArea .height / this .activeSeriesLength ) - this .chartConfig .chart .grid .labels .yAxis .gap : this .drawingArea .height ;
1260+ const zeroPosition = this .drawingArea .bottom - yOffset - ((individualHeight) * individualZero / individualMax);
12191261
12201262 return {
1263+ individualHeight,
1264+ yOffset,
12211265 ... datapoint,
12221266 zeroPosition,
12231267 individualMax,
@@ -1226,15 +1270,15 @@ export default {
12261270 const yRatio = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale ? ((datapoint .absoluteValues [j] + Math .abs (individualZero)) / individualMax) : this .ratioToMax (plot)
12271271 return {
12281272 x: (this .drawingArea .left + (this .slot .plot / 2 )) + (this .slot .plot * j),
1229- y: this .drawingArea .bottom - ( this . drawingArea . height * yRatio),
1273+ y: this .drawingArea .bottom - yOffset - (individualHeight * yRatio),
12301274 value: datapoint .absoluteValues [j],
12311275 }
12321276 })
12331277 }
12341278 })
12351279 },
12361280 drawingArea () {
1237- const individualScalesPadding = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale && this .chartConfig .chart .grid .labels .show ? this .absoluteDataset .filter (s => ! this .segregatedSeries .includes (s .id )).length * this .chartConfig .chart .grid .labels .yAxis .labelWidth : 0 ;
1281+ const individualScalesPadding = this .chartConfig .chart .grid .labels .yAxis .useIndividualScale && this .chartConfig .chart .grid .labels .show ? this .absoluteDataset .filter (s => ! this .segregatedSeries .includes (s .id )).length * ( this .chartConfig .chart .grid .labels .yAxis .stacked ? 0 : this . chartConfig . chart . grid . labels . yAxis . labelWidth ) : 0 ;
12381282 return {
12391283 top: this .chartConfig .chart .padding .top ,
12401284 right: this .chartConfig .chart .width - this .chartConfig .chart .padding .right ,
0 commit comments