Okay. Trying to show a legend within the pychart gtk control isn't going to be very good.

This commit is contained in:
james 2016-04-08 04:45:26 -06:00
parent 7942621856
commit ed2ee1b3dd
3 changed files with 17 additions and 12 deletions

View File

@ -1,3 +1,5 @@
Undo the shit i changed with pychart gtk
Make sure we're all good to use the images:
images/synchronize.png
Downloaded at: https://www.iconfinder.com/iconsets/UltimateGnome

View File

@ -472,7 +472,7 @@ class oxcSERVER(oxcSERVERvm, oxcSERVERhost, oxcSERVERproperties,
# Default three hours of period
self.halt_performance = False
# TODO: James - Commented this out
# TODO: James - Commented this out GUI Has changed
#for widget in ["scrwin_cpuusage", "scrwin_memusage", "scrwin_netusage", "scrwin_diskusage"]:
# widget = self.wine.builder.get_object(widget).get_children()[0]
# if widget.get_children():
@ -544,8 +544,8 @@ class oxcSERVER(oxcSERVERvm, oxcSERVERhost, oxcSERVERproperties,
chart[name].xaxis.set_tic_format_function(show_tic)
chart[name].yaxis.set_position(7)
chart[name].connect("datapoint-hovered", hovered)
chart[name].legend.set_visible(True)
chart[name].legend.set_position(line_chart.POSITION_RIGHT)
chart[name].legend.set_visible(False)
chart[name].legend.set_position(line_chart.POSITION_BOTTOM_LEFT)
chart[name].set_padding(100)
chart[name].yaxis.set_label("kBps")
chart["cpu"].yaxis.set_label("%")
@ -563,10 +563,11 @@ class oxcSERVER(oxcSERVERvm, oxcSERVERhost, oxcSERVERproperties,
chart["cpu"].add_graph(graph[key])
chart["cpu"].set_size_request(len(data)*20, 250)
# gobject.idle_add(lambda: self.wine.builder.get_object("scrwin_cpuusage").add(chart["cpu"]) and False)
# gobject.idle_add(lambda: self.wine.builder.get_object("scrwin_cpuusage").show_all() and False)
self.wine.builder.get_object("scrwin_cpuusage").add(chart["cpu"])
self.wine.builder.get_object("scrwin_cpuusage").show_all()
gobject.idle_add(lambda: self.wine.builder.get_object("scrwin_cpuusage").add(chart["cpu"]) and False)
gobject.idle_add(lambda: self.wine.builder.get_object("scrwin_cpuusage").show_all() and False)
# self.wine.builder.get_object("scrwin_cpuusage").add(chart["cpu"])
# self.wine.builder.get_object("scrwin_cpuusage").show_all()
# Memory
if "memory_internal_free" in rrdinfo and "memory" in rrdinfo:

View File

@ -403,8 +403,7 @@ class LineChart(chart.Chart):
graph_rect = rect
if (self.legend.get_property("visible") == True) and (self.legend.get_position() == POSITION_RIGHT):
new_width = 400
graph_rect.width -= 300
graph_rect.width -= self.legend.last_width
if self.graphs and data_available:
self.grid.draw(context, graph_rect, self.xaxis, self.yaxis)
@ -2023,6 +2022,7 @@ class Legend(ChartObject):
ChartObject.__init__(self)
self._show = False
self._position = POSITION_TOP_RIGHT
self.last_width = 0
def do_get_property(self, property):
if property.name == "visible":
@ -2063,7 +2063,8 @@ class Legend(ChartObject):
total_height += rheight + 6
total_width = max(total_width, rwidth)
self.last_width = total_width
total_width += 18 + 20
if self._position == POSITION_TOP_RIGHT:
x = rect.width - total_width - 16
@ -2082,8 +2083,9 @@ class Legend(ChartObject):
y = 16
elif self._position == POSITION_RIGHT:
x = rect.width - total_width - 16
y = (rect.height - 16 - total_height) / 2
# Bah. This is so broken and horrible and just wont work for small graphs
x = rect.width - (total_width/2) - 16
y = (rect.height - total_height) / 2
context.set_antialias(cairo.ANTIALIAS_NONE)
context.set_source_rgb(1, 1, 1)