def create_plot(self): polygon_filter, visible_features_only = self.get_polygon_filter(0) config = {'displayModeBar': False, 'staticPlot': True} if len(self.plot_settings) == 1: plot_factory = PlotFactory(self.plot_settings[0], self, polygon_filter=polygon_filter) self.plot_settings[0].properties['visible_features_only'] = visible_features_only return plot_factory.build_html(config) # to plot many plots in the same figure elif len(self.plot_settings) > 1: # plot list ready to be called within go.Figure pl = [] plot_factory = PlotFactory(self.plot_settings[0], self, polygon_filter=polygon_filter) for current, plot_setting in enumerate(self.plot_settings): polygon_filter, visible_features_only = self.get_polygon_filter(current) plot_setting.properties['visible_features_only'] = visible_features_only factory = PlotFactory(plot_setting, self, polygon_filter=polygon_filter) pl.append(factory.trace[0]) plot_path = plot_factory.build_figures(self.plot_settings[0].plot_type, pl, config=config) with open(plot_path, 'r') as myfile: return myfile.read()
def create_plot(self): if self.linked_map and self.filter_by_map: polygon_filter = FilterRegion(QgsGeometry.fromQPolygonF(self.linked_map.visibleExtentPolygon()), self.linked_map.crs()) visible_features_only = True elif self.filter_by_atlas and self.layout().reportContext().layer() and self.layout().reportContext().feature().isValid(): polygon_filter = FilterRegion(self.layout().reportContext().currentGeometry(), self.layout().reportContext().layer().crs()) visible_features_only = True else: polygon_filter = None visible_features_only = False config = {'displayModeBar': False, 'staticPlot': True} if len(self.plot_settings) == 1: plot_factory = PlotFactory(self.plot_settings[0], self, polygon_filter=polygon_filter) self.plot_settings[0].properties['visible_features_only'] = visible_features_only return plot_factory.build_html(config) # to plot many plots in the same figure elif len(self.plot_settings) > 1: # plot list ready to be called within go.Figure pl = [] plot_factory = PlotFactory(self.plot_settings[0], self, polygon_filter=polygon_filter) for plot_setting in self.plot_settings: plot_setting.properties['visible_features_only'] = visible_features_only factory = PlotFactory(plot_setting, self, polygon_filter=polygon_filter) pl.append(factory.trace[0]) plot_path = plot_factory.build_figures(self.plot_settings[0].plot_type, pl, config=config) with open(plot_path, 'r') as myfile: return myfile.read()