MAIDR Documentation - v3.39.0
    Preparing search index...
    • Factory function to create the appropriate SmoothTrace instance based on layer data and context.

      Uses structural detection (performed upstream) to identify violin plot KDE layers: if the subplot contains both BOX and SMOOTH layers, callers pass isViolinPlot=true and this factory creates a ViolinKdeTrace for SMOOTH layers. Otherwise, it creates a SmoothTrace or SmoothTraceSvgXY based on the data format.

      Note: Structural detection (BOX + SMOOTH in same subplot) is used to avoid plot-specific metadata in the general MaidrLayer interface. This approach works well in practice because:

      • Regular box plots only contain BOX layers
      • Regular smooth plots (regression lines) only contain SMOOTH layers
      • Violin plots are the only plot type that combines both in the same subplot

      Edge case: If a subplot intentionally combines an independent box plot and regression line, this detection would incorrectly identify it as a violin plot. This is rare in practice.

      Parameters

      • layer: MaidrLayer

        The MAIDR layer data for the smooth trace

      • isViolinPlot: boolean = false

        Optional hint that this subplot is a violin plot (BOX + SMOOTH present in the same subplot).

      Returns SmoothTrace | SmoothTraceSvgXY | ViolinKdeTrace

      A SmoothTrace instance: - ViolinKdeTrace if this is a violin plot KDE layer (BOX + SMOOTH detected upstream) - SmoothTraceSvgXY if the data contains svg_x/svg_y coordinates - SmoothTrace otherwise (standard smooth/regression line)