Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self
def setYBound(self, lower, upper):
self.y_lower_bound = lower
self.y_upper_bound = upper
self.rangeAxes[0].setBound(lower, upper)
return self
def setXBound(self, lower, upper):
self.x_auto_range = False
self.x_lower_bound = lower
self.x_upper_bound = upper
return self
class HeatMapChart(XYChart):
ROWS_LIMIT = 10000
COLUMN_LIMIT = 100
def __init__(self, rows_limit, column_limit, **kwargs):
super(HeatMapChart, self).__init__(**kwargs)
self.rows_limit = rows_limit
self.column_limit = column_limit
@staticmethod
def total_points(listOfData):
return sum(map(lambda x: len(x), listOfData))
@staticmethod
def find_step_for_column(row):
step = 2
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')
class TreeMapChart(XYChart):
ROWS_LIMIT = 1000
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 = {}
def add(self, item, weight):
if isinstance(item.chart, XYChart):
self.chart.plots.append(item.chart)
self.chart.weights.append(weight)
elif isinstance(item, list):
for elem in item:
self.chart.add(elem.chart, 1)
else:
raise Exception('CombinedPlot takes XYChart or List of XYChart')
self.model = self.chart.transform()
return self
def __init__(self, **kwargs):
super(Plot, self).__init__()
self.chart = XYChart(**kwargs)
self.model = self.chart.transform()
self.on_msg(self._handle_msg)
self.details = GraphicsActionObject(None, {})
@staticmethod
def total_number(listOfData):
return max(list(map(lambda x: len(x), listOfData)))
def transform(self):
self_copy = copy.copy(self)
self_copy.totalNumberOfPoints = HistogramChart.total_number(self_copy.graphics_list)
self_copy.tooManyRows = self_copy.totalNumberOfPoints >= HistogramChart.ROWS_LIMIT
self_copy.rowsLimitItems = HistogramChart.ROWS_LIMIT
self_copy.numberOfPointsToDisplay = str(HistogramChart.ROWS_LIMIT_T0_INDEX) + " items"
self_copy.graphics_list = list(map(HistogramChart.limit_points, self_copy.graphics_list))
return super(HistogramChart, self_copy).transform()
class CategoryChart(XYChart):
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')
self_copy = copy.copy(self)
self_copy.totalNumberOfPoints = self.total_points(self_copy.graphics_list)
self_copy.rowsLimitItems = self.rows_limit
too_many_points = self_copy.totalNumberOfPoints > self.rows_limit
if too_many_points:
limited_heat_map_data = self.limit_Heatmap(self_copy.graphics_list)
self_copy.graphics_list = limited_heat_map_data
self_copy.numberOfPointsToDisplay = self.total_points(self_copy.graphics_list)
self_copy.numberOfPointsToDisplay = self.total_points(self_copy.graphics_list)
self_copy.tooManyRows = too_many_points
return super(HeatMapChart, self_copy).transform()
class HistogramChart(XYChart):
ROWS_LIMIT = 1000000
ROWS_LIMIT_T0_INDEX = 10000
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')
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')