Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding documentation for visualization development #12755

Closed
wants to merge 6 commits into from

Conversation

ppisljar
Copy link
Member

adding docs for visualize development (after visualize refactor)

@ppisljar ppisljar added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Team:Docs WIP Work in progress labels Jul 11, 2017
@timroes
Copy link
Contributor

timroes commented Jul 18, 2017

We seem to have mixed conventions right now whether to write kibana upper or lowercase. A quick search showed, that we tend to write it uppercase (Kibana) currently within text in the docs. Is there any rule we currently try to stick to?

Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the docs (not checked whether the asciidoc syntax is valid, but focused on the content).

Made some suggestions about wording and typos (since I am not a native speaker, please feel free to ignore whatever you want from this).

Also made some suggestions where we might explain stuff in a bit more detail.

I think this would be a great starting point for the documentation which we might extend over time and I guess several of the mentioned suggestions could also be incorporated over time. That's why I won't mark it as "request changes needed" (but neither as "approved") :-)

Update: I think that some "a" or "the" might be missing in the text, but as a non-native I wasn't sure enough to mark all the places 🤐

=== Using Visualizations

There are two ways to insert visualization in your page. Using `<visualize>` directive or using `<visualization>` directive.
The following assumes you are using angular in your plugin.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

angular is more often written uppercase and I guess even more often referenced as AngularJS


==== `<visualize>` directive
`<visualize>` directive takes a savedVis object and it takes care of loading data, parsing data,
rendering editor (if in edit mode) and rendering the visualization. Its the easiest way to add visualization to your
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"rendering the editor"? (sorry, I am not a native speaker, so please ignore comments that just sounds wrong in English)
"Its" -> "It's"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not a native speaker either as you probably noticed ;)


`<visualize saved-obj='savedVis' app-state='appState' ui-state='uiState' editor-mode='false'></visualize>` where

`savedVis` is an instance of savedVisualization object, which can be retrieved using `savedVisualizations` service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add: "which can be retrieved using the savedVisualizations service which is explained later in this documentation."


`savedVis` is an instance of savedVisualization object, which can be retrieved using `savedVisualizations` service.

`appState` is an instance of `AppState`. visualize is expecting two parameters defined on it:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"visualize is expecting.." -> "appState is expecting..."?

Also maybe: "x is expecting to have two keys defined.."


if not provided <visualize> will still work, just without monitoring the AppState.

`uiState` should be an instance of `PersistedState`. if not provided visualize will generate one, but you will have no access to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a a short sentence, wherefore uiState will be used.


[[development-none-request-handler]]
==== `none` request handler
Using 'none' as your request handles means your visualization does not require search.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make clear, that "search" means "data from ES" in that case.

Using 'none' as your request handles means your visualization does not require search.

[[development-custom-request-handler]]
==== custom request handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would need a bit more explanation about what this function does, or make it clear in the docs, that this is kind of an internal thing, and you have to lookup in code how that function works (maybe with link to current implementation).

[[development-visualization-response-handlers]]
=== Visualization Response Handlers
Response handler will receive the data from request handler and an instance of Vis object. Its job is to convert the data to a format visualization can use.
by default 'none' request handler is used which just passes the data it receives back, but can be changed to 'basic' (which VislibVisTypeFactory uses) or to a custom one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly will be done with the return value of this function? To what (scope) variable/prop will it be assigned?


Visualization gets all its parameters in `vis.params` (defaults merged with the current state). If it wants to update them it should update them in this object and then call `vis.updateState()` which will inform <visualize> about the change, which will call request and response handler and then your visualizations render method.

For the parameters that should not be saved with visualization you should use UI state (such as current state: popup open/closed, custom colors applied to the series etc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should custom colors applied to series, really not be saved with the visualization? It sounds like something, that would make sense to store in the visualization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colors are viewer specific (when you put it on dashboard you allow every person to customize them) thats why they are stored in uiState.


For the parameters that should not be saved with visualization you should use UI state (such as current state: popup open/closed, custom colors applied to the series etc)

You can access filter bar and time picker thru the objects defined on `vis.API`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thru -> through (for less colloquial language)?

@ppisljar
Copy link
Member Author

thanks a lot Tim! i'll go over all the comments tomorrow

@ppisljar ppisljar added review and removed WIP Work in progress labels Jul 19, 2017
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great and should really help plugin developers.

[[development-visualization-request-handlers]]
=== Visualization Request Handlers
Request handler gets called when one of the following keys on AppState change:
`vis`, `query`, `filters` or `uiState`. This sums up to pretty much every change to visualization. On top
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about aggs and time. Don't those cause requests as well?

which just passes the data it received back. The data object will then be passed to visualization.

[[development-default-response-handler]]
==== default response handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called the default response handler when the above paragraph states that "By default 'none' request handler is used". Maybe this should be called the 'tabular' response handler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the default should be default, none should be possible but unadvised.
with 'none' visualization gets pure es data in which:

  • is hard to work with
  • might change in the future
  • locks visualization to being used with es responses only

@thomasneirynck
Copy link
Contributor

jenkins, test this

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitting, because i dont want to lose my notes (#14252). ill move these to the new one. That new PR and my notes crossed eachother.


Easiest way to add new visualizations to kibana or to show existing kibana visualizations in your plugin is using
Visualize Plugin. This part of documentation is split into two parts. First part will tell you all you need to know to
use existing kibana visualization in your plugin and second step will focus on creating your own custom visualization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider slight rewrite wrt language:

Kibana Visualizations are the easiest way to add additional functionality to Kibana. This part of documentation is split into two parts. The first part tells you all you need to know on how to embed existing Kibana Visualizations in your plugin. The second step explains how to create your own custom visualization.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a short hedge. This is not public API (yet).

These pages document internal APIs and are not guaranteed to be supported across future versions of Kibana. However, these docs will be kept up-to-date to reflect the current implementation of Visualization plugins in Kibana.

[[development-using-visualizations]]
=== Using Visualizations

There are two ways to insert visualization in your page. Using `<visualize>` directive or using `<visualization>` directive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:

There are two different angular directives you can use to insert a visualization in your page. To display an already saved visualization, use the <visualize> directive. To reuse an existing Visualization implementation for a more custom purpose, use the <visualization> directive instead.

@@ -0,0 +1,90 @@
[[development-using-visualizations]]
=== Using Visualizations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider Embedding Visualizations

`<visualize>` directive takes a savedVis object and it takes care of loading data, parsing data,
rendering the editor (if in edit mode) and rendering the visualization. Its the easiest way to add visualization to your
page under the assumption that the visualization you are trying to display is saved in kibana. If that is not the case
take a look at using <visualization> directive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small language typos:

The <visualize> directive takes care of loading data, parsing data, rendering the editor (if the Visualization is in edit mode) and rendering the visualization. The directive takes a savedVis object for its configuration. It is the easiest way to add visualization to your page under the assumption that the visualization you are trying to display is saved in kibana. If that is not the case, take a look at using <visualization> directive.

page under the assumption that the visualization you are trying to display is saved in kibana. If that is not the case
take a look at using <visualization> directive.

Once <visualize> is done rendering the element will emit `renderComplete` event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove. Already explained at end of this section.


[[development-vis-object]]
=== Vis object
Vis object holds the visualization state and is the window into kibana:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vis object holds the visualization state and is the window into Kibana:

- *vis.API.events.click*: default click handler
- *vis.API.events.brush*: default brush handler

Visualization gets all its parameters in `vis.params` (defaults merged with the current state).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visualization gets all its parameters in vis.params, which are default values merged with the current state.

- *vis.API.events.brush*: default brush handler

Visualization gets all its parameters in `vis.params` (defaults merged with the current state).
If it wants to update them it should update them in this object and then call `vis.updateState()`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the visualization needs to update the current state, it should update the vis.params ...

Visualization gets all its parameters in `vis.params` (defaults merged with the current state).
If it wants to update them it should update them in this object and then call `vis.updateState()`
which will inform <visualize> about the change, which will call request and response handler and then your
visualizations render method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visualization's

which will inform <visualize> about the change, which will call request and response handler and then your
visualizations render method.

For the parameters that should not be saved with visualization (are viewer specific) you should use UI state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the parameters that should not be saved with the visualization you should use the UI state. These hold viewer-specific state, such as ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review Team:Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants