-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Vega] Write tutorials and reference #71028
Conversation
Pinging @elastic/kibana-docs (Team:Docs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for adding all the wonderful docs for Vega! I added a few comments and suggestions inline.
docs/visualize/vega.asciidoc
Outdated
@@ -3,71 +3,2114 @@ | |||
|
|||
experimental[] | |||
|
|||
Build custom visualizations from multiple data sources using Vega | |||
and Vega-Lite. | |||
Build custom visualizations using Vega and Vega-Lite, backed by any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build custom visualizations using Vega and Vega-Lite, backed by any | |
Build custom visualizations using Vega and Vega-Lite, backed by one or more |
docs/visualize/vega.asciidoc
Outdated
that {kib} provides, but with higher complexity. The most common reason | ||
to use Vega in {kib} is that your data or | ||
visualization isn't supported in other tools in {kib}, so you need | ||
to use the more powerful tool. The most common reasons to use Vega in {kib} are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate "the most common reason" here and a few lines above.
docs/visualize/vega.asciidoc
Outdated
|
||
and click "Update". The result is probably not what you expect, because it shows | ||
a flat line with 0 results. This shows the first thing that you need to understand | ||
when writing a Vega spec in {kib}: small changes can lead to unexpected results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL :) As a first lesson, I think we should rather add something like "baby steps - make sure to frequently refresh (i.e. Ctrl+Enter or auto-apply) - to see the result of each minor change". But I'm not too sure of how to phrase it, so maybe its ok to leave as is.
docs/visualize/vega.asciidoc
Outdated
|
||
* Use intuition to guess at the problem | ||
* Open the browser dev tools and look at the Network tab to inspect the {es} request | ||
* Open the browser dev tools and type `VEGA_DEBUG.vegalite_spec.data` to inspect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Open the browser dev tools and type `VEGA_DEBUG.vegalite_spec.data` to inspect | |
* Open the browser dev tools console and type `VEGA_DEBUG.vegalite_spec.data` to inspect |
docs/visualize/vega.asciidoc
Outdated
* Open the browser dev tools and type `VEGA_DEBUG.vegalite_spec.data` to inspect | ||
the response from {es} | ||
* Build a comparable query using the {kib} Dev Tools and see if the results match | ||
* Copy the spec from `JSON.stringify(VEGA_DEBUG.vegalite_spec)` and paste into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably link to the vega editor?
docs/visualize/vega.asciidoc
Outdated
* Use `VEGA_DEBUG.view.data('source_0')` or `VEGA_DEBUG.view.data('data_0')` to | ||
understand the transformations that are applied after fetching data | ||
|
||
This complex debugging process will come up frequently while working on Vega in {kib}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should write "this complex debugging process" - no reason to scare people ahead of time ;)
docs/visualize/vega.asciidoc
Outdated
Now, let's make the visualization more interesting by adding another aggregation | ||
to create a stacked area chart. | ||
|
||
Click the wrench icon and select "Reformat as JSON, strip comments". Now, open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why reformat?
@nyurik Can you take another look? I updated the intro and rewrote the Vega tutorial, which I think addresses your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good overall. I've left a couple of suggestions. Most of them are optional.
Two additional notes. In line 1384 of the vega.asciidoc we're missing an opening backtick around "%timefield%", maybe we can also add it in this PR.
I wonder - since I assume a lot of people will come through the tutorial before jumping to the reference - if it's worth adding a note about %context% and %timefield% already into the tutorial when we first use it in the spec.
@@ -147,7 +147,7 @@ export class VegaBaseView { | |||
defaultMessage: | |||
'External URLs are not enabled. Add {enableExternalUrls} to {kibanaConfigFileName}', | |||
values: { | |||
enableExternalUrls: 'vega.enableExternalUrls: true', | |||
enableExternalUrls: 'vis_type_vega.enableExternalUrls: true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵️♂️ good catch
docs/visualize/vega.asciidoc
Outdated
* *Vega* — A declarative format to create visualizations using JSON. | ||
Generate interactive displays using D3. | ||
Vega and Vega-Lite are both declarative formats to create visualizations | ||
using JSON. Vega-Lite is an easier format to use that compiles into Vega. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "Vega-Lite is an easier but less powerful format to use [that compiles into Vega]."
Should we mention "compiles into Vega" in a user-facing documentation? Wording wise as, is this information relevant for users? (I am open for both, just lose thoughts.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've clarified this
docs/visualize/vega.asciidoc
Outdated
Vega and Vega-Lite are capable of building most of the visualizations | ||
that {kib} provides, but with higher complexity. The most common reason | ||
to use Vega in {kib} is that your data or | ||
visualization isn't supported in other tools in {kib}, especially |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Could we replace the "especially in these cases", by something a bit more lose like "for example the following cases". I feel (but threat this with the grain of salt of a non-native speaker), that in the current phrasing we kind of advertise using Vega in all those cases, while e.g. bucket script users could potentially find "better" solutions in other visualization tools inside Kibana.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
* Custom maps | ||
* Using a visual theme that {kib} does not provide | ||
|
||
Because Vega supports all of these, it is often easier to write a Vega spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Since we still officially don't recommend writing custom plugins (and e.g. don't allow them running into our cloud), I am not sure if we should make this comparison here at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
Go to `mark`, change the value to a different visualization type, then click | ||
*Update*. | ||
The first step is to change the index to one of the <<add-sample-data, sample data>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I mean kind of obvious, but wonder if we should still mention, that they should make sure the ecommerce sample data set is installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
Open the browser dev tools console and type | ||
`VEGA_DEBUG.view.data('data_0')`. You will see: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should change the phrasing here, to not look like too similar to the previous paragraph. I first thought it's a duplicate. So many we could write something like: "Now type VEGA_DEBUG.view.data('data_0')
into the console to see the data used by the chart."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
} | ||
} | ||
} | ||
}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet does not contain the opening [
, so we should remove the ]
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
the `"url"` value. | ||
{kib} registers a default https://vega.github.io/vega/docs/schemes/[Vega color scheme] | ||
with the id `elastic`, and sets a default color for each `mark` type. | ||
Override it by providing an alternate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The end of this sentence is somehow missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
* `{%timefilter%: true}`: Replaced by an {es} range query with upper and lower bounds | ||
* `{%timefilter%: "min" | "max"}`: Replaced only by the upper or lower bounds | ||
* `{%timefilter: true, shift: -1, unit: 'hour'}`: Generates a time range query one hour in the past | ||
* `{%autointerval%: true}`: Replaced by the string representing the time interval, such as `1h` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Let's clarify a bit more what "the time interval" means here, e.g. something like "Replaced by a string representing a reasonable sized interval, for most charts over time" (I don't like my version of this sentence, but something along those lines, maybe).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/visualize/vega.asciidoc
Outdated
* https://vega.github.io/vega/docs/[Docs] | ||
* https://vega.github.io/vega/examples/[Examples] | ||
|
||
TIP: When you use the examples, you may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "When you use the examples in Kibana, you may ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@alexwizp I am not documenting the new Vega inspector here because I'm trying to merge these docs for 7.9. Do you think we need a followup issue for 7.10 docs? |
💚 Build SucceededBuild metricsasync chunks size
miscellaneous assets size
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* [Vega] Improve all Vega docs * Rewrite Vega tutorial to introduce from empty visualization * Update from feedback
* [Vega] Improve all Vega docs * Rewrite Vega tutorial to introduce from empty visualization * Update from feedback
* [Vega] Write tutorials and reference (#71028) * [Vega] Improve all Vega docs * Rewrite Vega tutorial to introduce from empty visualization * Update from feedback * Fix image path by moving to new folder Co-authored-by: Elastic Machine <[email protected]>
Preview
Diff
Closes #70478
Closes #70267