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

Add Reformat as JSON Option (Keep Comments) For Vega Editor #68674

Closed
nimocks opened this issue Jun 9, 2020 · 9 comments
Closed

Add Reformat as JSON Option (Keep Comments) For Vega Editor #68674

nimocks opened this issue Jun 9, 2020 · 9 comments
Labels
enhancement New value added to drive a business result Feature:Vega Vega visualizations Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@nimocks
Copy link

nimocks commented Jun 9, 2020

The Vega editor currently has 2 options when you click the wrench.

  1. Reformat as HJSON
  2. Reformat as JSON, delete comments

We are requesting another option.
3. Reformat as JSON, keep comments

In our Vega code we have a header for change tracking with versions and releases as well as inline code explaining what is going on. So we don't need to write/maintain this code in another place it would be great if we can just reformat as JSON but keep the comments.

@flash1293 flash1293 added Feature:Vega Vega visualizations Team:Visualizations Visualization editors, elastic-charts and infrastructure triage_needed labels Jun 10, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@flash1293
Copy link
Contributor

Can you elaborate on how that would look like? The JSON spec doesn't support comments, so I'm not sure how we could keep them when formatting the spec as JSON.

@nimocks
Copy link
Author

nimocks commented Jun 10, 2020

Can you elaborate on how that would look like? The JSON spec doesn't support comments, so I'm not sure how we could keep them when formatting the spec as JSON.

The same way Visual Studio Code and other IDE's maintain comments but allow formatting I'd assume.

  1. It would require stripping comments and saving the position.
  2. Reformat JSON.
  3. Insert comments back in the position they were.

Without this I have to maintain my Vega JSON object in VS Code and copy/paste back and forth which is not a tremendous burden but anything that increases productivity I am game for.

@flash1293
Copy link
Contributor

I have to admit I never came across this - my IDE is throwing an error when I try to use comments in JSON:
Screenshot 2020-06-10 at 14 38 13

Thanks for the explanation though, I think I understand your use case - you want to format the current spec to look like JSON, with comment support but without the additional syntax HJSON offers, right? Is it because you don't like the other parts of the HJSON syntax? Just trying to understand the problem this feature request is addressing.

@nimocks
Copy link
Author

nimocks commented Jun 10, 2020

I don't use HJSON because most my work is done in https://vega.github.io/editor/#/ due to the ease of development. Then I will copy the code over when done or ready to start using elasticsearch data.

The IDE will throw errors but still allows you to maintain comments and reformat as expected.

The default Vega Visualization when you add a new visualization contains comments in JSON. I am simply asking to maintain that functionality.

@flash1293
Copy link
Contributor

I am simply asking to maintain that functionality.

It's not a functionality, the default spec is just hardcoded like this. It's not JSON (as JSON is not allowed no include comments at all), it's HJSON which is mostly compatible with JSON except for the embedded comments.

I'm still not 100% sure how your workflow looks like (I tried using a spec containing comments and it seems like the vega editor you linked is just throwing errors without showing a chart or being able to format the spec), but I see the point of this functionality.

I'll label this an enhancement. Thanks for being responsive and explaining your use case!

@flash1293 flash1293 added enhancement New value added to drive a business result and removed triage_needed labels Jun 10, 2020
@nimocks
Copy link
Author

nimocks commented Jun 10, 2020

I tried using a spec containing comments and it seems like the vega editor you linked is just throwing errors without showing a chart or being able to format the spec

Correct. The editor doesn't allow comments there. They don't allow it but Kibana does.

My workflow goes like this.

  1. Develop prototype in github editor using hardcoded data set
  2. Move to Kibana
  3. Replace hardcoded data set with elasticsearch data
  4. Complete development
  5. Add comments where needed

Now when I go back and make revisions that require reformatting my workflow goes like this.

  1. Copy code from Kibana and paste in VS Code
  2. Format document
  3. Copy code from VS Code to Kibana and save

Thanks for your help on this.

@nimocks
Copy link
Author

nimocks commented Jun 10, 2020

After brainstorming with the team I think we have a solution that will work for us and anyone that wants to do this.

"transform": [
{
"type": "extent",
"comment1": "Add whatever we want",
"comment2": "Add whatever we want",
"comment3": "Add whatever we want",
"field": "year",
"signal": "years"
}
]

Just add fields for comments. It doesn't break the Vega visualization if there are fields that aren't used. Just ignores them.

@stratoula
Copy link
Contributor

Thank you for contributing to this issue, however, we are closing this issue due to inactivity as part of a backlog grooming effort. If you believe this feature/bug should still be considered, please reopen with a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Vega Vega visualizations Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants