Exemplo n.º 1
0
    def __init__(self, color_1: str, color_2: str):
        super().__init__()

        self.model = Dazzle.GraphModel(value_min=0.0, value_max=100.0)
        self.model.add_column(Dazzle.GraphColumn(name="0", value_type=float))
        self.model.add_column(Dazzle.GraphColumn(name="1", value_type=float))

        self.add_renderer(
            Dazzle.GraphLineRenderer(column=0, stroke_color=color_1))
        self.add_renderer(
            Dazzle.GraphLineRenderer(column=1, stroke_color=color_2))
        self.set_model(self.model)
Exemplo n.º 2
0
    def _init_graphs(self) -> None:
        if is_dazzle_version_supported():
            self._graph_views: Dict[GraphType, Tuple[Gtk.Label, Gtk.Label, Gtk.Label]] = {}
            self._graph_models: Dict[GraphType, Dazzle.GraphModel] = {}
            for graph_type in GraphType:
                self._graph_container: Gtk.Frame = self._builder.get_object(f'graph_container_{graph_type.value}')
                self._graph_views[graph_type] = (self._builder.get_object(f'graph_min_value_{graph_type.value}'),
                                                 self._builder.get_object(f'graph_max_value_{graph_type.value}'),
                                                 self._builder.get_object(f'graph_max_axis_{graph_type.value}'))
                graph_views = Dazzle.GraphView()
                graph_model = Dazzle.GraphModel()
                graph_renderer = GraphStackedRenderer()
                graph_views.set_hexpand(True)
                graph_views.props.height_request = 80
                graph_renderer.set_line_width(1.5)
                stroke_color = Gdk.RGBA()
                stroke_color.parse(GRAPH_COLOR_HEX)
                stacked_color = Gdk.RGBA()
                stacked_color.parse(GRAPH_COLOR_HEX)
                stacked_color.alpha = 0.5
                graph_renderer.set_stroke_color_rgba(stroke_color)
                graph_renderer.set_stacked_color_rgba(stacked_color)
                graph_model.set_timespan(MONITORING_INTERVAL * 1000 * 1000)
                graph_model.set_max_samples(MONITORING_INTERVAL / self._presenter.get_refresh_interval() + 1)
                graph_model.props.value_max = 100.0
                graph_model.props.value_min = 0.0

                column_ram = Dazzle.GraphColumn().new("Col0", TYPE_DOUBLE)
                graph_model.add_column(column_ram)

                graph_views.set_model(graph_model)
                graph_views.add_renderer(graph_renderer)

                self._graph_container.add(graph_views)

                graph_model_iter = graph_model.push(GLib.get_monotonic_time())
                graph_model.iter_set(graph_model_iter, 0, 0.0)

                self._graph_models[graph_type] = graph_model