Beispiel #1
0
    def graphpoints(self, *args):
        hotendactual_plot = SmoothLinePlot(color=[1, 0, 0, 1])
        hotendtarget_plot = MeshLinePlot(color=[1, 0, 0, .75])
        bedactual_plot = SmoothLinePlot(color=[0, 0, 1, 1])
        bedtarget_plot = MeshLinePlot(color=[0, 0, 1, .75])
        # Build list of plot points tuples from temp and time lists
        # FIXME - Need to reduce the number of points on the graph. 360 is overkill
        hotendactual_points_list = []
        hotendtarget_points_list = []
        bedactual_points_list = []
        bedtarget_points_list = []
        for i in range(360):
            hotendactual_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, hotendactual_list[i]))
            hotendtarget_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, hotendtarget_list[i]))
            bedactual_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, bedactual_list[i]))
            bedtarget_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, bedtarget_list[i]))

        # Remove all old plots from the graph before drawing new ones
        for plot in self.my_graph.plots:
            self.my_graph.remove_plot(plot)

        # Draw the new graphs
        hotendactual_plot.points = hotendactual_points_list
        self.my_graph.add_plot(hotendactual_plot)
        hotendtarget_plot.points = hotendtarget_points_list
        self.my_graph.add_plot(hotendtarget_plot)
        bedactual_plot.points = bedactual_points_list
        self.my_graph.add_plot(bedactual_plot)
        bedtarget_plot.points = bedtarget_points_list
        self.my_graph.add_plot(bedtarget_plot)
Beispiel #2
0
    def get_weekly_mistakes(self):
        if self.flag == 5:
            return

        self.flag = 5

        week_list = get_all_weeks()

        week_om_cost = get_monthly_mistake_tuple()[0]
        week_cm_cost = get_monthly_mistake_tuple()[1]
        points_om_list = self.make_pairs(week_list, week_om_cost)
        points_cm_list = self.make_pairs(week_list, week_cm_cost)
        plot_om = SmoothLinePlot(
            color=[255 / 255.0, 125 / 255.0, 125 / 255.0, 1])
        plot_om.points = points_om_list
        plot_cm = SmoothLinePlot(
            color=[125 / 255.0, 177 / 255.0, 255 / 255.0, 1])
        plot_cm.points = points_cm_list

        # print("om:" + str(points_om_list)) #Blue
        # print("cm:" + str(points_cm_list)) # Red

        # week_mistakes = get_weekly_mistake_num()
        # points_list = self.make_pairs(week_list, week_mistakes)
        # print(points_list)

        plot = SmoothLinePlot(color=[1, 0, 0, 1])
        self.graph6.add_plot(plot_om)
        self.graph6.add_plot(plot_cm)
        self.ids['graph3'].remove_widget(self.graph7)
        self.ids['graph3'].remove_widget(self.graph5)
        self.ids['graph3'].add_widget(self.graph6)
Beispiel #3
0
    def graphpoints(self, *args):
        hotendactual_plot = SmoothLinePlot(color=[1, 0, 0, 1])
        hotendtarget_plot = MeshLinePlot(color=[1, 0, 0, .75])
        bedactual_plot = SmoothLinePlot(color=[0, 0, 1, 1])
        bedtarget_plot = MeshLinePlot(color=[0, 0, 1, .75])
        #Build list of plot points tuples from temp and time lists
        ##FIXME - Need to reduce the number of points on the graph. 360 is overkill
        hotendactual_points_list = []
        hotendtarget_points_list = []
        bedactual_points_list = []
        bedtarget_points_list = []
        for i in range(360):
            hotendactual_points_list.append( (graphtime_list[i]/1000.0*-1, hotendactual_list[i]) )
            hotendtarget_points_list.append( (graphtime_list[i]/1000.0*-1, hotendtarget_list[i]) )
            bedactual_points_list.append( (graphtime_list[i]/1000.0*-1, bedactual_list[i]) )
            bedtarget_points_list.append( (graphtime_list[i]/1000.0*-1, bedtarget_list[i]) )

        #Remove all old plots from the graph before drawing new ones
        for plot in self.my_graph.plots:
            self.my_graph.remove_plot(plot)

        #Draw the new graphs
        hotendactual_plot.points = hotendactual_points_list
        self.my_graph.add_plot(hotendactual_plot)
        hotendtarget_plot.points = hotendtarget_points_list
        self.my_graph.add_plot(hotendtarget_plot)
        bedactual_plot.points = bedactual_points_list
        self.my_graph.add_plot(bedactual_plot)
        bedtarget_plot.points = bedtarget_points_list
        self.my_graph.add_plot(bedtarget_plot)
Beispiel #4
0
    def graphpoints(self, *args):
        global g_hotend_actual
        global g_hotend_target
        global g_bed_actual
        global g_bed_target
        hotendactual_plot = SmoothLinePlot(color=[1, 0, 0, 1])
        hotendtarget_plot = MeshLinePlot(color=[1, 0, 0, .75])
        bedactual_plot = SmoothLinePlot(color=[0, 0, 1, 1])
        bedtarget_plot = MeshLinePlot(color=[0, 0, 1, .75])

        # Update temperature graph arrays with new data
        hotendactual_list.popleft()
        hotendactual_list.append(g_hotend_actual)
        hotendtarget_list.popleft()
        hotendtarget_list.append(g_hotend_target)
        bedactual_list.popleft()
        bedactual_list.append(g_bed_actual)
        bedtarget_list.popleft()
        bedtarget_list.append(g_bed_target)

        # Build list of plot points tuples from temp and time lists
        hotendactual_points_list = []
        hotendtarget_points_list = []
        bedactual_points_list = []
        bedtarget_points_list = []
        for i in range(temperature_list_size):
            hotendactual_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, int(hotendactual_list[i])))
            hotendtarget_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, int(hotendtarget_list[i])))
            bedactual_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, int(bedactual_list[i])))
            bedtarget_points_list.append(
                (graphtime_list[i] / 1000.0 * -1, int(bedtarget_list[i])))

        # Remove all old plots from the graph before drawing new ones
        while (len(self.my_graph.plots) != 0):
            # TODO - add a counter so we can abort after a certain number of tries.
            self.my_graph.remove_plot(self.my_graph.plots[0])

        # Draw the new graphs
        hotendactual_plot.points = hotendactual_points_list
        self.my_graph.add_plot(hotendactual_plot)
        hotendtarget_plot.points = hotendtarget_points_list
        self.my_graph.add_plot(hotendtarget_plot)
        bedactual_plot.points = bedactual_points_list
        self.my_graph.add_plot(bedactual_plot)
        bedtarget_plot.points = bedtarget_points_list
        self.my_graph.add_plot(bedtarget_plot)
Beispiel #5
0
    def get_daily_cost(self):
        if self.flag == 1:
            return

        self.flag = 1
        day_list = days_to_ints(get_all_days())
        my_day_list = {}

        for (m, d) in day_list:
            if m in my_day_list:
                my_day_list[m].append(d)
            else:
                my_day_list[m] = []
                my_day_list[m].append(d)

        new_day_list = []

        for eachMonth in my_day_list:
            for eachDay in my_day_list[eachMonth]:
                new_day_list.append(eachDay + (eachMonth - 1) * 30)

        day_cost = get_daily_cost()

        points_list = self.make_pairs(new_day_list, day_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list

        self.graph8.add_plot(plot)

        self.ids['graph1'].remove_widget(self.graph2)
        self.ids['graph1'].remove_widget(self.graph1)
        self.ids['graph1'].add_widget(self.graph8)
 def __init__(self, **kwargs):
     super(BElGenLiveGraph, self).__init__(**kwargs)
     graph = Graph(
         xlabel="X",
         ylabel="Y",
         x_ticks_minor=5,
         x_ticks_major=25,
         y_ticks_major=1,
         y_grid_label=True,
         x_grid_label=True,
         padding=5,
         x_grid=True,
         y_grid=True,
         xmin=-0,
         xmax=10,
         ymin=-12,
         ymax=12,
     )
     plot = SmoothLinePlot(color=[0.49, 0.98, 1, 1])
     with open("adclog.txt") as fh:
         coords = []
         for line in fh:
             line = line.strip("()\n")  # Get rid of the newline and parentheses
             line = line.split(", ")  # Split into two parts
             c = tuple(float(x) for x in line)  # Make the tuple
             coords.append(c)
     plot.points = coords
     graph.add_plot(plot)
     self.add_widget(graph)
Beispiel #7
0
    def get_daily_mistakes(self):
        if self.flag == 4:
            return

        self.flag = 4

        day_list = days_to_ints(get_all_days())
        my_day_list = {}

        for (m, d) in day_list:
            if m in my_day_list:
                my_day_list[m].append(d)
            else:
                my_day_list[m] = []
                my_day_list[m].append(d)

        new_day_list = []

        for eachMonth in my_day_list:
            for eachDay in my_day_list[eachMonth]:
                new_day_list.append(eachDay + (eachMonth - 1) * 30)

        day_om_cost = get_daily_mistake_tuple()[0]
        day_cm_cost = get_daily_mistake_tuple()[1]
        points_om_list = self.make_pairs(new_day_list, day_om_cost)
        points_cm_list = self.make_pairs(new_day_list, day_cm_cost)
        plot_om = SmoothLinePlot(
            color=[255 / 255.0, 125 / 255.0, 125 / 255.0, 1])
        plot_om.points = points_om_list
        plot_cm = SmoothLinePlot(
            color=[125 / 255.0, 177 / 255.0, 255 / 255.0, 1])
        plot_cm.points = points_cm_list

        print("om:" + str(points_om_list))  #Blue
        print("cm:" + str(points_cm_list))  # Red

        self.graph7.add_plot(plot_om)
        self.graph7.add_plot(plot_cm)
        self.ids['graph3'].remove_widget(self.graph5)
        self.ids['graph3'].remove_widget(self.graph6)
        self.ids['graph3'].add_widget(self.graph7)
Beispiel #8
0
    def update_plot(self, event=False):
        profile_scrollview = self.get_widget(self, 'profile_scrollview')
        profile_gridlayout = self.get_widget(profile_scrollview, 'profile_gridlayout')
        box = self.get_widget(profile_gridlayout, 'box')
        profile_graph = self.get_widget(box, 'profile_graph')

        profile_plot = SmoothLinePlot(color=[1,0,0,1])
        profile_plot.points = [(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()] #(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()
        # print profile_plot.points
        for plot in profile_graph.plots:
            profile_graph.remove_plot(plot)
        profile_graph.add_plot(profile_plot)
Beispiel #9
0
    def update_plot(self, event=False):
        monitor_scrollview = self.get_widget(self, 'monitor_scrollview')
        monitor_gridlayout = self.get_widget(monitor_scrollview, 'monitor_gridlayout')
        box = self.get_widget(monitor_gridlayout, 'box')
        monitor_graph = self.get_widget(box, 'monitor_graph')

        profile_plot = SmoothLinePlot(color=[1,0,0,1])
        profile_plot.points = [(float(x[1]['time']), float(x[1]['temperature'])) for x in self.unfilled_profile.iterrows()] #(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()
        # brew_plot = SmoothLinePlot(color=[0,1,0,1])
        # brew_plot.points = [(float(x[1][0]), float(x[1][1])) for x in self.brew_df.iterrows()]
        for plot in monitor_graph.plots:
            monitor_graph.remove_plot(plot)
        monitor_graph.add_plot(profile_plot)
Beispiel #10
0
    def create_kivy_plot(self,
                         series=np.array(range(12)),
                         label_y='Average Response Time'):
        if self.graph_figure:
            self.destroy()

        series_len = len(series)
        if series_len == 0:
            return False
        max_y = max(series)
        min_y = min(series)
        #arg_max_y = series.index(max_y) # use this to label max and min...
        #arg_min_y = series.index(min_y) # with their resp time stamp
        ticks_y = round(max_y / 10., 2)

        graph_theme = {
            'label_options': {
                'color': rgb('444444'),  # color of tick labels and titles
                'bold': True
            },
            'background_color': rgb('000000'),  # back ground color of canvas
            'tick_color': rgb('444444'),  # ticks and grid
            'border_color': rgb('444444')
        }  # border drawn around each graph

        self.graph_figure = Graph(xlabel='Last {} games'.format(series_len),
                                  ylabel=label_y,
                                  x_ticks_minor=5,
                                  x_ticks_major=5,
                                  y_ticks_major=ticks_y,
                                  y_grid_label=True,
                                  x_grid_label=True,
                                  padding=10,
                                  x_grid=False,
                                  y_grid=True,
                                  xmin=0,
                                  xmax=series_len,
                                  ymin=0,
                                  ymax=int(1.2 * max_y + 1),
                                  _with_stencilbuffer=False,
                                  **graph_theme)
        plot = SmoothLinePlot(color=next(self.colors))  #mode='line_strip',
        plot.points = [(x, series[x - 1]) for x in range(1, len(series) + 1)]
        self.graph_figure.add_plot(plot)

        self.add_widget(self.graph_figure)
Beispiel #11
0
    def get_weekly_cost(self):
        if self.flag == 2:
            return

        self.flag = 2

        week_list = get_all_weeks()
        week_cost = get_weekly_cost()
        points_list = self.make_pairs(week_list, week_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list
        self.graph2.add_plot(plot)
        self.ids['graph1'].remove_widget(self.graph8)
        self.ids['graph1'].remove_widget(self.graph1)
        self.ids['graph1'].add_widget(self.graph2)
Beispiel #12
0
    def get_monthly_cost(self):
        if self.flag == 3:
            return

        self.flag = 3

        month_list = get_all_months()
        month_cost = get_monthly_cost()
        points_list = self.make_pairs(month_list, month_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list
        self.graph1.add_plot(plot)
        self.ids['graph1'].remove_widget(self.graph8)
        self.ids['graph1'].remove_widget(self.graph2)
        self.ids['graph1'].add_widget(self.graph1)
 def __init__(self, **kwargs):
     super(BElGenLiveGraph, self).__init__(**kwargs)
     graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
                   x_ticks_major=25, y_ticks_major=1,
                   y_grid_label=True, x_grid_label=True, padding=5,
                   x_grid=True, y_grid=True, xmin=-0, xmax=10, ymin=-12,
                   ymax=12)
     plot = SmoothLinePlot(color=[0.49, 0.98, 1, 1])
     with open("adclog.txt") as fh:
         coords = []
         for line in fh:
             line = line.strip('()\n')
             line = line.split(', ')
             c = tuple(float(x) for x in line)
             coords.append(c)
     plot.points = coords
     graph.add_plot(plot)
     self.add_widget(graph)
        def build(self):
            layout = BoxLayout(orientation='vertical')

            graph_theme = {
                'label_options': {
                    'color': rgb('444444'),  # color of tick labels and titles
                    'bold': True
                },
                'background_color':
                rgb('f8f8f2'),  # back ground color of canvas
                'tick_color': rgb('808080'),  # ticks and grid
                'border_color': rgb('808080')
            }  # border drawn around each graph

            x_values = list(range(100))
            y_values = [123.0 + random() for x in x_values]
            end_date = date(2017, 2, 1)
            one_day = timedelta(1)
            date_values = [end_date - one_day * i for i in x_values]
            date_values.reverse()
            time_series = zip(x_values, y_values)

            graph1 = TimeSeriesGraph(
                date_values,
                date_label_format='%b',
                xlabel='example 1',
                ylabel='some y labels',
                #x_ticks_minor=5,
                x_ticks_major='month',
                y_ticks_major=0.1,
                y_grid_label=True,
                x_grid_label=True,
                padding=5,
                xlog=False,
                ylog=False,
                x_grid=True,
                y_grid=True,
                #xmin=-50,
                #xmax=50,
                ymin=123,
                ymax=124,
                font_size='12sp',
                **graph_theme)

            plot1 = SmoothLinePlot(color=rgb('7dac9f'))
            plot1.points = time_series
            graph1.add_plot(plot1)

            plot3 = SmoothLinePlot(color=rgb('dc7062'))
            y_values = [123.0 + random() for x in x_values]
            time_series = zip(x_values, y_values)
            plot3.points = time_series
            graph1.add_plot(plot3)

            layout.add_widget(graph1)

            y_values = [123.0 + random() for x in x_values]

            graph2 = TimeSeriesGraph(
                date_values,
                date_label_format='%b-%d',
                xlabel='example 2',
                ylabel='some y labels',
                x_ticks_minor=5,
                x_ticks_major=30,
                y_ticks_major=0.1,
                y_grid_label=True,
                x_grid_label=True,
                padding=5,
                xlog=False,
                ylog=False,
                x_grid=True,
                y_grid=True,
                #xmin=-50,
                #xmax=50,
                ymin=123,
                ymax=124,
                font_size='12sp',
                **graph_theme)

            plot2 = SmoothLinePlot(color=rgb('7dac9f'))
            plot2.points = zip(x_values, y_values)
            graph2.add_plot(plot2)

            layout.add_widget(graph2)

            s = Screen(name="test1")
            s.add_widget(layout)

            sm = ScreenManager()
            sm.add_widget(s)

            return sm