(series, data, xScale, yScale, gridArea, backgroundColor)
| 262 | }; |
| 263 | |
| 264 | const prepare: CandlestickRenderer['prepare'] = (series, data, xScale, yScale, gridArea, backgroundColor) => { |
| 265 | assertNotDisposed(); |
| 266 | |
| 267 | if (data.length === 0) { |
| 268 | instanceCount = 0; |
| 269 | hollowInstanceCount = 0; |
| 270 | return; |
| 271 | } |
| 272 | |
| 273 | const plotSize = computePlotSizeCssPx(gridArea); |
| 274 | if (!plotSize) { |
| 275 | instanceCount = 0; |
| 276 | hollowInstanceCount = 0; |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | const plotClipRect = computePlotClipRect(gridArea); |
| 281 | const clipPerCssX = plotSize.plotWidthCss > 0 ? plotClipRect.width / plotSize.plotWidthCss : 0; |
| 282 | |
| 283 | lastCanvasWidth = gridArea.canvasWidth; |
| 284 | lastCanvasHeight = gridArea.canvasHeight; |
| 285 | lastScissor = computePlotScissorDevicePx(gridArea); |
| 286 | |
| 287 | // Compute category step and width |
| 288 | const categoryStep = computeCategoryStep(data); |
| 289 | const categoryWidthClip = computeCategoryWidthClip(xScale, categoryStep, plotClipRect, data.length); |
| 290 | |
| 291 | // Compute body width in clip space |
| 292 | let bodyWidthClip = 0; |
| 293 | const rawBarWidth = series.barWidth; |
| 294 | if (typeof rawBarWidth === 'number') { |
| 295 | bodyWidthClip = Math.max(0, rawBarWidth) * clipPerCssX; |
| 296 | } else if (typeof rawBarWidth === 'string') { |
| 297 | const p = parsePercent(rawBarWidth); |
| 298 | bodyWidthClip = p == null ? 0 : categoryWidthClip * clamp01(p); |
| 299 | } |
| 300 | |
| 301 | // Apply min/max width constraints (CSS pixels converted to clip space) |
| 302 | const minWidthClip = series.barMinWidth * clipPerCssX; |
| 303 | const maxWidthClip = series.barMaxWidth * clipPerCssX; |
| 304 | bodyWidthClip = Math.min(Math.max(bodyWidthClip, minWidthClip), maxWidthClip); |
| 305 | |
| 306 | // Compute wick width in clip space (default 1px CSS) |
| 307 | const wickWidthCssPx = series.itemStyle.borderWidth ?? DEFAULT_WICK_WIDTH_CSS_PX; |
| 308 | const wickWidthClip = Math.max(0, wickWidthCssPx) * clipPerCssX; |
| 309 | |
| 310 | // Write VS uniforms (identity transform + wick width) |
| 311 | vsUniformScratchF32.set([ |
| 312 | 1, 0, 0, 0, // col0 |
| 313 | 0, 1, 0, 0, // col1 |
| 314 | 0, 0, 1, 0, // col2 |
| 315 | 0, 0, 0, 1, // col3 |
| 316 | wickWidthClip, |
| 317 | 0, |
| 318 | 0, |
| 319 | 0, |
| 320 | ]); |
| 321 | writeUniformBuffer(device, vsUniformBuffer, vsUniformScratchBuffer); |
nothing calls this directly
no test coverage detected