diff --git a/deluge/plugins/graph/graph/pycha_compare.html b/deluge/plugins/graph/graph/pycha_compare.html
new file mode 100644
index 000000000..db5e2e594
--- /dev/null
+++ b/deluge/plugins/graph/graph/pycha_compare.html
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/deluge/plugins/graph/graph/pycha_line_deluge.py b/deluge/plugins/graph/graph/pycha_line_deluge.py
new file mode 100644
index 000000000..76e04fcae
--- /dev/null
+++ b/deluge/plugins/graph/graph/pycha_line_deluge.py
@@ -0,0 +1,113 @@
+# Copyright (c) 2007-2008 by Lorenzo Gil Sanchez
+#
+# This file is part of PyCha.
+#
+# PyCha is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PyCha is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with PyCha. If not, see .
+
+from pycha.chart import Chart
+from pycha.color import hex2rgb, clamp
+
+class LineChart(Chart):
+
+ def __init__(self, surface=None, options={}):
+ super(LineChart, self).__init__(surface, options)
+ self.points = []
+
+ def _updateChart(self):
+ """Evaluates measures for line charts"""
+ self.points = []
+
+ for i, (name, store) in enumerate(self.datasets):
+ for item in store:
+ xval, yval = item
+ x = (xval - self.minxval) * self.xscale
+ y = 1.0 - (yval - self.minyval) * self.yscale
+ point = Point(x, y, xval, yval, name)
+
+ if 0.0 <= point.x <= 1.0 and 0.0 <= point.y <= 1.0:
+ self.points.append(point)
+
+ def _renderChart(self, cx):
+ """Renders a line chart"""
+ def preparePath(storeName):
+ cx.new_path()
+ firstPoint = True
+ lastX = None
+ if self.options.shouldFill:
+ # Go to the (0,0) coordinate to start drawing the area
+ cx.move_to(self.area.x, self.area.y + self.area.h)
+
+ for point in self.points:
+ if point.name == storeName:
+ if not self.options.shouldFill and firstPoint:
+ # starts the first point of the line
+ cx.move_to(point.x * self.area.w + self.area.x,
+ point.y * self.area.h + self.area.y)
+ firstPoint = False
+ continue
+ cx.line_to(point.x * self.area.w + self.area.x,
+ point.y * self.area.h + self.area.y)
+ # we remember the last X coordinate to close the area
+ # properly. See bug #4
+ lastX = point.x
+
+ if self.options.shouldFill:
+ # Close the path to the start point
+ cx.line_to(lastX * self.area.w + self.area.x,
+ self.area.h + self.area.y)
+ cx.line_to(self.area.x, self.area.y + self.area.h)
+ cx.close_path()
+ else:
+ cx.set_source_rgb(*self.options.colorScheme[storeName])
+ cx.stroke()
+
+
+ cx.save()
+ cx.set_line_width(self.options.stroke.width)
+ if self.options.shouldFill:
+ def drawLine(storeName):
+ if self.options.stroke.shadow:
+ # draw shadow
+ cx.save()
+ cx.set_source_rgba(0, 0, 0, 0.15)
+ cx.translate(2, -2)
+ preparePath(storeName)
+ cx.fill()
+ cx.restore()
+
+ # fill the line
+ cx.set_source_rgb(*self.options.colorScheme[storeName])
+ preparePath(storeName)
+ cx.fill()
+
+ if not self.options.stroke.hide:
+ # draw stroke
+ cx.set_source_rgb(*hex2rgb(self.options.stroke.color))
+ preparePath(storeName)
+ cx.stroke()
+
+ # draw the lines
+ for key in self._getDatasetsKeys():
+ drawLine(key)
+ else:
+ for key in self._getDatasetsKeys():
+ preparePath(key)
+
+ cx.restore()
+
+class Point(object):
+ def __init__(self, x, y, xval, yval, name):
+ self.x, self.y = x, y
+ self.xval, self.yval = xval, yval
+ self.name = name
diff --git a/deluge/plugins/graph/graph/test.py b/deluge/plugins/graph/graph/test.py
index 8081a3d94..49664d1fb 100644
--- a/deluge/plugins/graph/graph/test.py
+++ b/deluge/plugins/graph/graph/test.py
@@ -4,7 +4,7 @@ from graph import NetworkGraph
def test_sync():
- if 1:
+ if 0:
upload = sclient.graph_get_upload()
download = sclient.graph_get_download()
print upload
@@ -53,8 +53,8 @@ def test_write():
test_sync()
-test_async()
-test_write()
+#test_async()
+#test_write()
diff --git a/deluge/plugins/graph/graph/test_pycha.py b/deluge/plugins/graph/graph/test_pycha.py
index b3657bda7..1383d5026 100644
--- a/deluge/plugins/graph/graph/test_pycha.py
+++ b/deluge/plugins/graph/graph/test_pycha.py
@@ -5,71 +5,111 @@ good :
bad :
* docs are sparse.
+
+Make it look like the deluge graph:
#Is it easy to hack in a n'th line color option? --> probably just not documented... ->YEP
*fill is broken? , no opacity. -> pycha needs to be hacked to mimic the current deluge style.
*how to set line-width?
-
-
-
+*kbps label on y axis
"""
upload = [66804, 66915, 66974, 67447, 67540, 67318, 67320, 67249, 66659, 66489, 67027, 66914, 66802, 67303, 67654, 67643, 67763, 67528, 67523, 67431, 67214, 66939, 67316, 67020, 66881, 67103, 67377, 67141, 67366, 67492, 67375, 67203, 67056, 67010, 67029, 66741, 66695, 66868, 66805, 66264, 66249, 66317, 66459, 66306, 66681, 66954, 66662, 66278, 65921, 65695, 65681, 65942, 66000, 66140, 66424, 66480, 66257, 66271, 66145, 65854, 65568, 65268, 65112, 65050, 65027, 64676, 64655, 64178, 64386, 63979, 63271, 62746, 62337, 62297, 62496, 62902, 63801, 64121, 62957, 62921, 63051, 62644, 63240, 64107, 63968, 63987, 63644, 63263, 63153, 62999, 62843, 62777, 63101, 63078, 63178, 63126, 63401, 62630, 62451, 62505, 62254, 61485, 61264, 60937, 60568, 61011, 61109, 60325, 60196, 59640, 59619, 59514, 60813, 60572, 61632, 61689, 63365, 64583, 66396, 67179, 68209, 68295, 67674, 67559, 67195, 66178, 65632, 66124, 66456, 66676, 67183, 67620, 66960, 66347, 65925, 65907, 65896, 66738, 66703, 67060, 67004, 67007, 66329, 65304, 52002, 38969, 25433, 12426, 0, 0]
download = [42926, 43853, 43157, 45470, 44254, 46272, 45083, 47344, 46716, 51963, 50112, 52334, 55525, 57545, 53691, 51637, 49574, 49836, 48295, 49843, 52878, 56014, 56966, 56938, 60065, 60461, 56542, 59526, 58678, 54424, 51862, 55109, 52132, 53783, 51687, 56567, 52182, 50758, 46714, 50511, 48161, 50920, 48694, 50528, 55074, 55420, 55882, 59268, 59958, 57938, 57115, 51424, 51180, 53184, 52879, 51177, 54417, 51097, 47901, 49870, 55865, 61118, 61476, 63498, 58878, 49630, 45975, 45632, 45892, 44855, 49495, 48304, 45829, 42152, 39403, 37574, 32384, 34933, 34901, 33492, 31953, 36271, 33826, 34515, 36408, 41106, 43054, 44110, 40810, 41383, 37267, 35881, 38660, 37525, 34857, 36718, 36842, 34281, 39528, 41854, 42952, 40021, 41722, 41045, 42917, 39287, 38672, 32824, 28765, 22686, 18490, 15714, 15268, 14793, 15305, 16354, 16720, 17502, 17857, 16622, 18447, 19929, 31138, 36965, 36158, 32795, 30445, 21997, 18100, 22491, 27227, 29317, 32436, 35700, 39140, 36258, 33697, 24751, 20354, 8211, 3836, 1560, 834, 2034, 1744, 1637, 1637, 1637, 0, 0]
-
import sys
import cairo
-import pycha.line
+#import pycha.line
+import pycha_line_deluge as line
from pycha.color import hex2rgb
from pycha.chart import Option
+#Complete pycha style ;
+options = Option(
+ axis=Option(
+ lineWidth=1.0,
+ lineColor='#000000',
+ tickSize=3.0,
+ labelColor='#666666',
+ labelFont='Tahoma',
+ labelFontSize=9,
+ labelWidth=50.0,
+ x=Option(
+ hide=True,
+ ticks=None,
+ tickCount=10,
+ tickPrecision=1,
+ range=None,
+ rotate=None,
+ label=None,
+ ),
+ y=Option(
+ hide=False,
+ ticks=None,
+ tickCount=3,
+ tickPrecision=1,
+ range=None,
+ rotate=None,
+ label=None,
+ ),
+ ),
+ background=Option(
+ hide=False,
+ baseColor=None,
+ chartColor='#ffffff',
+ lineColor='#f5f5f5',
+ lineWidth=1.5,
+ ),
+ legend=Option(
+ opacity=0.8,
+ borderColor='#FFFFFF',
+ style={},
+ hide=False,
+ position=Option(top=0, left=800 - 100)
+ ),
+ padding=Option(
+ left=30,
+ right=30,
+ top=15,
+ bottom=15,
+ ),
+ stroke=Option(
+ color='#ffffff',
+ hide=False,
+ shadow=True,
+ width=2
+ ),
+ fillOpacity=0.5,
+ shouldFill=False,
+ barWidthFillFraction=0.75,
+ xOriginIsZero=True,
+ yOriginIsZero=True,
+ pieRadius=0.4,
+ colorScheme="blue",
+ title=None,
+ titleFont='Tahoma',
+ titleFontSize=12,
+)
+
+
def test_colscheme():
print pycha.color.generateColorscheme("#6d1d1d", ["one","two"])
def lineChart(output):
- surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 800, 300)
+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 800, 200)
+
+ options["colorScheme"] = {
+ 'upload': hex2rgb("#444499"),
+ 'download': hex2rgb("#449944"),
+ }
dataSet = (
- ('download',[(i, bps / 1024) for i, bps in enumerate(download) ] ),
- ('upload', [(i, bps / 1024) for i, bps in enumerate(upload) ] ),
+ ('download',[(i, bps / 1024) for i, bps in enumerate(reversed(download)) ] ),
+ ('upload', [(i, bps / 1024) for i, bps in enumerate(reversed(upload)) ] ),
)
- options = {
- "legend":Option(
- opacity=0.8,
- borderColor='#FFFFFF',
- style={},
- hide=False,
- position=Option(top=0, left=800 - 100)
- ),
-
- 'axis': {
- 'x': {
- 'ticks': [],
- },
- 'y': {
- 'tickCount': 4,
- }
- },
- 'background': {
- 'color': '#ffffff',
- 'lineColor': '#444444'
- },
- #'colorScheme': 'blue',
- "colorScheme":{
- 'upload': hex2rgb("#449944"),
- 'download': hex2rgb("#444499"),
- },
- 'padding': {
- 'left': 55,
- 'bottom': 40,
- },
- "fillOpacity":0.5,
- "shouldFill":False,
- }
- chart = pycha.line.LineChart(surface, options)
+ chart = line.LineChart(surface, options)
chart.addDataset(dataSet)
chart.render()