UNPKG

@nativescript-community/ui-chart

Version:

A powerful chart / graph plugin, supporting line, bar, pie, radar, bubble, and candlestick charts as well as scaling, panning and animations.

199 lines (197 loc) 6.25 kB
import { ComponentBase } from './ComponentBase'; import { LegendEntry } from './LegendEntry'; import { DashPathEffect, Paint } from '@nativescript-community/ui-canvas'; export declare enum LegendForm { /** * Avoid drawing a form */ NONE = 0, /** * Do not draw the a form, but leave space for it */ EMPTY = 1, /** * Use default (default dataset's form to the legend's form) */ DEFAULT = 2, /** * Draw a square */ SQUARE = 3, /** * Draw a circle */ CIRCLE = 4, /** * Draw a horizontal line */ LINE = 5 } export declare enum LegendHorizontalAlignment { LEFT = 0, CENTER = 1, RIGHT = 2 } export declare enum LegendVerticalAlignment { TOP = 0, CENTER = 1, BOTTOM = 2 } export declare enum LegendOrientation { HORIZONTAL = 0, VERTICAL = 1 } export declare enum LegendDirection { LEFT_TO_RIGHT = 0, RIGHT_TO_LEFT = 1 } /** * Class representing the legend of the chart. The legend will contain one entry * per color and DataSet. Multiple colors in one DataSet are grouped together. * The legend object is NOT available before setting data to the chart. * */ export declare class Legend extends ComponentBase { /** * The legend entries array */ entries: LegendEntry[]; /** * Entries that will be appended to the end of the auto calculated entries after calculating the legend. * (if the legend has already been calculated, you will need to call notifyDataSetChanged() to let the changes take effect) */ extraEntries: LegendEntry[]; /** * Are the legend labels/colors a custom value or auto calculated? If false, * then it's auto, if true, then custom. default false (automatic legend) */ mIsLegendCustom: boolean; horizontalAlignment: LegendHorizontalAlignment; verticalAlignment: LegendVerticalAlignment; orientation: LegendOrientation; drawInside: boolean; /** * the text direction for the legend */ direction: LegendDirection; /** * the shape/form the legend colors are drawn in */ form: LegendForm; /** * the size of the legend forms/shapes */ formSize: number; /** * the size of the legend forms/shapes */ formLineWidth: number; /** * Line dash path effect used for shapes that consist of lines. */ formLineDashEffect: DashPathEffect; /** * the space between the legend entries on a horizontal axis, default 6f */ xEntrySpace: number; /** * the space between the legend entries on a vertical axis, default 5f */ yEntrySpace: number; /** * the space between the legend entries on a vertical axis, default 2f * private float this.mYEntrySpace = 2f; /** the space between the form and the * actual label/text */ formToTextSpace: number; /** * the space that should be left between stacked forms */ stackSpace: number; /** * The maximum relative size out of the whole chart view. / If the legend is * to the right/left of the chart, then this affects the width of the * legend. / If the legend is to the top/bottom of the chart, then this * affects the height of the legend. / If the legend is the center of the * piechart, then this defines the size of the rectangular bounds out of the * size of the "hole". / default: 0.95f (95%) */ maxSizePercent: number; /** * Constructor. Provide entries for the legend. * * @param entries */ constructor(entries?: LegendEntry[]); /** * returns the maximum length in pixels across all legend labels + formsize * + formtotextspace * * @param p the paint object used for rendering the text * @return */ getMaximumEntryWidth(p: Paint): number; /** * returns the maximum height in pixels across all legend labels * * @param p the paint object used for rendering the text * @return */ getMaximumEntryHeight(p: Paint): number; /** * Entries that will be appended to the end of the auto calculated * entries after calculating the legend. * (if the legend has already been calculated, you will need to call notifyDataSetChanged() * to let the changes take effect) */ setExtra(colors: any, labels: any): void; /** * Sets a custom legend's entries array. * * A null label will start a group. * This will disable the feature that automatically calculates the legend * entries from the datasets. * Call resetCustom() to re-enable automatic calculation (and then * notifyDataSetChanged() is needed to auto-calculate the legend again) */ setCustom(entries: any): void; /** * Calling this will disable the custom legend entries (set by * setCustom(...)). Instead, the entries will again be calculated * automatically (after notifyDataSetChanged() is called). */ resetCustom(): void; /** * @return true if a custom legend entries has been set default * false (automatic legend) */ isLegendCustom(): boolean; /** * the total width of the legend (needed width space) */ mNeededWidth: number; /** * the total height of the legend (needed height space) */ mNeededHeight: number; mTextHeightMax: number; mTextWidthMax: number; /** * Should the legend word wrap? / this is currently supported only for: * BelowChartLeft, BelowChartRight, BelowChartCenter. / note that word * wrapping a legend takes a toll on performance. / you may want to set * maxSizePercent when word wrapping, to set the point where the text wraps. * / default: false */ wordWrapEnabled: boolean; calculatedLabelSizes: any[]; calculatedLabelBreakPoints: any[]; calculatedLineSizes: any[]; /** * Calculates the dimensions of the Legend. This includes the maximum width * and height of a single entry, as well as the total width and height of * the Legend. * * @param labelpaint */ calculateDimensions(labelpaint: Paint, viewPortHandler: any): void; }