diff --git a/README.md b/README.md index a0951e0..770cef4 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,16 @@ # Kibana Sankey Diagram Plugin -This is a sankey diagram visType plugin for Kibana 4.3+. +This is a sankey diagram visType plugin for Kibana 4.3+, 5.x. This plugin was developped from . -![](https://cloud.githubusercontent.com/assets/1219655/9702343/081607e6-548b-11e5-81cb-4523c8c9225d.png) +![](https://cloud.githubusercontent.com/assets/1219655/21418571/29e596d8-c85d-11e6-8060-11c0add8bf5b.png) # Install ``` +cd KIBANA_FOLDER_PATH/plugins/ git clone https://github.com/chenryn/kbn_sankey_vis.git -cd kbn_sankey_vis -npm install -npm run build -cp -R build/kbn_sankey_vis KIBANA_FOLDER_PATH/installedPlugins/ ``` # Uninstall diff --git a/bower.json b/bower.json deleted file mode 100644 index 5860686..0000000 --- a/bower.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "kbn_sankey_vis", - "version": "0.1.0", - "dependencies": { - "d3-plugins-sankey": "https://github.com/squidsolutions/d3-plugins-sankey.git#master" - } -} diff --git a/gulpfile.babel.js b/gulpfile.babel.js deleted file mode 100644 index 1ae779c..0000000 --- a/gulpfile.babel.js +++ /dev/null @@ -1,118 +0,0 @@ -import gulp from 'gulp'; -import _ from 'lodash'; -import path from 'path'; -import gutil from 'gulp-util'; -import mkdirp from 'mkdirp'; -import Rsync from 'rsync'; -import Promise from 'bluebird'; -import eslint from 'gulp-eslint'; -import del from 'del'; -import tar from 'gulp-tar'; -import gzip from 'gulp-gzip'; -import fs from 'fs'; - -import pkg from './package.json'; - -const packageName = pkg.name + '-' + pkg.version; - -// relative location of Kibana install -const pathToKibana = '../kibana'; -const buildDir = path.resolve(__dirname, 'build'); -const targetDir = path.resolve(__dirname, 'target'); -const buildTarget = path.resolve(buildDir, pkg.name); -const kibanaPluginDir = path.resolve(__dirname, pathToKibana, 'installedPlugins', pkg.name); - -const include = [ - 'package.json', - 'index.js', - 'node_modules', - 'public', - 'webpackShims', - 'server' -]; - -const exclude = [ - 'gulpfile.babel.js', - '.babelrc', - '.eslintrc' -]; - -Object.keys(pkg.devDependencies).forEach(function (name) { - exclude.push(path.join('node_modules', name)); -}); - -function syncPluginTo(dest, done) { - mkdirp(dest, function (err) { - if (err) return done(err); - - const source = path.resolve(__dirname) + '/'; - const rsync = new Rsync(); - - rsync.source(source) - .destination(dest) - .flags('uav') - .recursive(true) - .set('delete') - .include(include) - .exclude(exclude) - .output(function (data) { - process.stdout.write(data.toString('utf8')); - }); - - rsync.execute(function (err) { - if (err) { - console.log(err); - return done(err); - } - - done(); - }); - }); -} - -gulp.task('sync', function (done) { - syncPluginTo(kibanaPluginDir, done); -}); - -gulp.task('lint', function (done) { - const filePaths = [ - 'gulpfile.js', - 'server/**/*.js', - 'public/**/*.js', - 'public/**/*.jsx', - ]; - - return gulp.src(filePaths) - // eslint() attaches the lint output to the eslint property - // of the file object so it can be used by other modules. - .pipe(eslint()) - // eslint.format() outputs the lint results to the console. - // Alternatively use eslint.formatEach() (see Docs). - .pipe(eslint.formatEach()) - // To have the process exit with an error code (1) on - // lint error, return the stream and pipe to failOnError last. - .pipe(eslint.failOnError()); -}); - -gulp.task('test', ['lint'], function () { - gutil.log(gutil.colors.red('Nothing to test...')); -}); - -gulp.task('clean', function () { - return del([buildDir, targetDir]); -}); - -gulp.task('build', ['clean'], function (done) { - syncPluginTo(buildTarget, done); -}); - -gulp.task('package', ['build'], function (done) { - return gulp.src(path.join(buildDir, '**', '*')) - .pipe(tar(packageName + '.tar')) - .pipe(gzip()) - .pipe(gulp.dest(targetDir)); -}); - -gulp.task('dev', ['sync'], function (done) { - gulp.watch(['package.json', 'index.js', 'public/**/*', 'server/**/*'], ['sync', 'lint']); -}); diff --git a/package.json b/package.json index 6048ab9..30bbb54 100644 --- a/package.json +++ b/package.json @@ -1,44 +1,11 @@ { "name": "kbn_sankey_vis", - "version": "0.1.0", + "version": "kibana", "authors": [ "Chenryn " ], "description": "sankey diagram visualization plugin", "main": "index.js", "license": "Apache-2.0", - "homepage": "http://kibana.logstash.es/", - "scripts": { - "test": "gulp test", - "test:coverage": "gulp coverage", - "start": "gulp dev", - "postinstall": "bower install", - "precommit": "gulp lint", - "build": "gulp build" - }, - "dependencies": { - "babel-eslint": "^4.1.8", - "babel-preset-es2015": "^6.5.0", - "babel-register": "^6.5.2", - "d3-plugins-sankey": "squidsolutions/d3-plugins-sankey", - "bluebird": "^3.3.4", - "bower": "^1.7.7", - "del": "^2.2.0", - "eslint": "^2.4.0", - "eslint-plugin-mocha": "^2.0.0", - "gulp": "^3.9.1", - "gulp-eslint": "^2.0.0", - "gulp-gzip": "^1.2.0", - "gulp-tar": "^1.8.0", - "gulp-util": "^3.0.7", - "gulp-zip": "3.1.0", - "husky": "^0.10.2", - "lodash": "^4.6.1", - "minimist": "1.2.0", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.2", - "rsync": "^0.4.0" - }, - "devDependencies": { - } + "homepage": "http://kibana.logstash.es/" } diff --git a/public/kbn_sankey_vis_controller.js b/public/kbn_sankey_vis_controller.js index 5d4b7ac..88981a1 100644 --- a/public/kbn_sankey_vis_controller.js +++ b/public/kbn_sankey_vis_controller.js @@ -1,7 +1,7 @@ import d3 from 'd3'; import _ from 'lodash'; import $ from 'jquery'; -import S from 'd3-plugins-sankey'; +import S from './lib/d3-plugins-sankey/sankey'; import sankeyAggResponseProvider from './lib/agg_response'; import uiModules from 'ui/modules'; diff --git a/public/lib/agg_response.js b/public/lib/agg_response.js index fd9abef..b77a8a0 100644 --- a/public/lib/agg_response.js +++ b/public/lib/agg_response.js @@ -11,12 +11,13 @@ define(function (require) { function processEntry(aggConfig, metric, aggData, prevNode) { _.each(aggData.buckets, function (b) { - if (isNaN(nodes[b.key])) { - nodes[b.key] = lastNode + 1; + var bkey = aggConfig.fieldFormatter()(b.key); + if (isNaN(nodes[bkey])) { + nodes[bkey] = lastNode + 1; lastNode = _.max(_.values(nodes)); } if (aggConfig._previous) { - var k = prevNode + 'sankeysplitchar' + nodes[b.key]; + var k = prevNode + 'sankeysplitchar' + nodes[bkey]; if (isNaN(links[k])) { links[k] = metric.getValue(b); } else { @@ -24,7 +25,7 @@ define(function (require) { } } if (aggConfig._next) { - processEntry(aggConfig._next, metric, b[aggConfig._next.id], nodes[b.key]); + processEntry(aggConfig._next, metric, b[aggConfig._next.id], nodes[bkey]); } }); } diff --git a/public/lib/d3-plugins-sankey b/public/lib/d3-plugins-sankey new file mode 160000 index 0000000..5060619 --- /dev/null +++ b/public/lib/d3-plugins-sankey @@ -0,0 +1 @@ +Subproject commit 50606196309513618e45775398ce12ea9b27660e