[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace/plasma/sreich/qml2-system-monitors] plasma/generic/applets/system-monitor/plotter/pri
From:       Shaun Reich <shaun.reich () kdemail ! net>
Date:       2012-02-17 14:17:03
Message-ID: 20120217141703.086B5A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit ec3df14e50454c82996bb0d25076935d24f1f474 by Shaun Reich.
Committed on 17/02/2012 at 15:16.
Pushed by sreich into branch 'plasma/sreich/qml2-system-monitors'.

add a new graph type, LineGraph

doesn't fill and also doesn't trace to the bottom to create filled lin
es, just goes straight to the next point. it's a bit difficult to read
honestly, probably color especially strokes could help

M  +20   -8    plasma/generic/applets/system-monitor/plotter/private/plotterpainter.js


http://commits.kde.org/kde-workspace/ec3df14e50454c82996bb0d25076935d24f1f474

diff --git a/plasma/generic/applets/system-monitor/plotter/private/plotterpainter.js \
b/plasma/generic/applets/system-monitor/plotter/private/plotterpainter.js index \
                211e412..277d201 100644
--- a/plasma/generic/applets/system-monitor/plotter/private/plotterpainter.js
+++ b/plasma/generic/applets/system-monitor/plotter/private/plotterpainter.js
@@ -43,13 +43,19 @@ var gridPainted = false;
 var backgroundPainted = false;
 
 var GraphTypeEnum = {
+    // vertical rectangles
     BarGraph: "BarGraph",
-    FilledLineGraph: "FilledLineGraph"
+    // line graph with area below filled
+    FilledLineGraph: "FilledLineGraph",
+    // non filled, only lines
+    LineGraph: "LineGraph"
 }
 
 // what this graph is currently being rendered as
 // a bar graph or a filled line graph
-var graphType = GraphTypeEnum.BarGraph // FilledLineGraph;
+//var graphType = GraphTypeEnum.BarGraph;
+//var graphType = GraphTypeEnum.FilledLineGraph;
+var graphType = GraphTypeEnum.LineGraph;
 
 // the scalar that gets multiplied to scale it up or down.
 //  if it is 1 then it is not scaled at all
@@ -144,7 +150,7 @@ function shiftLeft()
         for (var j = 0; j < points[i].length; ++j) {
 
             if (points[i][j].x < graphPadding || (points[i][j].x - horizSpace) < \
                graphPadding) {
-                //FIXME: SHIFTS LEFT FAR,  FAR TOO SOON, THE GRAPH CANT KEEP UP \
HARDLY +                //FIXME: WARNING: leaks slowly, when a break in the graph is \
seen...probably a  round error or so.  points[i].splice(j, 1);
                 print("&&&&&&& LENGHT LEFTHSIFT: " + points[i].length);
             }
@@ -257,7 +263,7 @@ function paint(canvas, context)
             gridPainted = true;
         }
 
-        if (graphType == GraphTypeEnum.FilledLineGraph) {
+        if (graphType == GraphTypeEnum.FilledLineGraph || graphType == \
GraphTypeEnum.LineGraph) {  drawLines();
         } else if (graphType == GraphTypeEnum.BarGraph) {
             drawBarGraph();
@@ -350,13 +356,19 @@ function drawLines()
                 cp2y = y - 10;
               context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x + 5, y);
             } else {
-              context.lineTo(points[i][j].x, height - graphPadding);
+                if (graphType == GraphTypeEnum.FilledLineGraph) {
+                    context.lineTo(points[i][j].x, height - graphPadding);
+                }
             }
         }
 
-        context.lineTo(graphPadding, height - graphPadding);
-        context.closePath();
-        context.fill();
+
+        if (graphType == GraphTypeEnum.FilledLineGraph) {
+            context.lineTo(graphPadding, height - graphPadding);
+            context.closePath();
+            context.fill();
+        }
+
         context.stroke();
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic