File tree Expand file tree Collapse file tree
packages/layerchart/src/lib/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' layerchart ' : patch
3+ ---
4+
5+ fix(Axis|Text): Improve Text y placement using lineHeight/capHeight and remove explicit adjustments, aligning with Html rendering
Original file line number Diff line number Diff line change 264264 return {
265265 textAnchor: ' middle' ,
266266 verticalAnchor: ' end' ,
267- dy: - tickLength - 2 , // manually adjusted until Text supports custom styles
267+ dy: - tickLength ,
268268 };
269269
270270 case ' bottom' :
271271 return {
272272 textAnchor: ' middle' ,
273273 verticalAnchor: ' start' ,
274- dy: tickLength , // manually adjusted until Text supports custom styles
274+ dy: tickLength ,
275275 };
276276
277277 case ' left' :
278278 return {
279279 textAnchor: ' end' ,
280280 verticalAnchor: ' middle' ,
281281 dx: - tickLength ,
282- dy: - 2 , // manually adjusted until Text supports custom styles
283282 };
284283
285284 case ' right' :
286285 return {
287286 textAnchor: ' start' ,
288287 verticalAnchor: ' middle' ,
289288 dx: tickLength ,
290- dy: - 2 , // manually adjusted until Text supports custom styles
291289 };
292290
293291 case ' angle' :
302300 ? ' end'
303301 : ' start' ,
304302 verticalAnchor: ' middle' ,
305- dx: Math .sin (xValue ) * ( tickLength + 2 ) ,
303+ dx: Math .sin (xValue ) * tickLength ,
306304 dy: - Math .cos (xValue ) * (tickLength + 4 ), // manually adjusted until Text supports custom styles
307305 };
308306
311309 textAnchor: ' middle' ,
312310 verticalAnchor: ' middle' ,
313311 dx: 2 ,
314- dy: - 2 , // manually adjusted until Text supports custom styles
315312 };
316313 }
317314 }
416413 value: tickFormat (tick , index ),
417414 ... getDefaultTickLabelProps (tick ),
418415 motion ,
419- lineHeight: ' 11px' , // complement 10px text (until Text supports custom styles)
416+ // complement 10px text (until Text supports custom styles)
417+ capHeight: ' 7px' ,
418+ lineHeight: ' 11px' ,
420419 ... tickLabelProps ,
421420 class: cls (
422421 layerClass (' axis-tick-label' ),
Original file line number Diff line number Diff line change 337337
338338 const startDy = $derived .by (() => {
339339 if (verticalAnchor === ' start' ) {
340- return getPixelValue (capHeight );
340+ return getPixelValue (lineHeight );
341341 } else if (verticalAnchor === ' middle' ) {
342342 return ((lineCount - 1 ) / 2 ) * - getPixelValue (lineHeight ) + getPixelValue (capHeight ) / 2 ;
343343 } else {
344- return (lineCount - 1 ) * - getPixelValue (lineHeight );
344+ return (lineCount - 1 ) * - getPixelValue (lineHeight ) - getPixelValue ( capHeight ) / 2 ;
345345 }
346346 });
347347
You can’t perform that action at this time.
0 commit comments