Skip to content

Custom price line label snaps to "minMove" and shows a rounded value instead of the precise number #1959

@Deodes

Description

@Deodes

Custom price line is positioned at the exact numeric value on the chart (Y-coordinate is correct), but the axis label for that line is rounded to the nearest tick defined by the series/price scalevminMove. There is no way to specify a per price line formatter or disable snapping only for the line’s label.

This creates a visible mismatch: the line is drawn at the precise value, but the label shows a different, tick-rounded value.

Lightweight Charts™ Version: 5.0.7

Steps/code to reproduce:

<div id="c" style="width:800px;height:400px"></div>
<script type="module">
  import { createChart, CandlestickSeries } from 'lightweight-charts';

  const chart = createChart(document.getElementById('c'), {});

  // Series uses instrument tick (example: 0.00050)
  const series = chart.addSeries(CandlestickSeries, {
    priceScaleId: 'right',
    priceFormat: { type: 'price', precision: 5, minMove: 0.0005 },
  });

  series.setData([
    { time: 1, open: 1.1590, high: 1.1600, low: 1.1580, close: 1.1592 },
    { time: 2, open: 1.1592, high: 1.1602, low: 1.1585, close: 1.1591 },
  ]);

  // Draw a price line at a precise value that is not aligned to minMove
  const preciseValue = 1.15949;
  series.createPriceLine({
    price: preciseValue,
    axisLabelVisible: true,
    color: '#21ba45',
    lineWidth: 2,
  });

  // Observed: line Y position is correct; axis label displays 1.15950 (rounded to tick)
</script>

Actual behavior:

The line is rendered at the precise price (correct Y position).

The axis label for that line displays a tick-rounded value (snapped to minMove), not the exact number passed to price.

Expected behavior:

The axis label displays the exact line value (no tick snapping)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions