summaryrefslogtreecommitdiff
path: root/widgets/graph
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2016-07-13 20:07:09 +0200
committervarac <varacanero@zeromail.org>2016-07-13 20:07:09 +0200
commit5d01197cf893d4a8c9a57f7c963f47393d34e157 (patch)
tree860e97c0af1ad8c7d4bd1aecb0b7e6658b312846 /widgets/graph
initial commit, import from pixelated_dashboard
Diffstat (limited to 'widgets/graph')
-rw-r--r--widgets/graph/graph.coffee36
-rw-r--r--widgets/graph/graph.html5
-rw-r--r--widgets/graph/graph.scss65
3 files changed, 106 insertions, 0 deletions
diff --git a/widgets/graph/graph.coffee b/widgets/graph/graph.coffee
new file mode 100644
index 0000000..a54de08
--- /dev/null
+++ b/widgets/graph/graph.coffee
@@ -0,0 +1,36 @@
+class Dashing.Graph extends Dashing.Widget
+
+ @accessor 'current', ->
+ return @get('displayedValue') if @get('displayedValue')
+ points = @get('points')
+ if points
+ points[points.length - 1].y
+
+ ready: ->
+ container = $(@node).parent()
+ # Gross hacks. Let's fix this.
+ width = (Dashing.widget_base_dimensions[0] * container.data("sizex")) + Dashing.widget_margins[0] * 2 * (container.data("sizex") - 1)
+ height = (Dashing.widget_base_dimensions[1] * container.data("sizey"))
+ @graph = new Rickshaw.Graph(
+ element: @node
+ width: width
+ height: height
+ renderer: @get("graphtype")
+ series: [
+ {
+ color: "#fff",
+ data: [{x:0, y:0}]
+ }
+ ]
+ )
+
+ @graph.series[0].data = @get('points') if @get('points')
+
+ x_axis = new Rickshaw.Graph.Axis.X(graph: @graph)
+ y_axis = new Rickshaw.Graph.Axis.Y(graph: @graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
+ @graph.render()
+
+ onData: (data) ->
+ if @graph
+ @graph.series[0].data = data.points
+ @graph.render()
diff --git a/widgets/graph/graph.html b/widgets/graph/graph.html
new file mode 100644
index 0000000..456dd0f
--- /dev/null
+++ b/widgets/graph/graph.html
@@ -0,0 +1,5 @@
+<h1 class="title" data-bind="title"></h1>
+
+<h2 class="value" data-bind="current | prettyNumber | prepend prefix"></h2>
+
+<p class="more-info" data-bind="moreinfo"></p>
diff --git a/widgets/graph/graph.scss b/widgets/graph/graph.scss
new file mode 100644
index 0000000..d1d7534
--- /dev/null
+++ b/widgets/graph/graph.scss
@@ -0,0 +1,65 @@
+// ----------------------------------------------------------------------------
+// Sass declarations
+// ----------------------------------------------------------------------------
+$background-color: #178CA6;
+
+$title-color: rgba(255, 255, 255, 0.7);
+$moreinfo-color: rgba(255, 255, 255, 0.3);
+$tick-color: rgba(0, 0, 0, 0.4);
+
+
+// ----------------------------------------------------------------------------
+// Widget-graph styles
+// ----------------------------------------------------------------------------
+.widget-graph {
+
+ background-color: $background-color;
+ position: relative;
+
+
+ svg {
+ position: absolute;
+ opacity: 0.4;
+ fill-opacity: 0.4;
+ left: 0px;
+ top: 0px;
+ }
+
+ .title, .value {
+ position: relative;
+ z-index: 99;
+ }
+
+ .title {
+ color: $title-color;
+ }
+
+ .more-info {
+ color: $moreinfo-color;
+ font-weight: 600;
+ font-size: 20px;
+ margin-top: 0;
+ }
+
+ .x_tick {
+ position: absolute;
+ bottom: 0;
+ .title {
+ font-size: 20px;
+ color: $tick-color;
+ opacity: 0.5;
+ padding-bottom: 3px;
+ }
+ }
+
+ .y_ticks {
+ font-size: 20px;
+ fill: $tick-color;
+ fill-opacity: 1;
+ }
+
+ .domain {
+ display: none;
+ }
+
+}