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

updating metricvis interpreter func arguments #34532

Merged
merged 92 commits into from
Jun 28, 2019

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Apr 4, 2019

Summary

updating metricvis interpreter func arguments:

  • properties were extracted out of visConfig json to actual arguments
  • dimensions are using visdimension helper function

for example:
metricvis visConfig='"dimensions": {"metric": { "accessor": 1 }, "bucket": { "accessor": 0, "format": { "type": "ip" }}}, "metric": { "labels": {"show": true}, "percentage": true }}'
becomes:
metricvis metric={vis_dimension 1} bucket={vis_dimension 0 format='ip'} showLabels=true percentage=true

using multiple metric dimensions:
metricvis metric={vis_dimension 1} metric={vis_dimension 0} metric={vis_dimension 1} showLabels=true

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@ppisljar ppisljar added the WIP Work in progress label Apr 4, 2019
@ppisljar ppisljar requested review from w33ble and lukeelmers April 4, 2019 11:11
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the interpreter/semantics/metric branch from bd2f784 to 08156e5 Compare April 4, 2019 14:21
@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Makes sense to me - had a few nits around the help text for some of these args, otherwise no major concerns.

This also reinforces how it'll be helpful to refactor the build_pipeline utility to clean up some of this string concatenation. Still something on my near-to-midterm list

types: ['boolean'],
default: false,
help: i18n.translate('metricVis.function.percentage.help', {
defaultMessage: 'Shows metric in percentage mode. Dont forget to set colorRange.'
Copy link
Member

Choose a reason for hiding this comment

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

Dont -> Don't

Or would it be better to say Requires colorRange to be set?

types: ['string'],
default: '"Green to Red"',
help: i18n.translate('metricVis.function.colorSchema.help', {
defaultMessage: 'Color schema to use'
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to describe this besides "Color schema"? It feels like the type of thing that wouldn't be immediately intuitive to a user

Copy link
Member

Choose a reason for hiding this comment

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

Also (I don't know the answer to this): should colorSchema have a list of options? e.g.

options: ['Green to Red', 'Blah to blahblah'],

Copy link
Contributor

@w33ble w33ble Apr 8, 2019

Choose a reason for hiding this comment

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

nit: "Color scheme" (not schema) seems like the right name here too, at least as an alias.

style: {
bgFill: args.bgFill,
bgColor: args.colorMode === 'Background',
labelColor: args.colorMode === 'Label',
Copy link
Member

Choose a reason for hiding this comment

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

Nice, I like how colorMode simplifies these

@@ -21,7 +21,7 @@ import { functionsRegistry } from 'plugins/interpreter/registries';
import { i18n } from '@kbn/i18n';

export const metric = () => ({
name: 'kibana_metric',
name: 'metricvis',
Copy link
Member

Choose a reason for hiding this comment

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

nit: should this be camelCase if we are avoiding underscores? metricVis

types: ['string'],
default: '"[{ from: 0, to: 10000 }]"',
help: i18n.translate('metricVis.function.colorRange.help', {
defaultMessage: 'Color ranges'
Copy link
Member

Choose a reason for hiding this comment

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

I think more specific help text would be useful here (TBH i'm not sure how colorRange even works)

Copy link
Member Author

Choose a reason for hiding this comment

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

well its just array of objects with from and to property .... we probably want to create another helper function here to generate this objects, and maybe use a multi agg then ? @w33ble ?

Copy link
Contributor

@w33ble w33ble Apr 8, 2019

Choose a reason for hiding this comment

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

Yeah, making users type JSON is pretty much always the wrong thing to do. You could split the args into "from" and "to", or make a new function. I also don't know what this does so it's hard for me to decide which, or offer much more input.

That help text also isn't very helpful 😛

Copy link
Contributor

@w33ble w33ble Apr 8, 2019

Choose a reason for hiding this comment

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

...I wonder if it makes sense to put colorSchema (or colorScheme), colorMode, and even invertColors into its own function too. Are these concepts shared with other visualizations? If so, even partially, a new function (and type) probably makes sense.

There's a lot of "color" concepts to deal with as it is now, and I don't know what is unique to this vis.

@ppisljar ppisljar force-pushed the interpreter/semantics/metric branch from 08156e5 to bab5600 Compare April 8, 2019 10:25
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

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

Some change requests, nit ones would be nice but are not required.

useRanges: args.useRanges,
colorSchema: args.colorSchema,
metricColorMode: args.colorMode,
colorsRange: JSON.parse(args.colorRange),
Copy link
Contributor

Choose a reason for hiding this comment

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

Making users type JSON is pretty much always the wrong thing to do.

},
fontSize: {
types: ['number'],
default: 60,
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 have a help property.

types: ['string'],
default: `'[{ "from": 0, "to": 10000 }]'`,
help: i18n.translate('metricVis.function.colorRange.help', {
defaultMessage: 'Color ranges: array of objects with from and to property.'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you're one of maybe 6 people that understands the vis object. The rest of us need more guidance than this... what do these numbers mean/do?

Copy link
Member Author

Choose a reason for hiding this comment

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

creates color range. for example passing in an array:

[
 { from: 0, to: 100 },
 { from: 100, to: 200 },
]

will color metric in the "first color" (in scheme) if its value is between 0-100 and in second color if value is between 100 and 200

Copy link
Contributor

Choose a reason for hiding this comment

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

That's more helpful than "array of objects with from and to property", and that makes it sound like this should both be part of a new function and be a multi arg (multi: true).

Copy link
Member

Choose a reason for hiding this comment

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

@ppisljar I think for clarity we should update this help text since the user isn't expected to provide an array -- they just use the arg multiple times and the parser handles it for them. Maybe something like:

Suggested change
defaultMessage: 'Color ranges: array of objects with from and to property.'
defaultMessage: 'A range object specifying groups of values to which different colors should be applied.'

@w33ble
Copy link
Contributor

w33ble commented Apr 8, 2019

I don't fully understand all the args here, but some thoughts:

  • fontSize could instead be controlled with the existing font function
  • Since percentage and colorsRange are coupled, a new function might make sense
  • It looks like colorMode allows customizing the label or the background, but not both; putting all 3 associated args (colorSchema, colorMode, and I think maybe invertColors, but that might be wrong) behind a function may make sense; and then maybe both can be controlled with other enhancements too

@ppisljar
Copy link
Member Author

ppisljar commented Apr 9, 2019

@w33ble it feels like we'll end up with quite some helper functions, that can only be used with 1 or maybe 2 other functions. Whats canvas approach here ? Should we worry about having too many functions that can't be used independently or is that completely ok ?

feels also like we should do some additional work on visualization itself ...
for example if we would to use font function, maybe it makes sense if we actually allow users to change the font, not just fontsize, with it. (but all the options font can handle ?)

@w33ble
Copy link
Contributor

w33ble commented Apr 9, 2019

Should we worry about having too many functions that can't be used independently or is that completely ok ?

That's OK, we have a bit of that in canvas. There is a line of course, but a single-use function here or there is fine. It's better if the thing the function does can be re-used of couse, which is why a lot of my feedback was trying to group concepts.

for example if we would to use font function, maybe it makes sense if we actually allow users to change the font, not just fontsize, with it.

Yes it is, but that's also something you can do later. The font function is general and encapsulates a concept. Even if you don't use all the parts it can provide, it's still useful, and can work the same way even if the user switches to a different function. And you can make upstream changes to support more font properties and the expression does not change, it just starts doing more than it previously did.

The same could be true for controlling colors, like via a "colorConfig" object, which could be plugged into any argument that controls a color in nearly any function. Maybe... that's the idea I was trying to get across, but I don't know how all these vis objects work so I can't provide more than abstract ideas.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar
Copy link
Member Author

ppisljar commented May 8, 2019

@w33ble using font function requires it to be moved to open source. I took a look on what that would take and i think this is it:

  • move font interpreter function
  • move lib/fonts.js
  • move some types over

are you ok with going down this route ?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@w33ble
Copy link
Contributor

w33ble commented May 20, 2019

@ppisljar I don't see an issue with that off-hand. Are there side effects I'm not aware of? Nothing's really special about that function, there's no reason it can't be in OSS.

@LeeDr LeeDr added v7.3.0 and removed v7.2.0 labels May 23, 2019
@ppisljar ppisljar force-pushed the interpreter/semantics/metric branch from d9b3451 to afba947 Compare June 27, 2019 11:46
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

LGTM!

Just wanted to double check this question I had to be sure the help text is okay: #34532 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes review v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants