Skip to content

Commit

Permalink
fix: automatically add steps if density transform is grouped (#8088)
Browse files Browse the repository at this point in the history
* fix: automatically add steps if density transform is grouped

* chore: update examples [ci skip]

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
domoritz and GitHub Actions Bot committed Apr 4, 2022
1 parent 2ed3b1d commit c95806f
Show file tree
Hide file tree
Showing 29 changed files with 38 additions and 16 deletions.
Binary file modified examples/compiled/area_density.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/area_density.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/area_density_facet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/area_density_facet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion examples/compiled/area_density_facet.vg.json
Expand Up @@ -14,7 +14,8 @@
"field": "Body Mass (g)",
"groupby": ["Species"],
"extent": [2500, 6500],
"as": ["value", "density"]
"as": ["value", "density"],
"steps": 200
},
{
"type": "impute",
Expand Down
Binary file modified examples/compiled/area_density_stacked.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/area_density_stacked.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion examples/compiled/area_density_stacked.vg.json
Expand Up @@ -17,7 +17,8 @@
"field": "Body Mass (g)",
"groupby": ["Species"],
"extent": [2500, 6500],
"as": ["value", "density"]
"as": ["value", "density"],
"steps": 200
},
{
"type": "impute",
Expand Down
Binary file modified examples/compiled/errorband_2d_horizontal_color_encoding.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/errorband_2d_vertical_borders.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/errorband_2d_vertical_borders.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/errorbar_2d_vertical_ticks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/errorbar_2d_vertical_ticks.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/layer_line_errorband_ci.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/layer_line_errorband_ci.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/layer_line_window.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/layer_point_errorbar_2d_horizontal_ci.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/layer_point_errorbar_ci.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/layer_point_errorbar_ci.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/compiled/sample_scatterplot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/sample_scatterplot.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/trellis_selections.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/compiled/vega_version
@@ -1 +1 @@
vega: 5.21.0
vega: 5.22.1
5 changes: 5 additions & 0 deletions src/compile/data/density.ts
Expand Up @@ -16,6 +16,11 @@ export class DensityTransformNode extends DataFlowNode {
this.transform = duplicate(transform); // duplicate to prevent side effects
const specifiedAs = this.transform.as ?? [undefined, undefined];
this.transform.as = [specifiedAs[0] ?? 'value', specifiedAs[1] ?? 'density'];

// set steps when we are grouping so that we get consitent sampling points for imputing and grouping
if (transform.groupby && transform.minsteps == null && transform.maxsteps == null && transform.steps == null) {
this.transform.steps = 200;
}
}

public dependentFields() {
Expand Down
15 changes: 15 additions & 0 deletions test/compile/data/density.test.ts
Expand Up @@ -56,6 +56,21 @@ describe('compile/data/fold', () => {
as: ['A', 'density']
});
});

it('should add steps if we group', () => {
const transform: Transform = {
density: 'v',
groupby: ['a']
};
const density = new DensityTransformNode(null, transform);
expect(density.assemble()).toEqual({
type: 'kde',
groupby: ['a'],
field: 'v',
steps: 200,
as: ['value', 'density']
});
});
});

describe('dependentFields', () => {
Expand Down

0 comments on commit c95806f

Please sign in to comment.