コード例 #1
0
 def __init__(self, *args, **kwargs):
     super(BasedXYGraphics, self).__init__(*args, **kwargs)
     base = getValue(kwargs, 'base')
     if isinstance(base, list):
         self.bases = base
     else:
         self.bases = getValue(kwargs, 'base', 0)
コード例 #2
0
ファイル: legend.py プロジェクト: vital-ai/beakerx
    def __init__(self, **kwargs):
        self.position = getValue(kwargs, 'position')
        self.x = getValue(kwargs, 'x')
        self.y = getValue(kwargs, 'y')

        if self.x is None and self.y is None and self.position is None:
            self.position = LegendPosition.Position.TOP_RIGHT
        elif self.position is not None:
            self.x = None
            self.y = None
コード例 #3
0
 def addTextArea(self, *args, **kwargs):
     textarea = BeakerxTextArea(
         description=self.getDescription(args, kwargs))
     textarea.cols = getValue(kwargs, 'width', -1)
     textarea.rows = getValue(kwargs, 'height', -1)
     textarea.value = getValue(kwargs, 'value', "")
     textarea.placeholder = getValue(kwargs, 'placeholder', "")
     self.children += (textarea, )
     self.components[textarea.description] = textarea
     return textarea
コード例 #4
0
 def __init__(self, **kwargs):
     super(Graphics, self).__init__(**kwargs)
     self.type = self.__class__.__name__
     self.visible = getValue(kwargs, 'visible', True)
     self.yAxis = getValue(kwargs, 'yAxis')
     self.clickTag = getValue(kwargs, 'tag', "")
     self.hasClickAction = self.clickTag != ""
     self.uid = str(uuid.uuid4())
     self.onClickListeners = lambda *args: None
     self.onKeyListeners = {}
     self.keyTags = {}
     self.keys = []
コード例 #5
0
 def __init__(self, **kwargs):
     super(XYChart, self).__init__(**kwargs)
     self.graphics_list = getValue(kwargs, 'graphics', [])
     self.constant_lines = getValue(kwargs, 'constantLines', [])
     self.constant_bands = getValue(kwargs, 'constantBands', [])
     self.texts = getValue(kwargs, 'texts', [])
     self.x_auto_range = getValue(kwargs, 'xAutoRange', True)
     self.x_lower_bound = getValue(kwargs, 'xLowerBound', 0)
     self.x_upper_bound = getValue(kwargs, 'xUpperBound', 0)
     self.log_x = getValue(kwargs, 'logX', False)
     self.x_log_base = getValue(kwargs, 'xLogBase', 10)
     self.lodThreshold = getValue(kwargs, 'lodThreshold')
コード例 #6
0
    def __init__(self, *args, **kwargs):
        super(Stems, self).__init__(*args, **kwargs)
        self.width = getValue(kwargs, 'width', 1.5)
        color = getColor(getValue(kwargs, 'color'))
        if isinstance(color, list):
            self.colors = color
        else:
            self.color = color

        style = getValue(kwargs, 'style')
        if isinstance(style, list):
            self.styles = style
        else:
            self.style = getValue(kwargs, 'style', StrokeType.SOLID)
コード例 #7
0
    def addList(self, *args, **kwargs):
        multi_select = getValue(kwargs, 'multi', True)
        if multi_select:
            list = SelectMultipleWithRows(
                description=self.getDescription(args, kwargs))
        else:
            list = SelectMultipleSingle(
                description=self.getDescription(args, kwargs))
        list.options = self.getOptions(args, kwargs)
        list.size = getValue(kwargs, 'rows', len(list.options))

        self.children += (list, )
        self.components[list.description] = list
        return list
コード例 #8
0
 def __init__(self, **kwargs):
     super(CategoryChart, self).__init__(**kwargs)
     self.type = 'CategoryPlot'
     self.categoryNamesLabelAngle = getValue(kwargs,
                                             'categoryNamesLabelAngle', 0.0)
     self.categoryNames = getValue(kwargs, 'categoryNames', [])
     self.y_upper_margin = getValue(kwargs, 'upperMargin', 0.0)
     self.y_lower_bound = getValue(kwargs, 'lowerMargin', 0.0)
     self.x_upper_margin = getValue(kwargs, 'upperMargin', 0.05)
     self.x_lower_margin = getValue(kwargs, 'lowerMargin', 0.05)
     self.category_margin = getValue(kwargs, 'categoryMargin', 0.2)
     self.y_auto_range_includes_zero = getValue(
         kwargs, 'y_auto_range_includes_zero', False)
     self.y_auto_range = getValue(kwargs, 'y_auto_range', True)
     self.orientation = getValue(kwargs, 'orientation')
コード例 #9
0
 def addCheckBox(self, *args, **kwargs):
     checkbox = BeakerxCheckbox(
         description=self.getDescription(args, kwargs))
     checkbox.value = getValue(kwargs, 'value', False)
     self.children += (checkbox, )
     self.components[checkbox.description] = checkbox
     return checkbox
コード例 #10
0
    def __init__(self, rows_limit=10000, column_limit=100, **kwargs):
        super(HeatMap, self).__init__()
        if 'data' in kwargs:
            data_from_kwargs = kwargs['data']
            if isinstance(data_from_kwargs, DataFrame):
                kwargs['graphics'] = data_from_kwargs.values.tolist()
            else:
                kwargs['graphics'] = data_from_kwargs
        if not 'xLowerMargin' in kwargs:
            kwargs['xLowerMargin'] = 0.0
        if not 'yLowerMargin' in kwargs:
            kwargs['yLowerMargin'] = 0.0
        if not 'yUpperMargin' in kwargs:
            kwargs['yUpperMargin'] = 0.0
        if not 'xUpperMargin' in kwargs:
            kwargs['xUpperMargin'] = 0.0
        if not 'legendLayout' in kwargs:
            kwargs['legendLayout'] = LegendLayout.HORIZONTAL
        if not 'legendPosition' in kwargs:
            kwargs['legendPosition'] = LegendPosition.BOTTOM_RIGHT
        self.rows_limit = rows_limit
        self.column_limit = column_limit
        self.chart = HeatMapChart(self.rows_limit, self.column_limit, **kwargs)
        color = getValue(kwargs, 'color',
                         ["#FF780004", "#FFF15806", "#FFFFCE1F"])

        if isinstance(color, GradientColor):
            self.chart.color = color.color
        else:
            self.chart.color = color

        self.chart.type = 'HeatMap'

        self.model = self.chart.transform()
コード例 #11
0
 def addPasswordField(self, *args, **kwargs):
     password = BeakerxPassword(
         description=self.getDescription(args, kwargs))
     password.size = getValue(kwargs, 'width', -1)
     self.children += (password, )
     self.components[password.description] = password
     return password
コード例 #12
0
 def __init__(self, **kwargs):
     super(YAxis, self).__init__(**kwargs)
     self.label = getValue(kwargs, 'label', '')
     self.auto_range = getValue(kwargs, 'autoRange', True)
     self.auto_range_includes_zero = getValue(kwargs,
                                              'autoRangeIncludesZero', False)
     self.lower_margin = getValue(kwargs, 'lowerMargin', 0.05)
     self.upper_margin = getValue(kwargs, 'upperMargin', 0.05)
     self.lower_bound = getValue(kwargs, 'lowerBound', 0.0)
     self.upper_bound = getValue(kwargs, 'upperBound', 0.0)
     self.use_log = getValue(kwargs, 'logY', False)
     self.log_base = getValue(kwargs, 'logBase', 10.0)
     self.type = 'YAxis'
コード例 #13
0
    def __init__(self, *args, **kwargs):
        super(Points, self).__init__(*args, **kwargs)

        shape = getColor(getValue(kwargs, 'shape'))
        if isinstance(shape, list):
            self.shapes = shape
        else:
            self.shape = getValue(kwargs, 'shape', ShapeType.DEFAULT)

        size = getColor(getValue(kwargs, 'size'))
        if isinstance(size, list):
            self.sizes = size
        else:
            self.size = getValue(kwargs, 'size', 6)

        fill = getColor(getValue(kwargs, 'fill'))
        if isinstance(fill, list):
            self.fills = fill
        else:
            self.fill = fill

        color = getColor(getValue(kwargs, 'color'))
        if isinstance(color, list):
            self.colors = color
        else:
            self.color = color

        outlineColor = getColor(getValue(kwargs, 'outlineColor'))
        if isinstance(outlineColor, list):
            self.outline_colors = outlineColor
        else:
            self.outline_color = outlineColor
コード例 #14
0
 def addComboBox(self, *args, **kwargs):
     dropdown = BeakerxComboBox(
         description=self.getDescription(args, kwargs))
     dropdown.options = self.getOptions(args, kwargs)
     dropdown.original_options = self.getOptions(args, kwargs)
     dropdown.editable = getValue(kwargs, 'editable', False)
     self.children += (dropdown, )
     self.components[dropdown.description] = dropdown
     return dropdown
コード例 #15
0
    def __init__(self, *args, **kwargs):
        super(XYGraphics, self).__init__(**kwargs)
        if len(args) > 0 and isinstance(args[0], pd.Series):
            defX = args[0].index.tolist()
            defY = args[0].tolist()
        else:
            defY = getValue(kwargs, 'y')

            if defY is not None:
                if isinstance(defY, pd.Series) or isinstance(defY, np.ndarray):
                    defY = defY.tolist()
                defX = list(range(0, len(defY)))
            else:
                defX = []

        local_x = getValue(kwargs, 'x', defX)

        if local_x is not None:
            if isinstance(local_x, pd.Series):
                local_x = local_x.tolist()
            self.x = [None] * len(local_x)
            for idx in range(len(local_x)):
                x = local_x[idx]
                if isinstance(x, float) and math.isnan(x):
                    self.x[idx] = "NaN"
                elif isinstance(x, dt.date) or isinstance(x, dt.time):
                    self.x[idx] = date_time_2_millis(x.isoformat())
                elif is_date(x):
                    self.x[idx] = date_time_2_millis(x)
                elif isinstance(x, np.datetime64):
                    self.x[idx] = date_time_2_millis(x.__str__())
                else:
                    self.x[idx] = x

        self.y = defY
        if self.y is not None:
            for idx in range(len(self.y)):
                y = self.y[idx]
                if isinstance(y, float) and math.isnan(y):
                    self.y[idx] = "NaN"

        self.display_name = getValue(kwargs, 'displayName')
        self.lod_filter = getValue(kwargs, 'lodFilter')
        self.tooltips = getValue(kwargs, 'tooltips')
コード例 #16
0
 def __init__(self, **kwargs):
     super(Histogram, self).__init__()
     self.chart = HistogramChart(**kwargs)
     data = getValue(kwargs, 'data', [])
     if len(data) > 1 and isinstance(data[0], list):
         for x in data:
             self.chart.graphics_list.append(x)
     else:
         self.chart.graphics_list.append(data)
     self.model = self.chart.transform()
コード例 #17
0
    def __init__(self, *args, **kwargs):
        super(Bars, self).__init__(*args, **kwargs)

        width = getValue(kwargs, 'width')
        if isinstance(width, list):
            self.widths = width
        else:
            self.width = width

        color = getColor(getValue(kwargs, 'color'))
        if isinstance(color, list):
            self.colors = color
        else:
            self.color = color

        outlineColor = getColor(getValue(kwargs, 'outlineColor'))
        if isinstance(outlineColor, list):
            self.outline_colors = outlineColor
        else:
            self.outline_color = outlineColor
コード例 #18
0
 def __init__(self, **kwargs):
     super(Text, self).__init__(**kwargs)
     self.x = getValue(kwargs, 'x', 0)
     self.y = getValue(kwargs, 'y', 0)
     self.color = getColor(getValue(kwargs, 'color'))
     self.size = getValue(kwargs, 'size', 13)
     self.text = getValue(kwargs, 'text', '')
     self.show_pointer = getValue(kwargs, 'show_pointer', True)
     self.pointer_angle = getValue(kwargs, 'pointerAngle',
                                   (-0.25) * math.pi)
コード例 #19
0
 def __init__(self, **kwargs):
     super(TreeMapChart, self).__init__(**kwargs)
     self.type = 'TreeMap'
     self.showLegend = getValue(kwargs, 'showLegend', True)
     self.title = getValue(kwargs, 'title', "")
     self.colorProvider = getValue(kwargs, 'colorProvider',
                                   RandomColorProvider())
     self.toolTipBuilder = getValue(kwargs, 'toolTipBuilder')
     self.mode = getValue(kwargs, 'mode', Mode.SQUARIFY).value
     self.ratio = getValue(kwargs, 'ratio')
     self.valueAccessor = getValue(kwargs, 'valueAccessor',
                                   ValueAccessor.VALUE)
     self.custom_styles = []
     self.element_styles = {}
     self.graphics_list = getValue(kwargs, 'root')
コード例 #20
0
 def __init__(self, **kwargs):
     super(ConstantLine, self).__init__(**kwargs)
     self.x = self.transform_value_to_number(getValue(kwargs, 'x'))
     self.y = getValue(kwargs, 'y')
     self.color = getColor(getValue(kwargs, 'color'))
     self.width = getValue(kwargs, 'width', 1.5)
     self.style = getValue(kwargs, 'style')
     self.showLabel = getValue(kwargs, 'showLabel')
コード例 #21
0
 def __init__(self, **kwargs):
     super(Chart, self).__init__(**kwargs)
     self.init_width = getValue(kwargs, 'initWidth', 640)
     self.init_height = getValue(kwargs, 'initHeight', 480)
     self.chart_title = getValue(kwargs, 'title')
     self.show_legend = getValue(kwargs, 'showLegend')
     self.use_tool_tip = getValue(kwargs, 'useToolTip', True)
     self.legend_position = getValue(kwargs, 'legendPosition',
                                     LegendPosition.TOP_RIGHT)
     self.legend_layout = getValue(kwargs, 'legendLayout',
                                   LegendLayout.VERTICAL)
     self.type = "Plot"
コード例 #22
0
 def addRadioButtons(self, *args, **kwargs):
     orientation = getValue(kwargs, 'orientation', EasyForm.VERTICAL)
     radio_buttons = RadioButtons(options=self.getOptions(args, kwargs),
                                  description=self.getDescription(
                                      args, kwargs))
     radio_buttons.index = None
     if orientation == EasyForm.VERTICAL:
         self.children += (radio_buttons, )
     else:
         box = BeakerxHBox()
         box.children += (radio_buttons, )
         self.children += (box, )
     self.components[radio_buttons.description] = radio_buttons
     return radio_buttons
コード例 #23
0
 def __init__(self, **kwargs):
     super(CombinedChart, self).__init__(**kwargs)
     self.init_width = getValue(kwargs, 'initWidth', 640)
     self.init_height = getValue(kwargs, 'initHeight', 480)
     self.title = getValue(kwargs, 'title')
     self.x_label = getValue(kwargs, 'xLabel', 'Linear')
     self.plots = getValue(kwargs, 'plots', [])
     self.weights = getValue(kwargs, 'weights', [])
     self.auto_zoom = getValue(kwargs, 'autoZoom')
     self.version = 'groovy'
     self.type = 'CombinedPlot'
     self.y_tickLabels_visible = True
     self.x_tickLabels_visible = True
     self.plot_type = 'Plot'
コード例 #24
0
    def __init__(self, **kwargs):
        self.log = getValue(kwargs, 'log', False)
        if self.log:
            kwargs['logY'] = True

        super(HistogramChart, self).__init__(**kwargs)
        self.type = 'Histogram'
        self.bin_count = getValue(kwargs, 'binCount')
        self.cumulative = getValue(kwargs, 'cumulative', False)
        self.normed = getValue(kwargs, 'normed', False)

        self.range_min = getValue(kwargs, 'rangeMin')
        self.range_max = getValue(kwargs, 'rangeMax')
        self.names = getValue(kwargs, 'names')
        self.displayMode = getValue(kwargs, 'displayMode', "OVERLAP")

        color = getValue(kwargs, 'color')
        if color is not None:
            if isinstance(color, Color):
                self.colors = []
                self.colors.append(color)
            else:
                self.colors = color
コード例 #25
0
    def addCheckBoxes(self, *args, **kwargs):
        layout = BeakerxHBox()
        orientation = getValue(kwargs, 'orientation', EasyForm.VERTICAL)
        if orientation == EasyForm.HORIZONTAL:

            box = BeakerxHBox()
        else:
            box = BeakerxVBox()
        checkbox = BeakerxCheckboxGroup()

        for checkBoxItem in self.getOptions(args, kwargs):
            children = BeakerxCheckbox(description=checkBoxItem)
            checkbox.addChildren(children)
            box.children += (children, )

        layout.children += (
            BeakerxLabel(value=self.getDescription(args, kwargs)),
            box,
        )
        self.children += (layout, )
        self.components[self.getDescription(args, kwargs)] = checkbox
        return layout
コード例 #26
0
 def __init__(self, *args, **kwargs):
     super(Crosshair, self).__init__(*args, **kwargs)
     self.width = getValue(kwargs, 'width')
     self.style = getValue(kwargs, 'style')
     self.color = getColor(getValue(kwargs, 'color'))
コード例 #27
0
 def __init__(self, *args, **kwargs):
     super(Area, self).__init__(*args, **kwargs)
     self.color = getColor(getValue(kwargs, 'color'))
     self.interpolation = getValue(kwargs, 'interpolation')
コード例 #28
0
 def __init__(self, **kwargs):
     super(AbstractChart, self).__init__(**kwargs)
     self.rangeAxes = getValue(kwargs, 'yAxes', [])
     if len(self.rangeAxes) == 0:
         self.rangeAxes.append(YAxis(**kwargs))
     self.domain_axis_label = getValue(kwargs, 'xLabel')
     self.y_label = getValue(kwargs, 'yLabel')
     self.x_lower_margin = getValue(kwargs, 'xLowerMargin', 0.05)
     self.x_upper_margin = getValue(kwargs, 'xUpperMargin', 0.05)
     self.y_auto_range = getValue(kwargs, 'yAutoRange')
     self.y_auto_range_includes_zero = getValue(kwargs,
                                                'yAutoRangeIncludesZero')
     self.y_lower_margin = getValue(kwargs, 'yLowerMargin')
     self.y_upper_margin = getValue(kwargs, 'yUpperMargin')
     self.y_lower_bound = getValue(kwargs, 'yLowerBound')
     self.y_upper_bound = getValue(kwargs, 'yUpperBound')
     self.log_y = getValue(kwargs, 'logY', False)
     self.omit_checkboxes = getValue(kwargs, 'omitCheckboxes', False)
     self.crosshair = getValue(kwargs, 'crosshair')
     self.timezone = getValue(kwargs, 'timeZone')
     self.auto_zoom = getValue(kwargs, 'autoZoom')
コード例 #29
0
    def __init__(self, **kwargs):
        super(CategoryGraphics, self).__init__(**kwargs)
        self.center_series = getValue(kwargs, 'centerSeries', False)
        self.use_tool_tip = getValue(kwargs, 'useToolTip', True)
        self.showItemLabel = getValue(kwargs, 'showItemLabel', False)
        self.outline = getValue(kwargs, 'outline', False)
        self.labelPosition = getValue(kwargs, 'labelPosition', "CENTER")
        self.fills = getValue(kwargs, 'fill')
        self.itemLabels = getValue(kwargs, 'itemLabel')
        self.seriesNames = getValue(kwargs, 'seriesNames')
        self.style = getValue(kwargs, 'style')
        self.size = getValue(kwargs, 'size')

        outline = getValue(kwargs, 'outlineColor')
        if isinstance(outline, list):
            self.outline_colors = outline
        else:
            self.outline_color = outline

        drawOutline = getValue(kwargs, 'drawOutline')
        if isinstance(drawOutline, list):
            self.outlines = drawOutline
        else:
            self.outline = drawOutline

        base = getValue(kwargs, 'base', 0.0)
        if isinstance(base, list):
            self.bases = base
        else:
            self.base = base

        width = getValue(kwargs, 'width')
        if isinstance(width, list):
            self.widths = width
        else:
            self.width = width

        style = getValue(kwargs, 'style')
        if isinstance(style, list):
            self.styles = style
        else:
            self.style = style

        self.value = getValue(kwargs, 'value', [])

        color = getColor(getValue(kwargs, 'color'))
        if isinstance(color, list):
            self.colors = color
        else:
            self.color = color
コード例 #30
0
 def __init__(self, *args, **kwargs):
     super(Line, self).__init__(*args, **kwargs)
     self.width = getValue(kwargs, 'width', 1.5)
     self.style = getValue(kwargs, 'style')
     self.interpolation = getValue(kwargs, 'interpolation')
     self.color = getColor(getValue(kwargs, 'color'))