Exemple #1
0
 def __init__(self,parent,data,**kwargs):
     AbstractCanvas.__init__(self,parent,**kwargs)
   
     self.data = None
     self.isAutoScale = True
     self.enable_axis = True
     self.draw_full_axis = True
     self.enable_axis_x = True
     self.enable_axis_y = True
     self.enable_axis_labels = True
     self.enable_grid = True
     self.enable_xy_labels = True
     self.title = "Title"
     self.x_label = "x_label"
     self.y_label = "y_label"
     self.x_slim = []
     self.y_slim = []
     self.x_slim_labels = []
     self.y_slim_labels = []
     self.margin_top,self.margin_left,self.margin_right,self.margin_bottom = 40,50,40,50
     
     self.font_size_title    = stars.PLOT_TITLE_FONT_SIZE
     self.font_size_x_axis   = stars.PLOT_X_AXIS_FONT_SIZE
     self.font_size_y_axis   = stars.PLOT_Y_AXIS_FONT_SIZE
     self.font_size_xy_label = stars.PLOT_XY_LABEL_FONT_SIZE
     
     if kwargs.has_key("title"):
         self.title = kwargs["title"]
         
     self.isValidPlot = True
Exemple #2
0
    def __init__(self, parent, layer, data):
        AbstractCanvas.__init__(self, parent)

        self.setupPieChart()

        for lbl, val in data.iteritems():
            self.addPie(lbl, val)
Exemple #3
0
 def __init__(self, parent, layer, data):
     AbstractCanvas.__init__(self,parent)
     
     self.setupPieChart()
     
     for lbl,val in data.iteritems():
         self.addPie(lbl,val)
Exemple #4
0
    def __init__(self, parent, layers, **kwargs):
        AbstractCanvas.__init__(self, parent, **kwargs)

        try:
            if layers == None or len(layers) == 0:
                raise "The parameter 'layers' is not valid."

            self.parent = parent
            self.layers = layers
            self.layer_dict = {}  # {layer_name: layer}
            self.draw_layers = {}  # {layer: BaseLayer}
            self.hide_layers = {}  # {layer: true}
            self.color_schema_dict = {}  # {layer: color_schema}

            self.fixed_layer = None  # fixed layer that can't be removed
            self.selected_shape_ids = {}  # for brushing-linking
            self.default_label = ""  # default label for layer (tree control)
            self.opaque = 255  # default opaque for all layers

            self.oids = None  # for selecting by Weights
            self.oid_dict = None
            self.neighbor_dict = None
            self.is_selecting_by_weights = False

            title = "Map - %s" % self.layers[0].name
            self.SetTitle(title)

            # drawing all layers
            n = len(self.layers)
            for i, layer in enumerate(self.layers):
                self.layer_dict[layer.name] = layer
                if layer.shape_type == stars.SHP_POINT:
                    self.draw_layers[layer] = PointLayer(self, layer)
                elif layer.shape_type == stars.SHP_LINE:
                    self.draw_layers[layer] = LineLayer(self, layer)
                elif layer.shape_type == stars.SHP_POLYGON:
                    self.draw_layers[layer] = PolygonLayer(self, layer)

                # set color schema
                clr = self.draw_layers[layer].get_fill_color()
                edge_clr = self.draw_layers[layer].get_edge_color()
                color_schema = ColorSchema(colors=[clr],
                                           labels=[self.default_label],
                                           edge_color=edge_clr)
                self.color_schema_dict[layer.name] = color_schema
                # set hidden status
                self.hide_layers[layer] = False

            # for drawing sequences
            self.layer_name_list = [layer.name for layer in self.layers]

            # extent: set for first layer
            xl, yl, xr, yr = self.layers[0].extent
            self.extent = [xl, yl, xr, yr]
            self.map_query_region = self.extent

        except Exception as err:
            self.ShowMsgBox('ShapeMap could not be created. ' +
                            str(err.message))
            self.parentFrame.Close(True)
            return None

        # register event_handler to THE OBSERVER
        self.Register(stars.EVT_OBJS_SELECT, self.OnShapesSelect)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoShapeSelect)
Exemple #5
0
 def __init__(self,parent, layers, **kwargs):
     AbstractCanvas.__init__(self,parent,**kwargs)
     
     try:
         if layers == None or len(layers) == 0:
             raise "The parameter 'layers' is not valid."
         
         self.parent = parent
         self.layers = layers
         self.layer_dict = {}            # {layer_name: layer}
         self.draw_layers = {}           # {layer: BaseLayer}
         self.hide_layers = {}           # {layer: true}
         self.color_schema_dict = {}     # {layer: color_schema}
         
         self.fixed_layer = None         # fixed layer that can't be removed
         self.selected_shape_ids = {}    # for brushing-linking 
         self.default_label = ""         # default label for layer (tree control)
         self.opaque = 255               # default opaque for all layers
        
         self.oids   = None              # for selecting by Weights
         self.oid_dict = None 
         self.neighbor_dict = None
         self.is_selecting_by_weights = False
         
         title = "Map - %s" % self.layers[0].name
         self.SetTitle(title)
         
         # drawing all layers
         n = len(self.layers)
         for i,layer in enumerate(self.layers):
             self.layer_dict[layer.name] = layer
             if layer.shape_type == stars.SHP_POINT:
                 self.draw_layers[layer] = PointLayer(self,layer)
             elif layer.shape_type == stars.SHP_LINE:
                 self.draw_layers[layer] = LineLayer(self,layer)
             elif layer.shape_type == stars.SHP_POLYGON:
                 self.draw_layers[layer] = PolygonLayer(self,layer)        
                 
             # set color schema
             clr = self.draw_layers[layer].get_fill_color()
             edge_clr = self.draw_layers[layer].get_edge_color()
             color_schema = ColorSchema(colors=[clr],labels=[self.default_label],edge_color=edge_clr)
             self.color_schema_dict[layer.name] = color_schema 
             # set hidden status
             self.hide_layers[layer] = False
               
         # for drawing sequences
         self.layer_name_list = [layer.name for layer in self.layers]
         
         # extent: set for first layer
         xl,yl,xr,yr = self.layers[0].extent 
         self.extent = [xl,yl,xr,yr]   
         self.map_query_region = self.extent
         
     except Exception as err:
         self.ShowMsgBox('ShapeMap could not be created. ' + str(err.message))
         self.parentFrame.Close(True)
         return None
     
     # register event_handler to THE OBSERVER
     self.Register(stars.EVT_OBJS_SELECT, self.OnShapesSelect)
     self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoShapeSelect)
Exemple #6
0
    def __init__(self, parent, layer, data,**kwargs):
        AbstractCanvas.__init__(self,parent)
     
        try:
            self.view = None#"DUMMY"
            self.status_bar = None
            self.layer_name = layer.name
            
            self.var_name = data.keys()[0]
            self.data = data[self.var_name]
            
            # create a dict for input data for Brushing
            self.data_dict = dict([(item,i) for i,item in enumerate(self.data)])
            self.selected_pts = []
          
            self.hinge = 1.5
            
            # sort the data
            sorted_data = np.sort(self.data)
            
            # find the median
            self.median = np.median(sorted_data)
            
            # find the upper and lower quantiles:
            # the median of the numbers larger/smaller than the median
            boxplot = pysal.Box_Plot(np.array(self.data))
            bp_bins = boxplot.bins
            
            self.upper_median = boxplot.bins[3]
            self.lower_median = boxplot.bins[1]
            
            self.boxplot_min = boxplot.bins[0]
            self.boxplot_max = boxplot.bins[4]
            
            if sorted_data[0] < self.boxplot_min:
                self.boxplot_min = sorted_data[0]
            if sorted_data[-1] > self.boxplot_max:
                self.boxplot_max = sorted_data[-1]
           
            self.whisker_top = boxplot.bins[4]
            self.whisker_bottom = boxplot.bins[0]
            self.whisker = self.hinge * boxplot.iqr#(self.lower_median - self.upper_median)
    
            if self.whisker == 0:
                raise Exception("Divided by zero error, please check the input data")
          
            self.data_range = self.boxplot_max - self.boxplot_min
            self.ext_range = self.data_range * 0.1
            self.axis_scale = LinearScale(self.boxplot_min - self.ext_range, self.boxplot_max+self.ext_range)
            
            self.isValidPlot = True
        except Exception as err:
            self.ShowMsgBox("""Box plot could not be created! Please select a valid numeric variable.

Details:""" + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
        
        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnObjsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoObjSelect)
Exemple #7
0
    def __init__(self, parent, layer, data, **kwargs):
        AbstractCanvas.__init__(self, parent)

        try:
            self.view = None  #"DUMMY"
            self.status_bar = None
            self.layer_name = layer.name

            self.var_name = data.keys()[0]
            self.data = data[self.var_name]

            # create a dict for input data for Brushing
            self.data_dict = dict([(item, i)
                                   for i, item in enumerate(self.data)])
            self.selected_pts = []

            self.hinge = 1.5

            # sort the data
            sorted_data = np.sort(self.data)

            # find the median
            self.median = np.median(sorted_data)

            # find the upper and lower quantiles:
            # the median of the numbers larger/smaller than the median
            boxplot = pysal.Box_Plot(np.array(self.data))
            bp_bins = boxplot.bins

            self.upper_median = boxplot.bins[3]
            self.lower_median = boxplot.bins[1]

            self.boxplot_min = boxplot.bins[0]
            self.boxplot_max = boxplot.bins[4]

            if sorted_data[0] < self.boxplot_min:
                self.boxplot_min = sorted_data[0]
            if sorted_data[-1] > self.boxplot_max:
                self.boxplot_max = sorted_data[-1]

            self.whisker_top = boxplot.bins[4]
            self.whisker_bottom = boxplot.bins[0]
            self.whisker = self.hinge * boxplot.iqr  #(self.lower_median - self.upper_median)

            if self.whisker == 0:
                raise Exception(
                    "Divided by zero error, please check the input data")

            self.data_range = self.boxplot_max - self.boxplot_min
            self.ext_range = self.data_range * 0.1
            self.axis_scale = LinearScale(self.boxplot_min - self.ext_range,
                                          self.boxplot_max + self.ext_range)

            self.isValidPlot = True
        except Exception as err:
            self.ShowMsgBox(
                """Box plot could not be created! Please select a valid numeric variable.

Details:""" + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnObjsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoObjSelect)