scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
69 lines (68 loc) • 2.6 kB
TypeScript
import { TFormatLabelFn } from "./LabelProvider";
import { ILabel2DOptions } from "./LabelProviderBase2D";
import { NumericLabelProvider } from "./NumericLabelProvider";
export interface IRadianLabelProviderOptions extends ILabel2DOptions {
/**
* The maximum denominator to use when formatting values as fractions of PI
*
* e.g. For 12, you can expect fractions such as `11π/12`, `3π/4`, `5π/6`, but NOT `13π/24`
*
* Default `12`
*/
maxDenominator?: number;
/**
* The maximum error tolerance when formatting values as fractions of PI
*
* If a tick lands within this tolerance of a fraction of PI, it is formatted as that PI fraction, else it reverts to a decimal.
*
* Default `0.0001`
*/
errorTolerance?: number;
}
/**
* The {@link RadianLabelProvider} formats Axis Labels and Cursor / Tooltips for {@link NumericAxis} types as multiples/fractions of PI
* @note It is highly recommended to use this label provider with these axis options:
* ```ts
* const xAxis = new NumericAxis(wasmContext, {
* labelProvider: new RadianLabelProvider({
* maxDenominator: 4, // or any other non-zero integer
* errorTolerance: 0.0001,
*
* labelPrecision: 2
* // for values that cannot be expressed as fractions of PI within `maxDenominator` constraint,
* // thus default to decimal format
* }),
* autoTicks: false, // to manually set tick distance
* majorDelta: Math.PI / 4, // or any other PI fraction
* });
* ```
*/
export declare class RadianLabelProvider extends NumericLabelProvider {
private maxDenominatorProperty;
private errorToleranceProperty;
constructor(options?: IRadianLabelProviderOptions);
/**
* Gets or sets the maximum denominator to use when formatting values as fractions of PI
*/
get maxDenominator(): number;
set maxDenominator(value: number);
/**
* Gets or sets the maximum error tolerance when formatting values as fractions of PI
*/
get errorTolerance(): number;
set errorTolerance(value: number);
/**
* Used internally.
* Returns the greatest common divisor of two numbers.
*/
private getGCD;
/**
* Used internally.
* Finds the best fraction for a given ratio and maximum denominator, returns decimal if no fraction found.
*/
private findFraction;
/**
* @inheritdoc
*/
get formatLabel(): TFormatLabelFn;
}