You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/10/23 16:58:53 UTC
[kibble] 01/04: linechart should be able to handle counts a single
bar
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git
commit d4cef7ed3e639bf9bc5ca0246189151d6e415c08
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Oct 23 18:57:57 2017 +0200
linechart should be able to handle counts a single bar
---
ui/js/coffee/charts_linechart.coffee | 13 +++++---
ui/js/coffee/widget_linechart.coffee | 59 ++++++++++++++++++------------------
2 files changed, 38 insertions(+), 34 deletions(-)
diff --git a/ui/js/coffee/charts_linechart.coffee b/ui/js/coffee/charts_linechart.coffee
index 4457674..b985494 100644
--- a/ui/js/coffee/charts_linechart.coffee
+++ b/ui/js/coffee/charts_linechart.coffee
@@ -77,18 +77,21 @@ charts_linechart = (obj, data, options) ->
asDataArray = ts
else
- for k, v of data
+ for k, v of data.counts
asList.push(k)
- asTypes[k] = linetype
+ asTypes[k] = 'bar'
tmpArray = [k]
- for dataPoint in v
- tmpArray.push(dataPoint)
+ if isArray(v)
+ for dataPoint in v
+ tmpArray.push(dataPoint)
+ else
+ tmpArray.push(v)
asDataArray.push(tmpArray)
a++
config = {
bindto: obj,
data: {
- x: 'x',
+ x: if data.timeseries then 'x' else null,
#xFormat: '%s',
columns: asDataArray,
types: asTypes,
diff --git a/ui/js/coffee/widget_linechart.coffee b/ui/js/coffee/widget_linechart.coffee
index c1918a6..0df7c2d 100644
--- a/ui/js/coffee/widget_linechart.coffee
+++ b/ui/js/coffee/widget_linechart.coffee
@@ -20,38 +20,39 @@ linechart = (json, state) ->
cats = new Array()
dates = new Array()
catdata = {}
- if not json.timeseries.sort
+ if not isArray(json.timeseries) and not json.counts
div.innerHTML = "No data available"
state.widget.inject(div, true)
return
- json.timeseries.sort((a,b) => a.date - b.date)
- for point in json.timeseries
- for key, val of point
- if key != 'date' and not (key in cats)
- cats.push(key)
- catdata[key] = new Array()
-
- for point in json.timeseries
- m = moment(point.date*1000)
- rv = m.format("MMM, YYYY")
-
- if json.histogram == "daily" || json.interval == 'day'
- rv = m.format("MMMM DD, YYYY")
- if json.interval == 'year'
- rv = m.format("YYYY")
- else if json.interval == 'quarter'
- rv = "Q" +m.format("Q, YYYY")
- else if json.interval == 'week'
- rv = "Week " +m.format("W, YYYY")
- dates.push (rv)
- for key, val of point
- if key != 'date'
- if key == 'deletions'
- val = -val
- catdata[key].push(val)
- for cat in cats
- if not cat in point
- catdata[cat].push(0)
+ if json.timeseries
+ json.timeseries.sort((a,b) => a.date - b.date)
+ for point in json.timeseries
+ for key, val of point
+ if key != 'date' and not (key in cats)
+ cats.push(key)
+ catdata[key] = new Array()
+
+ for point in json.timeseries
+ m = moment(point.date*1000)
+ rv = m.format("MMM, YYYY")
+
+ if json.histogram == "daily" || json.interval == 'day'
+ rv = m.format("MMMM DD, YYYY")
+ if json.interval == 'year'
+ rv = m.format("YYYY")
+ else if json.interval == 'quarter'
+ rv = "Q" +m.format("Q, YYYY")
+ else if json.interval == 'week'
+ rv = "Week " +m.format("W, YYYY")
+ dates.push (rv)
+ for key, val of point
+ if key != 'date'
+ if key == 'deletions'
+ val = -val
+ catdata[key].push(val)
+ for cat in cats
+ if not cat in point
+ catdata[cat].push(0)
catseries = []
type = 'spline'
--
To stop receiving notification emails like this one, please contact
"commits@kibble.apache.org" <co...@kibble.apache.org>.