I would like to show the default visualization timefilter (the timeRangeSelector specifically) inside my own visualization. (I thought it was displayed by default in any case)
My visualization is itself just a simple display table. I am using ReactJS for rendering (and developing a Kibana 7.x plugin). I have not been able to see how I can enable the timeRangeSelector.
I have seen many examples for Angular (inside other plugins source code or the Kibana source itself). But I am however unable to control the timefilter from inside my plugin.
My code (generated at first using the kibana-plugin-generator) is structured as follows:
/* index.js /
export default function (kibana) {
return new kibana.Plugin({...
uiExports: {
app: {
main: 'plugins/myPlugin/app'
}, ...
/ app.js /
function RootController($scope, $element, $http) {
const domNode = $element[0];
render(, domNode);
...
/ main.js */
export class Main extends React.Component {
render() { return ( ...);
I was unable to find if there is a plugin option (in the current dev docs) that I can add in the app UiExports or how I could "manually" render it in my <EuiPage> content.
Can anyone point out some documentation or code examples?
the current timepicker is still written in Angular (see #15212 for ticket to move it to React). Thus you cannot embed it into a non Angular plugin, since it's an angular directive, that needs all dependencies injected correctly. But since the global timepicker has no links to visualizations anymore (finally!), you can just pick yourself any other timepicker you would like until we moved the Kibana one to React. You need to pass in the timerange a visualization should show, anyway specifically into the visualize loader as a parameter timeRange. It doesn't matter what timepicker you use to get that information from. Of course another time picker would still lack all the quick options, but you should be able to quickly implement that, it will just need to set the timeRange in the visualize loader to ES datemath strings, like: { from: 'now-7d', to: 'now' }.
One other possibility would be, include that timepicker directive outside of your React code using the actual Angular wrapper, that you use to mount the react component to also render the timepicker, and somehow pass the values from it into your react code, but to be honest, that doesn't sound much simpler than using a different timepicker
We are already actively looking into building the new time picker component in our EUI framework, but we are still needing to fix a lot of accessibility issues on the used libraries before we can integrate that into Kibana.
Hope that answer could help you a bit moving forward.
Thank you @bhavyarm and @timroes for your replies. Now I understand my problem better .
Regarding the indicated approaches, I would (at this point) go for including another datepicker there, not combining Angular and React code. I see from #15212 that there is, more or less, something already done in Kibana. I am not sure if I can use it, but I would have another look.
The visualization loader you mentioned, I assume is this one (and the timeRange is one of the accepted parameters)?
Will this loader be called even if I use a React visualization (component), specified in the app object of the uiExports?
I apologize for asking things that might be simple for experienced plugin developers.
the issue you refer to is our still open progress to replace the current date picker by a React version, but that's not done yet.
The visualize loader you pointed out is the correct one. It is vanilla JS and totally framework agnostic. You just need to pass it in the saved visualization id (or saved object), and a DOM node that we should render into. For most of the visualizations to work, you will nevertheless need to include some uiExports imports into your code, see e.g. this sample plugin.
That way you instruct the optimizer to bundle all that relevant parts into your application bundle, otherwise that code would be missing and you might get some weird errors trying to load a visualization.
I will move forward trying to use a datepicker range, from the EUI framework you pointed out. I trust that usage of components is an already available workaround. And then I can hopefully use that timeRange with the visualization loader, as you suggested.
I will mark your first reply as the one that got me unstuck; but the entire discussion helped me.
Just a quick question, regarding the usage of the visualize loader you pointed out.
I have tried to use code as documented, inside of the RootController that I use with ui/chrome. But I am getting some Angular related errors (Uncaught (in promise) Error: [$injector:unpr] Unknown provider: savedVisualizationsProvider <- savedVisualizations).
Can you please point out if there is any documentation, or code examples, of the loader used in/with React codebase? I have looked in the Kibana, Eui sources and other example plugins (from other threads), but was unable to find such a sample.
I think the main issue when you are getting some unknown provider is, that your application bundle will usually miss the related Angular files (no matter if you are using Angular yourself or not).
Which files Kibana should bundle for your plugin is controlled by a couple of import 'uiExport/*'; statements in your application entry file - if you are developing against 6.x or master - or earlier to that, a uiExports.app.uses statement.
In case you are developing against 6.x or master could you show your main application file and check if you have any of those imports, if you are developing for 6.3.0 or earlier, could you paste your index.js from you plugin?
Could you please share which providers currently error. Also in the error message, there is usually a link to the Angular docs explaining this error, which would contain more information about where this injection happened, could you please provide that too (if unsure what I am asking for, also post a screenshot of the error on the console :D)
My current error is Uncaught (in promise) Error: [$injector:unpr] Unknown provider: regionmapsConfigProvider <- regionmapsConfig <- SavedVis <- savedVisualizations
that's luckily now a new error, which is actually an issue, if you are not properly injecting the kibana variables into your application (and thus region map cannot find it's configuration).
Check this post for more information and the solution how to fix that!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.