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

[Vega] Write tutorials and reference #71028

Merged
merged 5 commits into from
Jul 15, 2020
Merged

Conversation

wylieconlon
Copy link
Contributor

@wylieconlon wylieconlon commented Jul 8, 2020

Preview
Diff

Closes #70478
Closes #70267

@wylieconlon wylieconlon added Team:Docs Feature:Vega Vega visualizations v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels Jul 8, 2020
@wylieconlon wylieconlon requested review from nyurik, alexwizp, KOTungseth and a team July 8, 2020 00:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-docs (Team:Docs)

Copy link
Contributor

@nyurik nyurik left a 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.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Build custom visualizations using Vega and Vega-Lite, backed by any
Build custom visualizations using Vega and Vega-Lite, backed by one or more

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:
Copy link
Contributor

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.


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.
Copy link
Contributor

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.


* 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 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

* 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
Copy link
Contributor

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?

* 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}.
Copy link
Contributor

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 ;)

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
Copy link
Contributor

Choose a reason for hiding this comment

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

why reformat?

docs/visualize/vega.asciidoc Outdated Show resolved Hide resolved
@timroes timroes mentioned this pull request Jul 14, 2020
20 tasks
@wylieconlon
Copy link
Contributor Author

@nyurik Can you take another look? I updated the intro and rewrote the Vega tutorial, which I think addresses your feedback.

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.

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',
Copy link
Contributor

Choose a reason for hiding this comment

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

🕵️‍♂️ good catch

* *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.
Copy link
Contributor

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've clarified this

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* 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
Copy link
Contributor

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.

Copy link
Contributor Author

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>>
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 300 to 301
Open the browser dev tools console and type
`VEGA_DEBUG.view.data('data_0')`. You will see:
Copy link
Contributor

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."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}
}
}]
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* `{%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`
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* https://vega.github.io/vega/docs/[Docs]
* https://vega.github.io/vega/examples/[Examples]

TIP: When you use the examples, you may
Copy link
Contributor

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 ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@wylieconlon wylieconlon requested a review from nyurik July 15, 2020 18:01
@wylieconlon
Copy link
Contributor Author

@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?

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
visTypeVega 2.1MB +17.0B 2.1MB

miscellaneous assets size

id value diff baseline
upgradeAssistant 22.5KB -28.0B 22.6KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@KOTungseth KOTungseth left a comment

Choose a reason for hiding this comment

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

LGTM!

@wylieconlon wylieconlon merged commit 97d8128 into elastic:master Jul 15, 2020
@wylieconlon wylieconlon deleted the vega-docs branch July 15, 2020 18:51
wylieconlon pushed a commit to wylieconlon/kibana that referenced this pull request Jul 15, 2020
* [Vega] Improve all Vega docs

* Rewrite Vega tutorial to introduce from empty visualization

* Update from feedback
wylieconlon pushed a commit to wylieconlon/kibana that referenced this pull request Jul 15, 2020
* [Vega] Improve all Vega docs

* Rewrite Vega tutorial to introduce from empty visualization

* Update from feedback
wylieconlon pushed a commit that referenced this pull request Jul 15, 2020
* [Vega] Improve all Vega docs

* Rewrite Vega tutorial to introduce from empty visualization

* Update from feedback
wylieconlon pushed a commit that referenced this pull request Jul 16, 2020
* [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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Vega Vega visualizations release_note:skip Skip the PR/issue when compiling release notes Team:Docs v7.9.0 v8.0.0
Projects
None yet
6 participants