-
-
Notifications
You must be signed in to change notification settings - Fork 668
fix: Arc mark does not stack for quantitative definitions when different fields are used for theta and radius [draft]
#9512
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
base: main
Are you sure you want to change the base?
Changes from all commits
2ea24ae
d071466
65c28e1
37ab111
6763a4a
c5eae62
9a260ed
f7f2600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| { | ||
| "$schema": "https://vega.github.io/schema/vega/v6.json", | ||
| "background": "white", | ||
| "padding": 5, | ||
| "width": 300, | ||
| "height": 300, | ||
| "style": "view", | ||
| "data": [ | ||
| { | ||
| "name": "source_0", | ||
| "values": [ | ||
| {"segment": 1, "value": 8}, | ||
| {"segment": 2, "value": 7}, | ||
| {"segment": 3, "value": 6} | ||
| ] | ||
| }, | ||
| { | ||
| "name": "data_0", | ||
| "source": "source_0", | ||
| "transform": [ | ||
| { | ||
| "type": "stack", | ||
| "groupby": [], | ||
| "field": "segment", | ||
| "sort": {"field": [], "order": []}, | ||
| "as": ["segment_start", "segment_end"], | ||
| "offset": "zero" | ||
| }, | ||
| { | ||
| "type": "filter", | ||
| "expr": "isValid(datum[\"segment\"]) && isFinite(+datum[\"segment\"]) && isValid(datum[\"value\"]) && isFinite(+datum[\"value\"])" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "marks": [ | ||
| { | ||
| "name": "marks", | ||
| "type": "arc", | ||
| "style": ["arc"], | ||
| "from": {"data": "data_0"}, | ||
| "encode": { | ||
| "update": { | ||
| "opacity": {"value": 0.5}, | ||
| "stroke": {"value": "#fff"}, | ||
| "innerRadius": {"value": 20}, | ||
| "fill": {"value": "#4c78a8"}, | ||
| "description": { | ||
| "signal": "\"segment: \" + (format(datum[\"segment\"], \"\")) + \"; value: \" + (format(datum[\"value\"], \"\"))" | ||
| }, | ||
| "x": {"signal": "width", "mult": 0.5}, | ||
| "y": {"signal": "height", "mult": 0.5}, | ||
| "outerRadius": {"scale": "radius", "field": "value"}, | ||
| "startAngle": {"scale": "theta", "field": "segment_end"}, | ||
| "endAngle": {"scale": "theta", "field": "segment_start"} | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "scales": [ | ||
| { | ||
| "name": "theta", | ||
| "type": "linear", | ||
| "domain": {"data": "data_0", "fields": ["segment_start", "segment_end"]}, | ||
| "range": [0, 6.283185307179586], | ||
| "zero": true | ||
| }, | ||
| { | ||
| "name": "radius", | ||
| "type": "sqrt", | ||
| "domain": {"data": "data_0", "field": "value"}, | ||
| "range": [20, {"signal": "min(width,height)/2"}], | ||
| "zero": true | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "$schema": "https://vega.github.io/schema/vega-lite/v6.json", | ||
| "data": { | ||
| "values": [ | ||
| { | ||
| "segment": 1, | ||
| "value": 8 | ||
| }, | ||
| { | ||
| "segment": 2, | ||
| "value": 7 | ||
| }, | ||
| { | ||
| "segment": 3, | ||
| "value": 6 | ||
| } | ||
| ] | ||
| }, | ||
| "mark": { | ||
| "type": "arc", | ||
| "innerRadius": 20, | ||
| "stroke": "#fff", | ||
| "opacity": 0.5 | ||
| }, | ||
| "encoding": { | ||
| "theta": { | ||
| "field": "segment", | ||
| "type": "quantitative", | ||
| "stack": true | ||
| }, | ||
| "radius": { | ||
| "field": "value", | ||
| "scale": { | ||
| "type": "sqrt", | ||
| "zero": true, | ||
| "rangeMin": 20 | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import {array, hasOwnProperty, isBoolean} from 'vega-util'; | ||
| import {Aggregate, SUM_OPS} from './aggregate.js'; | ||
| import {getSecondaryRangeChannel, NonPositionChannel, NONPOSITION_CHANNELS} from './channel.js'; | ||
| import {getSecondaryRangeChannel, NonPositionChannel, NONPOSITION_CHANNELS, isPolarPositionChannel} from './channel.js'; | ||
| import { | ||
| channelDefType, | ||
| FieldName, | ||
|
|
@@ -176,8 +176,13 @@ export function stack(m: Mark | MarkDef, encoding: Encoding<string>): StackPrope | |
| if (encoding[dimensionChannel]) { | ||
| const dimensionDef = encoding[dimensionChannel]; | ||
| const dimensionField = isFieldDef(dimensionDef) ? vgField(dimensionDef, {}) : undefined; | ||
| const hasSameDimensionAndStackedField = dimensionField && dimensionField === stackedField; | ||
|
|
||
| if (dimensionField && dimensionField !== stackedField) { | ||
| // For polar coordinates, do not set a groupBy when working with quantitative fields. | ||
| const isPolar = isPolarPositionChannel(fieldChannel) || isPolarPositionChannel(dimensionChannel); | ||
| const shouldAddPolarGroupBy = !isUnbinnedQuantitative(dimensionDef); | ||
|
|
||
| if (isPolar ? shouldAddPolarGroupBy : !hasSameDimensionAndStackedField) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we really need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By strictly check, do you mean we'd check if
for both polar and cartesian graphs? Currently if I just remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made a PoC commit to see if this is what you had in mind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
can't find this link There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found it interesting to see how many of the visual tests break if I removed the check that only applies this change to polar encodings. |
||
| // avoid grouping by the stacked field | ||
| groupbyChannels.push(dimensionChannel); | ||
| groupbyFields.add(dimensionField); | ||
|
|
@@ -237,7 +242,6 @@ export function stack(m: Mark | MarkDef, encoding: Encoding<string>): StackPrope | |
| if (!offset || !isStackOffset(offset)) { | ||
| return null; | ||
| } | ||
|
|
||
| if (isAggregate(encoding) && stackBy.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.