Creating base visualisations in Kibana


(Mishal) #1
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { Schemas } from 'ui/vis/editors/default/schemas';
import { CATEGORY } from 'ui/vis/vis_category';
import * as d3 from "d3";

class MyVisualization {
    constructor(el, vis) {
        this.el = el;
        this.vis = vis;
    }
    async render(visData, status) {
        console.warn("Vis ", this.vis.aggs);
        console.warn("Metric agg data ",this.vis.aggs.bySchemaName.metric[0]);
        console.warn("View by agg data", this.vis.aggs.bySchemaName.viewBy[0]);
        console.warn("Time by agg data", this.vis.aggs.bySchemaName.timeSplit[0]);
        const viewByBuckets = this.vis.aggs[this.vis.aggs.bySchemaName.viewBy[0].id].buckets;
        console.warn("View by buckets ",viewByBuckets);
        return 'done rendering';
    }
    destroy() {
        console.log('destroying');
    }
}

const MyNewVisType = (Private) => {
    const VisFactory = Private(VisFactoryProvider);

    return VisFactory.createBaseVisualization({
        name: 'my_new_vis',
        title: 'My New Vis',
        icon: 'fa fa-bars',
        description: 'Cool new chart',
        category: CATEGORY.OTHER,
        responseHandler: 'none',
        editorConfig: {
            collections: {},
            schemas: new Schemas([
                {
                    group: 'metrics',
                    name: 'metric',
                    title: 'Value',
                    min: 1,
                    max: 1,
                    aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality']
                },
                {
                    group: 'buckets',
                    name: 'viewBy',
                    icon: 'fa fa-eye',
                    title: 'View By',
                    mustBeFirst: true,
                    min: 0,
                    max: 1,
                    aggFilter: 'terms'
                },
                {
                    group: 'buckets',
                    name: 'timeSplit',
                    icon: 'fa fa-th',
                    title: 'Time Field',
                    min: 1,
                    max: 1,
                    aggFilter: 'date_histogram'
                },
            ])
        },
        visualization: MyVisualization
    });
}

VisTypesRegistryProvider.register(MyNewVisType);

This is my file for custom plugin for Kibana. However when I load this plugin, I am not able to render anything on the main area. Is there something I should add inside the 'render' method?


(Bhavya R M) #2

@ppisljar / @timroes can we please get some help here?

Thanks,
Bhavya


(Mishal) #3

Hi @bhavyarm , solved this issue. :slight_smile:


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.