leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.48k stars 370 forks source link

About axes.y.splits #896

Closed dingjunweibjkanyun closed 5 months ago

dingjunweibjkanyun commented 5 months ago
image

The prerequisite is that options.padding is [0,0,0,0]. In some cases, when the scaleMax returned by the split function is close to the maximum split line, it may be truncated. Is there any way to avoid this problem?

leeoniya commented 5 months ago

the purpose of the non-zero padding is to avoid this. if you want y tick labels that are vertically centered on the tick marks and want to put a tick at the top edge of the plotting area, obviously you need extra padding to draw the top half of the tick label. otherwise you cannot render ticks at scales.y.max.

dingjunweibjkanyun commented 5 months ago

Padding may have style issues, business needs to pay attention to this padding

image

Is this possible? When setting scaleMax, the largest split is calculated based on the algorithm of existing splits. If it is close to scaleMax, how can we adjust scaleMax appropriately?

leeoniya commented 5 months ago

the algorithm for auto-calculating yMax from dynamic data will be improved in the future to ensure that there is always a tick at the top edge of the plot. this means the padding will be even more important in the future. i dont have any advice for how to select ticks or yMax in a way that always prevents the top tick label from being clipped if your padding is 0. you can reduce the top padding to half your text height, which will help.