Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
szydan committed Jan 15, 2016
0 parents commit 341101d
Show file tree
Hide file tree
Showing 14 changed files with 947 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
insert_final_newline = false
68 changes: 68 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
parser: babel-eslint

env:
es6: true
amd: true
node: true
browser: true
mocha: true

rules:
block-scoped-var: 2
camelcase: [ 2, { properties: never } ]
comma-dangle: 0
comma-style: [ 2, last ]
consistent-return: 0
curly: [ 2, multi-line ]
dot-location: [ 2, property ]
dot-notation: [ 2, { allowKeywords: true } ]
eqeqeq: [ 2, allow-null ]
guard-for-in: 2
indent: [ 2, 2, { SwitchCase: 1 } ]
key-spacing: [ 0, { align: value } ]
max-len: [ 2, 140, 2, { ignoreComments: true, ignoreUrls: true } ]
new-cap: [ 2, { capIsNewExceptions: [ Private ] } ]
no-bitwise: 0
no-caller: 2
no-cond-assign: 0
no-debugger: 2
no-empty: 2
no-eval: 2
no-extend-native: 2
no-extra-parens: 0
no-irregular-whitespace: 2
no-iterator: 2
no-loop-func: 2
no-multi-spaces: 0
no-multi-str: 2
no-nested-ternary: 2
no-new: 0
no-path-concat: 0
no-proto: 2
no-return-assign: 0
no-script-url: 2
no-sequences: 2
no-shadow: 0
no-trailing-spaces: 2
no-undef: 2
no-underscore-dangle: 0
no-unused-expressions: 0
no-unused-vars: 0
no-use-before-define: [ 2, nofunc ]
no-with: 2
one-var: [ 2, never ]
quotes: [ 2, single ]
semi-spacing: [ 2, { before: false, after: true } ]
semi: [ 2, always ]
space-after-keywords: [ 2, always ]
space-before-blocks: [ 2, always ]
space-before-function-paren: [ 2, { anonymous: always, named: never } ]
space-in-parens: [ 2, never ]
space-infix-ops: [ 2, { int32Hint: false } ]
space-return-throw-case: [ 2 ]
space-unary-ops: [ 2 ]
strict: [ 2, never ]
valid-typeof: 2
wrap-iife: [ 2, outside ]
yoda: 0
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bower_components/
build/
node_modules/
npm-debug.log
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2015 SIREn Solutions

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this product except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Kibi Radar Chart Plugin

A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. The relative position and angle of the axes is typically uninformative.

![image](./radar.png)

## Installation

This plugin can be isntalled in both:

* [Kibana >= 4.3](https://www.elastic.co/downloads/past-releases/kibana-4-3-0)
* [Kibi >= 0.3](https://siren.solutions/kibi) (Coming soon ...)

#### Automatic
```
bin/kibana plugin --install sirensolutions/kibi-radar-chart-plugin
```

#### Manuall

```
git clone https://github.com/sirensolutions/kibi-radar-chart-plugin
cd kibi-radar-chart-plugin
npm install
npm run build
cp -R build/kibi_radar_vis KIBANA_FOLDER_PATH/installedPlugins/
```
## Development

- Clone the repository at the same level of a Kibana > 4.2 clone
- If needed, switch to the same node version as Kibana using nvm
(e.g. `nvm use 0.12`)
- Install dependencies with `npm install`
- Install the plugin to Kibana and start watching for changes by running
`npm start`
131 changes: 131 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
var gulp = require('gulp');
var _ = require('lodash');
var path = require('path');
var gulpUtil = require('gulp-util');
var mkdirp = require('mkdirp');
var Rsync = require('rsync');
var Promise = require('bluebird');
var eslint = require('gulp-eslint');
var rimraf = require('rimraf');
var tar = require('gulp-tar');
var gzip = require('gulp-gzip');
var fs = require('fs');
var spawn = require('child_process').spawn;
var minimist = require('minimist');

var pkg = require('./package.json');
var packageName = pkg.name + '-' + pkg.version;

var buildDir = path.resolve(__dirname, 'build');
var targetDir = path.resolve(__dirname, 'target');
var buildTarget = path.resolve(buildDir, pkg.name);

var include = [
'package.json',
'index.js',
'node_modules',
'public'
];
var exclude = Object.keys(pkg.devDependencies).map(function (name) {
return path.join('node_modules', name);
});

var knownOptions = {
string: 'kibanahome',
default: { kibanahome: 'kibana' }
};
var options = minimist(process.argv.slice(2), knownOptions);

var kibanaPluginDir = path.resolve(__dirname, '../' + options.kibanahome + '/installedPlugins/' + pkg.name);

function syncPluginTo(dest, done) {
mkdirp(dest, function (err) {
if (err) return done(err);
Promise.all(include.map(function (name) {
var source = path.resolve(__dirname, name);
return new Promise(function (resolve, reject) {
var rsync = new Rsync();
rsync
.source(source)
.destination(dest)
.flags('uav')
.recursive(true)
.set('delete')
.exclude(exclude)
.output(function (data) {
process.stdout.write(data.toString('utf8'));
});
rsync.execute(function (err) {
if (err) {
console.log(err);
return reject(err);
}
resolve();
});
});
}))
.then(function () {
done();
})
.catch(done);
});
}

gulp.task('sync', function (done) {
syncPluginTo(kibanaPluginDir, done);
});

gulp.task('lint', function (done) {
return gulp.src([
'server/**/*.js',
'public/**/*.js',
'!public/webpackShims/**'
]).pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failOnError());
});

gulp.task('clean', function (done) {
Promise.each([buildDir, targetDir], function (dir) {
return new Promise(function (resolve, reject) {
rimraf(dir, function (err) {
if (err) return reject(err);
resolve();
});
});
}).nodeify(done);
});

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']);
});

gulp.task('test', ['sync'], function(done) {
spawn('grunt', ['test:browser', '--grep=Kibi Radar Chart'], {
cwd: '../' + options.kibanahome,
stdio: 'inherit'
}).on('close', done);
});

gulp.task('coverage', ['sync'], function(done) {
spawn('grunt', ['test:coverage', '--grep=Kibi Radar Chart'], {
cwd: '../' + options.kibanahome,
stdio: 'inherit'
}).on('close', done);
});
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (kibana) {
return new kibana.Plugin({
name: 'kibi_radar_vis',
require: ['kibana', 'elasticsearch'],
uiExports: {
visTypes: [
'plugins/kibi_radar_vis/kibi_radar_vis'
]
}
});
};

39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "kibi_radar_vis",
"version": "0.1.0",
"authors": [
"SIREn Solutions <[email protected]>"
],
"description": "Kibi Radar Chart plugin",
"main": "index.js",
"license": "Apache-2.0",
"homepage": "http://siren.solutions/kibi",
"repository": {
"type": "git",
"url": "[email protected]:sirensolutions/kibi-radar-chart-plugin.git"
},
"scripts": {
"test": "gulp test",
"test:coverage": "gulp coverage",
"start": "gulp dev",
"precommit": "gulp lint",
"build": "gulp build"
},
"devDependencies": {
"babel-eslint": "^4.1.6",
"bluebird": "^3.0.6",
"bower": "^1.6.9",
"eslint": "^1.10.3",
"gulp": "^3.9.0",
"gulp-eslint": "^1.1.1",
"gulp-gzip": "^1.2.0",
"gulp-tar": "^1.6.0",
"gulp-util": "^3.0.7",
"husky": "^0.10.2",
"lodash": "^3.10.1",
"mkdirp": "^0.5.1",
"rimraf": "^2.4.4",
"rsync": "^0.4.0",
"minimist": "1.2.0"
}
}
3 changes: 3 additions & 0 deletions public/kibi_radar_vis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div ng-controller="KbnRadarVisController" class="metric-vis">
<div class="metric-container" ng-model="metrics"></div>
</div>
74 changes: 74 additions & 0 deletions public/kibi_radar_vis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
define(function (require) {
// we need to load the css ourselves
require('plugins/kibi_radar_vis/kibi_radar_vis.less');

// we also need to load the controller and used by the template
require('plugins/kibi_radar_vis/kibi_radar_vis_controller');

// register the provider with the visTypes registry
require('ui/registry/vis_types').register(RadarVisProvider);

function RadarVisProvider(Private) {
var TemplateVisType = Private(require('ui/template_vis_type/TemplateVisType'));
var Schemas = Private(require('ui/Vis/Schemas'));

// return the visType object, which kibana will use to display and configure new
// Vis object of this type.
return new TemplateVisType({
name: 'radar',
title: 'Radar chart',
description: 'A radar chart is a graphical method of displaying multivariate data ' +
'in the form of a two-dimensional chart of three or more ' +
'quantitative variables represented on axes starting from the same point.' +
' The relative position and angle of the axes is typically uninformative.',
icon: 'fa-empire',
template: require('plugins/kibi_radar_vis/kibi_radar_vis.html'),
params: {
defaults: {
fontSize: 60,
shareYAxis: true,
addTooltip: true,
addLegend: true,
isDonut: false,
isFacet: false,
addLevel: true,
addAxe: true,
addVertice: true,
addPolygon: true,
addLevelLabel: true,
addAxeLabel: true,
addLevelScale: 1,
addLabelScale: 0.9,
addLevelNumber: 5
},
editor: require('plugins/kibi_radar_vis/kibi_radar_vis_params.html')
},
schemas: new Schemas([
{
group: 'metrics',
name: 'metric',
title: 'Metric',
min: 3,
defaults: [
{ type: 'count', schema: 'metric' },
{ type: 'count', schema: 'metric' },
{ type: 'count', schema: 'metric' }
],
aggFilter: ['count','cardinality', 'avg', 'sum', 'min', 'max']
},
{
group: 'buckets',
name: 'segment',
icon: 'fa fa-scissors',
title: 'Split Slices',
min: 1,
max: 1,
aggFilter: ['terms','range']
}
])
});
}

// export the provider so that the visType can be required with Private()
return RadarVisProvider;
});
Loading

0 comments on commit 341101d

Please sign in to comment.