@@ -226,17 +226,19 @@ const segments = computed(() => {
226226 return [];
227227 };
228228 const scale = calculateNiceScale (minMax .value .min , minMax .value .max , FINAL_CONFIG .value .style .chart .segments .ticks .divisions );
229+ const absMin = scale .min >= 0 ? 0 : Math .abs (scale .min );
230+
229231 const target = {
230- x: svg .value .left + (props .dataset .target / scale .max * svg .value .chartWidth ) - FINAL_CONFIG .value .style .chart .target .width / 2
232+ x: svg .value .left + ((( props .dataset .target + absMin) / ( scale .max + absMin)) * svg .value .chartWidth ) - FINAL_CONFIG .value .style .chart .target .width / 2
231233 }
232234 const value = {
233- width: activeValue .value / scale .max * svg .value .chartWidth
235+ width: (( activeValue .value + absMin) / ( scale .max + absMin)) * svg .value .chartWidth
234236 }
235237 const ticks = scale .ticks .map (t => {
236238 return {
237239 value: t,
238240 y: svg .value .bottom + FINAL_CONFIG .value .style .chart .segments .dataLabels .fontSize + 3 + FINAL_CONFIG .value .style .chart .segments .dataLabels .offsetY ,
239- x: svg .value .left + (t / scale .max * svg .value .chartWidth )
241+ x: svg .value .left + (((t + absMin) / ( scale .max + absMin)) * svg .value .chartWidth )
240242 }
241243 })
242244 return {
@@ -248,10 +250,10 @@ const segments = computed(() => {
248250 return {
249251 ... segment,
250252 color: segment .color ? convertColorToHex (segment .color ) : segmentColors .value [i],
251- x: svg .value .left + (svg .value .chartWidth * (segment .from / scale .max )),
252- y: svg .value .top , // no padding
253+ x: svg .value .left + (svg .value .chartWidth * (( segment .from + absMin) / ( scale .max + absMin) )),
254+ y: svg .value .top ,
253255 height: svg .value .chartHeight ,
254- width: svg .value .chartWidth * ((segment .to - segment .from ) / scale .max ),
256+ width: svg .value .chartWidth * (Math . abs (segment .to - segment .from ) / ( scale .max + absMin) ),
255257 }
256258 })
257259 }
0 commit comments