remove cubism

This commit is contained in:
Florent BEAUCHAMP
2015-09-24 19:53:31 +02:00
parent 0007e9ea2b
commit 338c686e8d
5 changed files with 2 additions and 163 deletions
-4
View File
@@ -8,8 +8,6 @@ import filter from 'lodash.filter'
import foreach from 'lodash.foreach'
import xoApi from 'xo-api'
import xoCubism from'xo-cubism'
import xoHorizon from'xo-horizon'
import xoParallelD3 from 'xo-parallel-d3'
import xoSunburstD3 from 'xo-sunburst-d3'
import xoWeekHeatmap from'xo-week-heatmap'
@@ -20,8 +18,6 @@ export default angular.module('dashboard.dataviz', [
uiRouter,
uiSelect,
xoApi,
xoCubism,
xoHorizon,
xoParallelD3,
xoSunburstD3,
xoWeekHeatmap
+2 -1
View File
@@ -7,14 +7,15 @@ import forEach from 'lodash.foreach'
import sortBy from 'lodash.sortby'
import xoApi from 'xo-api'
import xoHorizon from'xo-horizon'
import xoServices from 'xo-services'
import view from './view'
export default angular.module('dashboard.health', [
uiRouter,
xoApi,
xoHorizon,
xoServices
])
.config(function ($stateProvider) {
-1
View File
@@ -10,7 +10,6 @@ import view from './view'
export default angular.module('dashboard', [
uiRouter,
dataviz,
health,
overview
-149
View File
@@ -1,149 +0,0 @@
'use strict'
import angular from 'angular'
import cubism from 'cubism'
import d3 from 'd3'
import clone from 'lodash.clonedeep'
import find from 'lodash.find'
import filter from 'lodash.filter'
import foreach from 'lodash.foreach'
const $ = window.$
export default angular.module('xoCubism', [])
.directive('cubism', function ($parse, $timeout) {
function link (scope, element, attrs) {
$timeout(function () {
init() // D3 need a dom width and height
}, 0)
function init () {
let $e, metrics, sources
metrics = []
sources = {}
$e = $(element[0])
while ($e.width() === 0 && $e.parent()) {
$e = $e.parent()
}
const size = $e.width()
const step = scope.step || 5000
const context = cubism.context()
.serverDelay(60 * 1000)
.clientDelay(60 * 1000)
.step(step)
.size(size)
const container = d3.select(element[0])
scope.$watch(() => scope.chartData, function (newvalue) {
console.log('change')
let hasone = false
foreach(newvalue, function (data, key) {
let metric
hasone = true
metric = find(metrics, {title: key})
/*
*/
sources[key] = clone(data)
if (!metric) {
console.log(key, 'this metric does not exists')
metric = context.metric(
function (start, stop, step, callback) {
let values, item, date
values = []
date = +start
stop = +stop
while (date < stop) {
item = find(sources[key], {date: new Date(date)})
if (item) {
values.push(item.value)
} else {
values.push(null)
}
date += step
}
callback(null, values)
// time only go forward, purge old values
sources[key] = filter(sources[key], function (datum) {
return datum.date >= start
})
})
metric.title = key
metrics.push(metric)
}
})
foreach(sources, function (val, key) {
console.log(' check ',key)
if (!newvalue[key]) {
console.log(' new value does not have ', key)
container
.select('.horizon')
.remove()
delete sources[key]
delete metrics[key]
}
})
if (!hasone) {
console.log(' has none')
return
}
if (container.select('.axis').empty()) {
container
.append('div')
.attr('class', 'axis')
.call(context.axis().orient('top'))
}
container
.selectAll('.horizon')
.data(metrics)
.enter().append('div')
.attr('class', 'horizon')
.call(
context
.horizon()
.height(120)
.title(function (metric) {
return metric.title + ' '
})
.extent(function (metric) {
if (scope.extents) {
return scope.extents[metric.title]
}
return null
})
.format(function (value) {
return value
})
)
if (container.select('.rule').empty()) {
container.append('div')
.attr('class', 'rule')
.call(context.rule())
}
}, true)
}
}
return {
resctict: 'E',
replace: false,
scope: {
step: '=',
size: '=',
chartData: '=',
extents: '=',
over: '&',
click: '&'
},
link: link
}
})
// A module exports its name.
.name
-8
View File
@@ -1,8 +0,0 @@
{
"private": true,
"browserify": {
"transform": [
"babelify"
]
}
}