topAxis

fun topAxis(label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), tick: LineComponent? = axisTickComponent(), tickLength: Dp = currentChartStyle.axis.axisTickLength, guideline: LineComponent? = axisGuidelineComponent(), valueFormatter: AxisValueFormatter<AxisPosition.Horizontal.Top> = DecimalFormatAxisValueFormatter(), sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, itemPlacer: AxisItemPlacer.Horizontal = remember { AxisItemPlacer.Horizontal.default() }): HorizontalAxis<AxisPosition.Horizontal.Top>

Deprecated

Use `rememberTopAxis` instead.

Replace with

import com.patrykandpatrick.vico.compose.axis.horizontal.rememberTopAxis

            rememberTopAxis(
                label = label,
                axis = axis,
                tick = tick,
                tickLength = tickLength,
                guideline = guideline,
                valueFormatter = valueFormatter,
                sizeConstraint = sizeConstraint,
                labelRotationDegrees = labelRotationDegrees,
                titleComponent = titleComponent,
                title = title,
                itemPlacer = itemPlacer,
            )
        

Creates and remembers a top axis (i.e., a HorizontalAxis with AxisPosition.Horizontal.Top).

Parameters

label

the TextComponent to use for the labels.

axis

the LineComponent to use for the axis line.

tick

the LineComponent to use for the ticks.

tickLength

the length of the ticks.

guideline

the LineComponent to use for the guidelines.

valueFormatter

formats the labels.

sizeConstraint

defines how the HorizontalAxis is to size itself.

labelRotationDegrees

the rotation of the axis labels (in degrees).

titleComponent

an optional TextComponent to use as the axis title.

title

the axis title.

itemPlacer

determines for what x values the HorizontalAxis is to display labels, ticks, and guidelines.


fun topAxis(label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), tick: LineComponent? = axisTickComponent(), tickLength: Dp = currentChartStyle.axis.axisTickLength, guideline: LineComponent? = axisGuidelineComponent(), valueFormatter: AxisValueFormatter<AxisPosition.Horizontal.Top> = DecimalFormatAxisValueFormatter(), sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, labelSpacing: Int = 1, labelOffset: Int = 0): HorizontalAxis<AxisPosition.Horizontal.Top>

Deprecated

`topAxis` is being replaced by `rememberTopAxis`. Also, `labelSpacing` and `labelOffset` are being replaced by `AxisItemPlacer.Horizontal`. Create a base `AxisItemPlacer.Horizontal` implementation with the desired spacing and offset via `AxisItemPlacer.Horizontal.default`, and use the `itemPlacer` parameter of `rememberTopAxis` to apply it to the `HorizontalAxis` being created.

Replace with

import androidx.compose.runtime.remember
import com.patrykandpatrick.vico.compose.axis.horizontal.rememberTopAxis
import com.patrykandpatrick.vico.core.axis.AxisItemPlacer

            rememberTopAxis(
                label = label,
                axis = axis,
                tick = tick,
                tickLength = tickLength,
                guideline = guideline,
                valueFormatter = valueFormatter,
                sizeConstraint = sizeConstraint,
                labelRotationDegrees = labelRotationDegrees,
                titleComponent = titleComponent,
                title = title,
                itemPlacer = remember {
                    AxisItemPlacer.Horizontal.default(spacing = labelSpacing, offset = labelOffset)
                },
            )
        

Creates and remembers a top axis (i.e., a HorizontalAxis with AxisPosition.Horizontal.Top).

Parameters

label

the TextComponent to use for the labels.

axis

the LineComponent to use for the axis line.

tick

the LineComponent to use for the ticks.

tickLength

the length of the ticks.

guideline

the LineComponent to use for the guidelines.

valueFormatter

formats the labels.

sizeConstraint

defines how the HorizontalAxis is to size itself.

labelRotationDegrees

the rotation of the axis labels (in degrees).

titleComponent

an optional TextComponent to use as the axis title.

title

the axis title.

labelSpacing

how often labels (and their corresponding ticks and guidelines) should be drawn.

labelOffset

the number of labels (and, for HorizontalLayout.FullWidth, their corresponding ticks and guidelines) to skip from the start.