Back to Lightweight Charts

Inverted Price Scale

website/tutorials/how_to/inverted-price-scale.mdx

5.2.01.2 KB
Original Source

This example shows how to invert a price scale. Usually, the price scale will map the range of numbers from small to large along the vertical axis from bottom to top. Inverting the price scale will change this such that the values map from top to bottom.

How to

Set the invertScale property on the priceScale options to true.

js
chart.applyOptions({
    rightPriceScale: {
        invertScale: true,
    },
});

// or (for a specific price scale)
const priceScale = chart.priceScale();
priceScale.applyOptions({
    invertScale: true,
});

You can see a full working example below.

Resources

Full example

import UsageGuidePartial from "../_usage-guide-partial.mdx"; import CodeBlock from "@theme/CodeBlock"; import code from "!!raw-loader!./inverted-price-scale.js";

<CodeBlock replaceThemeConstants chart className="language-js" hideableCode chartOnTop codeUsage={<UsageGuidePartial />}> {code} </CodeBlock>