@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.
62 lines (61 loc) • 2.72 kB
JavaScript
import { DashPathEffect, Style } from '@nativescript-community/ui-canvas';
import { ComponentBase } from './ComponentBase';
/** enum that indicates the position of the LimitLine label */
export var LimitLabelPosition;
(function (LimitLabelPosition) {
LimitLabelPosition[LimitLabelPosition["LEFT_TOP"] = 0] = "LEFT_TOP";
LimitLabelPosition[LimitLabelPosition["LEFT_BOTTOM"] = 1] = "LEFT_BOTTOM";
LimitLabelPosition[LimitLabelPosition["CENTER_TOP"] = 2] = "CENTER_TOP";
LimitLabelPosition[LimitLabelPosition["CENTER_BOTTOM"] = 3] = "CENTER_BOTTOM";
LimitLabelPosition[LimitLabelPosition["RIGHT_TOP"] = 4] = "RIGHT_TOP";
LimitLabelPosition[LimitLabelPosition["RIGHT_BOTTOM"] = 5] = "RIGHT_BOTTOM";
})(LimitLabelPosition || (LimitLabelPosition = {}));
/**
* The limit line is an additional feature for all Line-, Bar- and
* ScatterCharts. It allows the displaying of an additional line in the chart
* that marks a certain maximum / limit on the specified axis (x- or y-axis).
*
*/
export class LimitLine extends ComponentBase {
/**
* Constructor with limit and label.
*
* @param limit - the position (the value) on the y-axis (y-value) or x-axis
* (xIndex) where this line should appear
* @param label - provide "" if no label is required
*/
constructor(limit, label) {
super();
/** limit / maximum (the y-value or xIndex) */
this.limit = 0;
/** the width of the limit line
* thinner line === better performance, thicker line === worse performance
*/
this.lineWidth = 2;
/** the color of the limit line */
this.lineColor = '#ED5B5B';
/** the style of the label text */
this.textStyle = Style.FILL;
/** label string that is drawn next to the limit line */
this.label = '';
/** the path effect of this LimitLine that makes dashed lines possible */
this.dashPathEffect = null;
/** position of the LimitLine value label (either on the right or on
* the left edge of the chart). Not supported for RadarChart.
*/
this.labelPosition = LimitLabelPosition.RIGHT_TOP;
this.limit = limit;
this.label = label;
}
/**
* Enables the line to be drawn in dashed mode, e.g. like this "- - - - - -"
*
* @param lineLength the length of the line pieces
* @param spaceLength the length of space inbetween the pieces
* @param phase offset, in degrees (normally, use 0)
*/
enableDashedLine(lineLength, spaceLength, phase) {
this.dashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
}
//# sourceMappingURL=LimitLine.js.map