I am trying to replicate the histogram visualization type in kibana using the plugin new visualization type functionality. I used VisFactory's createVislibVisualization
. The visualization is not rendered. I encounter the following problem
TypeError: Cannot read property 'splitColumn' of undefined
. How can I overcome this error?
Can you please post your whole error log?
Thanks,
Bhavya
I am using Kibana version 7.1.1. The following is the browser console message.
Uncaught (in promise) TypeError: Cannot read property 'splitColumn' of undefined
at legacy.js:42
at new Promise (<anonymous>)
at handler (legacy.js:39)
at vislib.js:73
at new Promise (<anonymous>)
at VisualizeDataLoader.responseHandler (vislib.js:72)
at VisualizeDataLoader.<anonymous> (visualize_data_loader.ts:68)
at step (tslib.js:129)
at Object.eval [as next] (tslib.js:110)
at fulfilled (tslib.js:100)
@Aravinda_Kolla I'm not too familiar with the legacy plugin but just looking at the error message, it seems that the responseHandler
is expecting a dimensions
object, here .
The shape of the dimensions looks something like that of the kibana_datatable
vis, for example...
{
"x": null,
"y": [
{
"accessor": 0,
"format": {
"id": "number"
},
"params": {},
"label": "Total Delays",
"aggType": "count"
}
]
}
You may just need to decorate the Vis object with dimensions using getVisParams
helper method
If you could post more source code it would be easier to assist you further.
@nickofthyme I replicated the code on github kibana tagv7.1.1. The index.js looks as follows:
export default function (kibana) {
return new kibana.Plugin({
uiExports: {
visTypes: [
'plugins/hist_vis/hist_vis'
]
}
});
}
Copy pasted the code from the following link with no modifications in hist_vis.js.
I tried to do the same for version 7.5.1.
I get the following javascript error:
Uncaught (in promise) TypeError: Cannot read property 'find' of undefined
at point_series.js:133
at Array.forEach (<anonymous>)
at point_series.js:124
at new VisConfig (vis_config.js:45)
at Vis.initVisConfig (vis.js:88)
at _callee$ (controller.js:109)
at tryCatch (runtime.js:45)
at Generator.invoke [as _invoke] (runtime.js:271)
at Generator.prototype.<computed> [as next] (runtime.js:97)
at asyncGeneratorStep (controller.js:18)
The index.js is as follows:
export default function (kibana) {
return new kibana.Plugin({
require: ['elasticsearch'],
name: 'hist_vis',
uiExports: {
visTypes: [
'plugins/hist_vis/hist_vis'
],
interpreter: [
'plugins/hist_vis/pie_fn',
'plugins/hist_vis/hist_vis_fn',
]
},
config(Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
});
}
The hist_vis.js is same as:
https://github.com/elastic/kibana/blob/v7.5.1/src/legacy/core_plugins/kbn_vislib_vis_types/public/histogram.js .
The hist_fn.js is same as :
https://github.com/elastic/kibana/blob/v7.5.1/src/legacy/core_plugins/kbn_vislib_vis_types/public/vislib_fn.js .
The pie_fn.js is same as :
https://github.com/elastic/kibana/blob/v7.5.1/src/legacy/core_plugins/kbn_vislib_vis_types/public/pie_fn.js .
the controller is same as :
https://github.com/elastic/kibana/blob/v7.5.1/src/legacy/core_plugins/kbn_vislib_vis_types/public/controller.js
@Aravinda_Kolla sorry for the delay. It took me a bit to fully understand your question and figure out the code involved.
From what I understand, you just want to replicate the current histogram visualization. In coping all the files you mentioned below and attempting to create my own plugin/visualization under legacy/core_plugins/hist_vis
I did encounter the same error as you with the find
of undefined.
The problem is that it is never calling the fn
method on the hist_fn.js
which does the response handling, this guy .
This is because hist_vis
is not a vislibCharts
type which are defined here .
Adding hist_vis
to this array renders the replicated visualization as expected. This is sort of complex because the kbn_vislib_vis_types
plugin handles several visualizations that have shared logic.
Note: This area of code is very volatile right now as we are internally migrating all our existing plugins, including visualizations, to a new platform. See here if interested in more details.
Sorry, I can't give more context than this. I'm not too familiar with how this would work as a third-party plugin having replicated the kbn_vislib_vis_types
logic. If that is your end intent, you might have more issues. Please let me know if you have any other questions.
@nickofthyme Thank you for your elaborate reply. So if I want to replicate what the kbn_vislib_vis_types
histogram does, as a third party plugin, do I have to write custom request and response handlers ?
@Aravinda_Kolla yup, that's exactly right.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.