All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.flow.component.charts.model.RangeSelector Maven / Gradle / Ivy

There is a newer version: 24.5.4
Show newest version
/**
 * Copyright 2000-2024 Vaadin Ltd.
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See {@literal } for the full
 * license.
 */
package com.vaadin.flow.component.charts.model;

import java.util.ArrayList;
import java.util.Arrays;

import com.vaadin.flow.component.charts.model.style.ButtonTheme;
import com.vaadin.flow.component.charts.model.style.Color;
import com.vaadin.flow.component.charts.model.style.Style;

/**
 * The range selector is a tool for selecting ranges to display within the
 * chart. It provides buttons to select preconfigured ranges in the chart, like
 * 1 day, 1 week, 1 month etc. It also provides input boxes where min and max
 * dates can be manually input.
 */
public class RangeSelector extends AbstractConfigurationObject {

    private Boolean allButtonsEnabled;
    private ButtonPosition buttonPosition;
    private Number buttonSpacing;
    private ButtonTheme buttonTheme;
    private ArrayList buttons;
    private Boolean enabled;
    private Number height;
    private Color inputBoxBorderColor;
    private Number inputBoxHeight;
    private Number inputBoxWidth;
    private String inputDateFormat;
    private String _fn_inputDateParser;
    private String inputEditDateFormat;
    private Boolean inputEnabled;
    private ButtonPosition inputPosition;
    private Style inputStyle;
    private Style labelStyle;
    private Number selected;

    public RangeSelector() {
    }

    /**
     * @see #setAllButtonsEnabled(Boolean)
     */
    public Boolean getAllButtonsEnabled() {
        return allButtonsEnabled;
    }

    /**
     * Whether to enable all buttons from the start. By default buttons are only
     * enabled if the corresponding time range exists on the X axis, but
     * enabling all buttons allows for dynamically loading different time
     * ranges.
     * 

* Defaults to: false */ public void setAllButtonsEnabled(Boolean allButtonsEnabled) { this.allButtonsEnabled = allButtonsEnabled; } /** * @see #setButtonPosition(ButtonPosition) */ public ButtonPosition getButtonPosition() { if (buttonPosition == null) { buttonPosition = new ButtonPosition(); } return buttonPosition; } /** * A fixed pixel position for the buttons. Supports two properties, * x and y. */ public void setButtonPosition(ButtonPosition buttonPosition) { this.buttonPosition = buttonPosition; } /** * @see #setButtonSpacing(Number) */ public Number getButtonSpacing() { return buttonSpacing; } /** * The space in pixels between the buttons in the range selector. *

* Defaults to: 0 */ public void setButtonSpacing(Number buttonSpacing) { this.buttonSpacing = buttonSpacing; } /** * @see #setButtonTheme(ButtonTheme) */ public ButtonTheme getButtonTheme() { if (buttonTheme == null) { buttonTheme = new ButtonTheme(); } return buttonTheme; } /** *

* A collection of attributes for the buttons. The object takes SVG * attributes like fill, stroke, * stroke-width, as well as style, a collection of * CSS properties for the text. *

* *

* The object can also be extended with states, so you can set * presentational options for hover, select or * disabled button states. *

* *

* CSS styles for the text label. *

* *

* In styled mode, the buttons are styled by the * .highcharts-range-selector-buttons .highcharts-button rule * with its different states. *

*/ public void setButtonTheme(ButtonTheme buttonTheme) { this.buttonTheme = buttonTheme; } /** * @see #setButtons(RangeSelectorButton...) */ public RangeSelectorButton[] getButtons() { if (buttons == null) { return new RangeSelectorButton[] {}; } RangeSelectorButton[] arr = new RangeSelectorButton[buttons.size()]; buttons.toArray(arr); return arr; } /** *

* An array of configuration objects for the buttons. *

* * Defaults to * *
     * buttons: [{
     * 		type: 'month',
     * 		count: 1,
     * 		text: '1m'
     * 	}, {
     * 		type: 'month',
     * 		count: 3,
     * 		text: '3m'
     * 	}, {
     * 		type: 'month',
     * 		count: 6,
     * 		text: '6m'
     * 	}, {
     * 		type: 'ytd',
     * 		text: 'YTD'
     * 	}, {
     * 		type: 'year',
     * 		count: 1,
     * 		text: '1y'
     * 	}, {
     * 		type: 'all',
     * 		text: 'All'
     * 	}]
     * 
*/ public void setButtons(RangeSelectorButton... buttons) { this.buttons = new ArrayList( Arrays.asList(buttons)); } /** * Adds button to the buttons array * * @param button * to add * @see #setButtons(RangeSelectorButton...) */ public void addButton(RangeSelectorButton button) { if (this.buttons == null) { this.buttons = new ArrayList(); } this.buttons.add(button); } /** * Removes first occurrence of button in buttons array * * @param button * to remove * @see #setButtons(RangeSelectorButton...) */ public void removeButton(RangeSelectorButton button) { this.buttons.remove(button); } public RangeSelector(Boolean enabled) { this.enabled = enabled; } /** * @see #setEnabled(Boolean) */ public Boolean getEnabled() { return enabled; } /** * Enable or disable the range selector. *

* Defaults to: true */ public void setEnabled(Boolean enabled) { this.enabled = enabled; } /** * @see #setHeight(Number) */ public Number getHeight() { return height; } /** * The height of the range selector, used to reserve space for buttons and * input. *

* Defaults to: 35 */ public void setHeight(Number height) { this.height = height; } /** * @see #setInputBoxBorderColor(Color) */ public Color getInputBoxBorderColor() { return inputBoxBorderColor; } /** * The border color of the date input boxes. *

* Defaults to: #cccccc */ public void setInputBoxBorderColor(Color inputBoxBorderColor) { this.inputBoxBorderColor = inputBoxBorderColor; } /** * @see #setInputBoxHeight(Number) */ public Number getInputBoxHeight() { return inputBoxHeight; } /** * The pixel height of the date input boxes. *

* Defaults to: 17 */ public void setInputBoxHeight(Number inputBoxHeight) { this.inputBoxHeight = inputBoxHeight; } /** * @see #setInputBoxWidth(Number) */ public Number getInputBoxWidth() { return inputBoxWidth; } /** * The pixel width of the date input boxes. *

* Defaults to: 90 */ public void setInputBoxWidth(Number inputBoxWidth) { this.inputBoxWidth = inputBoxWidth; } /** * @see #setInputDateFormat(String) */ public String getInputDateFormat() { return inputDateFormat; } /** * The date format in the input boxes when not selected for editing. * Defaults to %b %e, %Y. *

* Defaults to: %b %e %Y, */ public void setInputDateFormat(String inputDateFormat) { this.inputDateFormat = inputDateFormat; } public String getInputDateParser() { return _fn_inputDateParser; } public void setInputDateParser(String _fn_inputDateParser) { this._fn_inputDateParser = _fn_inputDateParser; } /** * @see #setInputEditDateFormat(String) */ public String getInputEditDateFormat() { return inputEditDateFormat; } /** * The date format in the input boxes when they are selected for editing. * This must be a format that is recognized by JavaScript Date.parse. *

* Defaults to: %Y-%m-%d */ public void setInputEditDateFormat(String inputEditDateFormat) { this.inputEditDateFormat = inputEditDateFormat; } /** * @see #setInputEnabled(Boolean) */ public Boolean getInputEnabled() { return inputEnabled; } /** * Enable or disable the date input boxes. Defaults to enabled when there is * enough space, disabled if not (typically mobile). */ public void setInputEnabled(Boolean inputEnabled) { this.inputEnabled = inputEnabled; } /** * @see #setInputPosition(ButtonPosition) */ public ButtonPosition getInputPosition() { if (inputPosition == null) { inputPosition = new ButtonPosition(); } return inputPosition; } /** * Positioning for the input boxes. Allowed properties are * align, verticalAlign, x and * y. *

* Defaults to: { align: "right" } */ public void setInputPosition(ButtonPosition inputPosition) { this.inputPosition = inputPosition; } /** * @see #setInputStyle(Style) */ public Style getInputStyle() { if (inputStyle == null) { inputStyle = new Style(); } return inputStyle; } /** *

* CSS for the HTML inputs in the range selector. *

* *

* In styled mode, the inputs are styled by the * .highcharts-range-input text rule in SVG mode, and * input.highcharts-range-selector when active. *

*/ public void setInputStyle(Style inputStyle) { this.inputStyle = inputStyle; } /** * @see #setLabelStyle(Style) */ public Style getLabelStyle() { if (labelStyle == null) { labelStyle = new Style(); } return labelStyle; } /** *

* CSS styles for the labels - the Zoom, From and To texts. *

* *

* In styled mode, the labels are styled by the * .highcharts-range-label class. *

*/ public void setLabelStyle(Style labelStyle) { this.labelStyle = labelStyle; } /** * @see #setSelected(Number) */ public Number getSelected() { return selected; } /** * The index of the button to appear pre-selected. *

* Defaults to: undefined */ public void setSelected(Number selected) { this.selected = selected; } }