website/tutorials/how_to/inverted-price-scale.mdx
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.
Set the invertScale property
on the priceScale options to true.
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.
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>