Example #1
0
 def __init__(self,
              x,
              y,
              label='',
              color=None,
              width=None,
              plot_type='line',
              line_type='solid',
              marker_type=None,
              marker_size=10,
              bar_width=None,
              vector_rotate=None,
              gap_fraction=None):
     self.x = x
     self.y = y
     self.label = to_unicode(label)
     self.plot_type = plot_type
     self.line_type = line_type
     self.marker_type = marker_type
     self.marker_size = marker_size
     self.color = color
     self.fill_color = color
     self.width = width
     self.bar_width = bar_width
     self.vector_rotate = vector_rotate
     self.gap_fraction = gap_fraction
Example #2
0
 def _genXLabel(self, x):
     if self.x_label_format is None:
         return ''
     time_tuple = time.localtime(x)
     # The function time.strftime() still does not support Unicode, so we have to explicitly
     # convert it to UTF8, then back again:
     xlabel = to_unicode(time.strftime(self.x_label_format.encode('utf8'), time_tuple))
     return xlabel
Example #3
0
 def _genXLabel(self, x):
     if self.x_label_format is None:
         return ''
     time_tuple = time.localtime(x)
     # The function time.strftime() still does not support Unicode, so we have to explicitly
     # convert it to UTF8, then back again:
     xlabel = to_unicode(time.strftime(self.x_label_format.encode('utf8'), time_tuple))
     return xlabel
Example #4
0
 def __init__(self, x, y, label='', color=None, width=None, plot_type='line',
              line_type='solid', marker_type=None, marker_size=10, 
              bar_width=None, vector_rotate = None, gap_fraction=None):
     self.x           = x
     self.y           = y
     self.label       = to_unicode(label)
     self.plot_type   = plot_type
     self.line_type   = line_type
     self.marker_type = marker_type
     self.marker_size = marker_size
     self.color       = color
     self.fill_color  = color
     self.width       = width
     self.bar_width   = bar_width
     self.vector_rotate = vector_rotate
     self.gap_fraction = gap_fraction
Example #5
0
    def __init__(self, config_dict):
        """Initialize an instance of GeneralPlot.
        
        config_dict: an instance of ConfigObj, or something that looks like it.
        
        """

        self.line_list = []

        self.xscale = None
        self.yscale = None

        self.anti_alias = int(config_dict.get('anti_alias', 1))

        self.image_width = int(config_dict.get('image_width',
                                               300)) * self.anti_alias
        self.image_height = int(config_dict.get('image_height',
                                                180)) * self.anti_alias
        self.image_background_color = weeplot.utilities.tobgr(
            config_dict.get('image_background_color', '0xf5f5f5'))

        self.chart_background_color = weeplot.utilities.tobgr(
            config_dict.get('chart_background_color', '0xd8d8d8'))
        self.chart_gridline_color = weeplot.utilities.tobgr(
            config_dict.get('chart_gridline_color', '0xa0a0a0'))
        color_list = config_dict.get('chart_line_colors',
                                     ['0xff0000', '0x00ff00', '0x0000ff'])
        fill_color_list = config_dict.get('chart_fill_colors', color_list)
        width_list = config_dict.get('chart_line_width', [1, 1, 1])
        self.chart_line_colors = [
            weeplot.utilities.tobgr(v) for v in color_list
        ]
        self.chart_fill_colors = [
            weeplot.utilities.tobgr(v) for v in fill_color_list
        ]
        self.chart_line_widths = [int(v) for v in width_list]

        self.top_label_font_path = config_dict.get('top_label_font_path')
        self.top_label_font_size = int(
            config_dict.get('top_label_font_size', 10)) * self.anti_alias

        self.unit_label = None
        self.unit_label_font_path = config_dict.get('unit_label_font_path')
        self.unit_label_font_color = weeplot.utilities.tobgr(
            config_dict.get('unit_label_font_color', '0x000000'))
        self.unit_label_font_size = int(
            config_dict.get('unit_label_font_size', 10)) * self.anti_alias
        self.unit_label_position = (10, 0) * self.anti_alias

        self.bottom_label_font_path = config_dict.get('bottom_label_font_path')
        self.bottom_label_font_color = weeplot.utilities.tobgr(
            config_dict.get('bottom_label_font_color', '0x000000'))
        self.bottom_label_font_size = int(
            config_dict.get('bottom_label_font_size', 10)) * self.anti_alias
        self.bottom_label_offset = int(
            config_dict.get('bottom_label_offset', 3))

        self.axis_label_font_path = config_dict.get('axis_label_font_path')
        self.axis_label_font_color = weeplot.utilities.tobgr(
            config_dict.get('axis_label_font_color', '0x000000'))
        self.axis_label_font_size = int(
            config_dict.get('axis_label_font_size', 10)) * self.anti_alias

        self.x_label_format = to_unicode(config_dict.get('x_label_format'))
        self.y_label_format = to_unicode(config_dict.get('y_label_format'))

        # Calculate sensible margins for the given image and font sizes.
        self.lmargin = int(4.0 * self.axis_label_font_size)
        self.rmargin = 20 * self.anti_alias
        self.bmargin = int(
            1.5 * (self.bottom_label_font_size + self.axis_label_font_size) +
            0.5)
        self.tmargin = int(1.5 * self.top_label_font_size + 0.5)
        self.tbandht = int(1.2 * self.top_label_font_size + 0.5)
        self.padding = 3 * self.anti_alias

        self.render_rose = False
        self.rose_width = int(config_dict.get('rose_width', 21))
        self.rose_height = int(config_dict.get('rose_height', 21))
        self.rose_diameter = int(config_dict.get('rose_diameter', 10))
        self.rose_position = (self.lmargin + self.padding + 5,
                              self.image_height - self.bmargin - self.padding -
                              self.rose_height)
        self.rose_rotation = None
        self.rose_label = to_unicode(config_dict.get('rose_label', 'N'))
        self.rose_label_font_path = config_dict.get(
            'rose_label_font_path', self.bottom_label_font_path)
        self.rose_label_font_size = int(
            config_dict.get('rose_label_font_size', 10))
        self.rose_label_font_color = weeplot.utilities.tobgr(
            config_dict.get('rose_label_font_color', '0x000000'))
        self.rose_color = config_dict.get('rose_color')
        if self.rose_color is not None:
            self.rose_color = weeplot.utilities.tobgr(self.rose_color)

        # Show day/night transitions
        self.show_daynight = weeutil.weeutil.tobool(
            config_dict.get('show_daynight', False))
        self.daynight_day_color = weeplot.utilities.tobgr(
            config_dict.get('daynight_day_color', '0xffffff'))
        self.daynight_night_color = weeplot.utilities.tobgr(
            config_dict.get('daynight_night_color', '0xf0f0f0'))
        self.daynight_edge_color = weeplot.utilities.tobgr(
            config_dict.get('daynight_edge_color', '0xefefef'))
        self.daynight_gradient = int(config_dict.get('daynight_gradient', 20))
Example #6
0
 def setUnitLabel(self, unit_label):
     """Set the label to be used to show the units of the plot.
     
     """
     self.unit_label = to_unicode(unit_label)
Example #7
0
 def setBottomLabel(self, bottom_label):
     """Set the label to be put at the bottom of the plot.
     
     """
     self.bottom_label = to_unicode(bottom_label)
Example #8
0
    def __init__(self, config_dict):
        """Initialize an instance of GeneralPlot.
        
        config_dict: an instance of ConfigObj, or something that looks like it.
        
        """
        
        self.line_list = []
        
        self.xscale = None
        self.yscale = None

        self.anti_alias             = int(config_dict.get('anti_alias',  1))

        self.image_width            = int(config_dict.get('image_width',  300)) * self.anti_alias
        self.image_height           = int(config_dict.get('image_height', 180)) * self.anti_alias
        self.image_background_color = weeplot.utilities.tobgr(config_dict.get('image_background_color', '0xf5f5f5'))

        self.chart_background_color = weeplot.utilities.tobgr(config_dict.get('chart_background_color', '0xd8d8d8'))
        self.chart_gridline_color   = weeplot.utilities.tobgr(config_dict.get('chart_gridline_color',   '0xa0a0a0'))
        color_list                  = config_dict.get('chart_line_colors', ['0xff0000', '0x00ff00', '0x0000ff'])
        fill_color_list             = config_dict.get('chart_fill_colors', color_list)
        width_list                  = config_dict.get('chart_line_width',  [1, 1, 1])
        self.chart_line_colors      = [weeplot.utilities.tobgr(v) for v in color_list]
        self.chart_fill_colors      = [weeplot.utilities.tobgr(v) for v in fill_color_list]
        self.chart_line_widths      = [int(v) for v in width_list]

        
        self.top_label_font_path    = config_dict.get('top_label_font_path')
        self.top_label_font_size    = int(config_dict.get('top_label_font_size', 10)) * self.anti_alias

        self.unit_label             = None
        self.unit_label_font_path   = config_dict.get('unit_label_font_path')
        self.unit_label_font_color  = weeplot.utilities.tobgr(config_dict.get('unit_label_font_color', '0x000000'))
        self.unit_label_font_size   = int(config_dict.get('unit_label_font_size', 10)) * self.anti_alias
        self.unit_label_position    = (10 * self.anti_alias, 0)
        
        self.bottom_label_font_path = config_dict.get('bottom_label_font_path')
        self.bottom_label_font_color= weeplot.utilities.tobgr(config_dict.get('bottom_label_font_color', '0x000000'))
        self.bottom_label_font_size = int(config_dict.get('bottom_label_font_size', 10)) * self.anti_alias
        self.bottom_label_offset    = int(config_dict.get('bottom_label_offset', 3))

        self.axis_label_font_path   = config_dict.get('axis_label_font_path')
        self.axis_label_font_color  = weeplot.utilities.tobgr(config_dict.get('axis_label_font_color', '0x000000'))
        self.axis_label_font_size   = int(config_dict.get('axis_label_font_size', 10)) * self.anti_alias

        self.x_label_format         = to_unicode(config_dict.get('x_label_format'))
        self.y_label_format         = to_unicode(config_dict.get('y_label_format'))
        
        # Calculate sensible margins for the given image and font sizes.
        self.lmargin = int(4.0 * self.axis_label_font_size)
        self.rmargin = 20 * self.anti_alias
        self.bmargin = int(1.5 * (self.bottom_label_font_size + self.axis_label_font_size) + 0.5)
        self.tmargin = int(1.5 * self.top_label_font_size + 0.5)
        self.tbandht = int(1.2 * self.top_label_font_size + 0.5)
        self.padding =  3 * self.anti_alias

        self.render_rose            = False
        self.rose_width             = int(config_dict.get('rose_width', 21))
        self.rose_height            = int(config_dict.get('rose_height', 21))
        self.rose_diameter          = int(config_dict.get('rose_diameter', 10))
        self.rose_position          = (self.lmargin + self.padding + 5, self.image_height - self.bmargin - self.padding - self.rose_height)
        self.rose_rotation          = None
        self.rose_label             = to_unicode(config_dict.get('rose_label', 'N'))
        self.rose_label_font_path   = config_dict.get('rose_label_font_path', self.bottom_label_font_path)
        self.rose_label_font_size   = int(config_dict.get('rose_label_font_size', 10))  
        self.rose_label_font_color  = weeplot.utilities.tobgr(config_dict.get('rose_label_font_color', '0x000000'))
        self.rose_color             = config_dict.get('rose_color')
        if self.rose_color is not None:
            self.rose_color = weeplot.utilities.tobgr(self.rose_color)

        # Show day/night transitions
        self.show_daynight          = weeutil.weeutil.tobool(config_dict.get('show_daynight', False))
        self.daynight_day_color     = weeplot.utilities.tobgr(config_dict.get('daynight_day_color', '0xffffff'))
        self.daynight_night_color   = weeplot.utilities.tobgr(config_dict.get('daynight_night_color', '0xf0f0f0'))
        self.daynight_edge_color    = weeplot.utilities.tobgr(config_dict.get('daynight_edge_color', '0xefefef'))
        self.daynight_gradient      = int(config_dict.get('daynight_gradient', 20))
Example #9
0
 def setUnitLabel(self, unit_label):
     """Set the label to be used to show the units of the plot.
     
     """
     self.unit_label = to_unicode(unit_label)
Example #10
0
 def setBottomLabel(self, bottom_label):
     """Set the label to be put at the bottom of the plot.
     
     """
     self.bottom_label = to_unicode(bottom_label)