-
Notifications
You must be signed in to change notification settings - Fork 44
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
API Option #34
Comments
This is a very good point. One problem here is what if a particular field name has two functions? It's unclear how to resolve this. Another possibly better alternative is to make the API a list of array instead of dictionary as I suggested yesterday. (And since it's an array, we can have |
I see your point. I think I like the array approach better too as I don't have to overwrite user-provided field names :) So with the array approach, the var options =
{
// user provides these
fields: ['field1', 'field2', 'field3'],
fieldConfigs: // user provides, vlSpec supplements
{
'field1':
{
title: 'title1',
type: 'number' | 'time' | undefined,
format: string-specifier
}
}
colorTheme: 'light' | 'dark',
// vlSpec supplements these
bin: ['field1'],
timeUnit: {'field2': 'yearmonth'},
aggregate: {'field3': ['sum', 'mean']}
}; When user provides a field name that doesn't match field names in When user doesn't provide |
This looks very complicated and it's not really an array? Also,
What if we want a field with multiple aggregation functions? I really wonder if we really need to decouple field list from config? This seems simpler, with additional var options =
{
// user provides these
fields: [
{
field: 'field1',
aggregate: ..., // can be explicitly specified, but can be automatically inferred
timeUnit: ..., // can be explicitly specified, but can be automatically inferred
bin: true | false // can be explicitly specified, but can be automatically inferred
title: ..., // default = <func>(<field-name>)
formatType: ..., // don't name this "type" it's confusing.
format: ...
},
...
}],
showUnspecifiedFields: true | false // true by default?
colorTheme: 'light' | 'dark'
}; |
If we don't decouple I think decoupling also works well with vlSpec supplementing formats. Imagine if vlSpec supplemented |
Well,
If you really worry about typing, we could support a shorthand like
Even without shorthand, the config proposal can be verbose and repeat field names multiple times, plus it is unclear how to deal with repeated fields with different functions as mentioned earlier.
I don't know what's the problem here. vlTooltip should supplement format for a field from the Vega-Lite spec only if (1) the field is in the list or (2) If you mean user might want to manually configure format even though the field is not a part of the list, that case also doesn't happen because you would only want to configure the displayed field. |
I think for For Similarly, for |
I agree with @kanitw that we don't need to separate field and field configs if we have the |
OK, I'm happy to go with the combined way with |
@domoritz I think the user won't have to specify |
Instead of |
New var options =
{
showAllFields: true | false | undefined, // true by default, undefined equals true
customFields: [
{
field: 'field1', // user provides (vlSpec supplements when showAllFields === true || undefined)
title: ..., // user provides, vlSpec supplements
formatType: ..., // user provides, vlSpec supplements
format: string-specifier, // user provides, vlSpec supplements
aggregate: ['max', 'sum'], // vlSpec supplements
timeUnit: 'yearmonth' // vlSpec supplements
bin: true | false // vlSpec supplements
},
...
}],
colorTheme: 'light' | 'dark'
};
// When options is undefined, tooltip creates an options object, sets showAllFields to true,
// and supplement customFields using information from vlSpec.
// When showAllFields is true, tooltip supplements customFields using vlSpec, adding new fields
// to customFields when necessary
// When showAllFields is false, tooltip only supplements existing fields in customFields
// When showAllFields is undefined, tooltip sets it to true, and supplement customFields using vlSpec,
// adding new fields to customFields when necessary |
I would say just name it For ( |
You mean it's possible to have repeated fields like below? var options =
{
fields: [
{
field: 'field1',
aggregate: 'sum' // vlSpec supplements
},
{
field: 'field1',
aggregate: 'max' // vlSpec supplements
}
}]
}; And this is what |
Yes.
Because different aggregation function produces multiple fields in the output aggregated table. |
I know from Vega-Lite code that there is |
We fixed that just two days ago vega/vega-lite#1295. You might have to pull to see it. |
@kanitw I think I still prefer having Also, when What do you think? |
I disagree.
Your output SHOULD display multiple aggregate fields (e.g., Thus, making the API clear that you're displaying multiple aggregate fields is better (esp. if |
@domoritz That's good to know. I built the latest vega-lite code and used it locally in tooltip. I'm using |
Ah, I see... Now I agree with you that we should have repeated fields in |
Would a user ever need to specify var options =
{
showAllFields: false,
fields: [
{
field: 'field1',
aggregate: 'min'
},
{
field: 'field1',
aggregate: 'max'
}
]
} to explicitly specify she wants to show both Or, should a user just provide: var options =
{
showAllFields: false,
fields: [
{
field: 'field1'
}
]
} to more vaguely say that she wants to show I guess the first (more explicit) way is better? Because the user can, for example, show only |
This is part of PR #16. Here's how var options =
{
colorTheme: 'light' | 'dark',
showAllFields: true | false | undefined,
fields: [
{
field: 'field1', // user provides, vlSpec supplements underscore prefixes
title: 'Field One',
formatType: 'time' | 'number' | 'string',
format: string-specifier,
aggregate: operation,
},
...
}]
}; |
Generally we want the user to write a field name without any underscore prefixes in
options.fields
andoptions.fieldConfigs
. Then the tooltip plugin supplements the field names with underscore prefixes derived from vlSpec. We want to supplement the user-provided field names in order to match the field names returned byitem.datum
.For aggregated fields, user should provide field name (e.g.
'yield'
). Then tooltip supplements the field name with the aggregate operation (e.g.'mean_yield'
). This should match the field names initem.datum
.One exception is the aggregate operation
count
, where the field name is'*'
. In this case the supplemented field name should be'count'
instead of'count_*'
For fields with
timeUnit
, user should provide the field name (e.g.'date'
). Tooltip supplements the field name with thetimeUnit
(e.g.'month_date'
).For binned fields, user should provide field name (e.g.
'Acceleration'
). Tooltip supplements the field name with'bin_'
(e.g.'bin_Acceleration'
). In runtime the tooltip plugin calculates the range of the bin field (issue #29).If user don't provide
options.fields
, tooltip supplementsoptions.fields
with allfieldDefs
in the vlSpec, using the underscore prefixes described above.The text was updated successfully, but these errors were encountered: