Skip to content

Commit

Permalink
fix(#6708): change domain order for union with (#8451)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
ZacharyBys and GitHub Actions Bot committed Oct 10, 2022
1 parent ac50b06 commit d4591fb
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 2 deletions.
Binary file added examples/compiled/arc_color_mappings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/compiled/arc_color_mappings.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions examples/compiled/arc_color_mappings.vg.json
@@ -0,0 +1,77 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A simple pie chart with embedded data.",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"data": [
{
"name": "source_0",
"values": [
{"category": 1, "value": 4},
{"category": 2, "value": 6},
{"category": 3, "value": 10},
{"category": 4, "value": 3},
{"category": 5, "value": 7},
{"category": 6, "value": 8}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": [],
"field": "value",
"sort": {"field": ["category"], "order": ["ascending"]},
"as": ["value_start", "value_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"value\"]) && isFinite(+datum[\"value\"])"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "arc",
"style": ["arc"],
"from": {"data": "data_0"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"outerRadius": {"signal": "min(width,height)/2"},
"innerRadius": {"value": 0},
"startAngle": {"scale": "theta", "field": "value_end"},
"endAngle": {"scale": "theta", "field": "value_start"}
}
}
}
],
"scales": [
{
"name": "theta",
"type": "linear",
"domain": {"data": "data_0", "fields": ["value_start", "value_end"]},
"range": [0, 6.283185307179586],
"zero": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"fields": [[5, 6], {"data": "data_0", "field": "category"}]},
"range": ["purple", "green", "blue", "yellow", "magenta", "brown"]
}
],
"legends": [{"fill": "color", "symbolType": "circle", "title": "category"}]
}
60 changes: 60 additions & 0 deletions examples/specs/arc_color_mappings.vl.json
@@ -0,0 +1,60 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple pie chart with embedded data.",
"data": {
"values": [
{
"category": 1,
"value": 4
},
{
"category": 2,
"value": 6
},
{
"category": 3,
"value": 10
},
{
"category": 4,
"value": 3
},
{
"category": 5,
"value": 7
},
{
"category": 6,
"value": 8
}
]
},
"mark": "arc",
"encoding": {
"theta": {
"field": "value",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal",
"scale": {
"range": [
"purple",
"green",
"blue",
"yellow",
"magenta",
"brown"
],
"domain": {
"unionWith": [
5,
6
]
}
},
"sort": null
}
}
}
2 changes: 1 addition & 1 deletion src/compile/scale/domain.ts
Expand Up @@ -251,7 +251,7 @@ function parseSingleChannelDomain(

const unionWith = convertDomainIfItIsDateTime(domain.unionWith, type, timeUnit);

return makeExplicit([...defaultDomain.value, ...unionWith]);
return makeExplicit([...unionWith, ...defaultDomain.value]);
} else if (isSignalRef(domain)) {
return makeExplicit([domain]);
} else if (domain && domain !== 'unaggregated' && !isParameterDomain(domain)) {
Expand Down
2 changes: 1 addition & 1 deletion test/compile/scale/domain.test.ts
Expand Up @@ -50,7 +50,7 @@ describe('compile/scale', () => {
});

const xDomain = testParseDomainForChannel(model, 'x');
expect(xDomain).toEqual([{data: 'main', field: 'a'}, [0, 100]]);
expect(xDomain).toEqual([[0, 100], {data: 'main', field: 'a'}]);
});

it('correctly parse signal domain', () => {
Expand Down

0 comments on commit d4591fb

Please sign in to comment.