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

Layer #1241

Merged
merged 36 commits into from
Mar 20, 2016
Merged

Layer #1241

merged 36 commits into from
Mar 20, 2016

Conversation

domoritz
Copy link
Member

  • merge scales
  • layout
  • axes
  • legends
  • marks
  • data
    • generate separate data source for different filters
    • correctly set up bin

Need to get these working:

{
  "data": {"url": "data/stocks.csv","formatType": "csv"},
  "layers": [
    {
      "mark": "line",
      "encoding": {
        "x": {"field": "date","type": "temporal"},
        "y": {"field": "price","type": "quantitative"},
        "color": {"field": "symbol","type": "nominal"}
      }
    },
    {
      "mark": "rule",
      "encoding": {
        "x": {
          "field": "date",
          "type": "temporal",
          "aggregate": "mean"
        },
        "color": {"value": "red"}
      }
    }
  ]
}

screen shot 2016-03-16 at 19 04 07

{
  "data": {"url": "data/flights-2k.json"},
  "layers": [
    {
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "distance",
          "type": "quantitative",
          "bin": true
        },
        "y": {
          "aggregate": "count",
          "field": "*",
          "type": "quantitative"
        }
      }
    },
    {
      "transform": {"filter": "datum.delay < 5"},
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "distance",
          "type": "quantitative",
          "bin": true
        },
        "y": {
          "aggregate": "count",
          "field": "*",
          "type": "quantitative"
        },
        "color": {"value": "goldenrod"}
      }
    }
  ]
}

screen shot 2016-03-17 at 17 12 51

@domoritz
Copy link
Member Author

My test spec

{
  "data": {
    "values": [
      {"a": "A","b": "B","c": 28,"d": "a"}, {"a": "B","b": "C","c": 55,"d": "a"},
      {"a": "C","b": "D","c": 43,"d": "a"}, {"a": "D","b": "E","c": 91,"d": "a"},
      {"a": "E","b": "F","c": 81,"d": "a"}, {"a": "F","b": "G","c": 53,"d": "b"},
      {"a": "G","b": "H","c": 19,"d": "b"}, {"a": "H","b": "I","c": 87,"d": "c"},
      {"a": "I","b": "A","c": 52,"d": "c"}
    ]
  },
  "layers": [
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "a","type": "ordinal"},
        "y": {"field": "c","type": "quantitative"},
        "color": {"field": "d", "type": "nominal"}
      }
    }, {
      "mark": "line",
      "encoding": {
        "x": {"field": "b","type": "ordinal"},
        "y": {"field": "c","type": "quantitative"},
        "color": {"value": "purple"}
      }
    }, {
      "mark": "rule",
      "encoding": {
        "y": {"field": "c", "type": "quantitative", "aggregate": "mean"},
        "color": {"field": "d", "type": "nominal"},
        "size": {"field": "c", "type": "quantitative", "aggregate": "max"}
      }
    }
  ]
}

screen shot 2016-03-17 at 18 55 54

* Function to rename the dataset name using the name map. Used in the assemble step.
*/
public dataRename(name: string): string {
return this._dataNameMap.get(name);
Copy link
Member

Choose a reason for hiding this comment

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

This is get, not rename. I also have the renameData method right above on line 226.

@@ -287,13 +298,11 @@ export namespace formatParse {
// if there is no parse needed
model.forEach(function(fieldDef: FieldDef) {
if (fieldDef.type === TEMPORAL) {
parseComponent = parseComponent || {};
Copy link
Member

Choose a reason for hiding this comment

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

Have you thoroughly tested that removing this doesn't cause problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you look above, you see that there is a let parseComponent: Dict<string> = {}; so this is fine.

Copy link
Member

Choose a reason for hiding this comment

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

Yep. But before this PR, a part of source assemble code assumes that formatParse component either contains something or is null. I'm not saying that this is worse, but need to make sure that this doesn't break those parts.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed that part

domoritz and others added 3 commits March 18, 2016 16:56
…ecause now the value can be either `true` or `false`.

This way, we can distinguish between when we only care about the key or when we care about the value too.
(Although the underlying type of `StringSet` is also  `Dict<Boolean>`)

cc: @domoritz
@@ -479,12 +506,13 @@ export namespace nullFilter {
}

export function parseLayer(model: LayerModel) {
// note that we run this before source.parseLayer
let nullFilterComponent = parse(model);
Copy link
Member

Choose a reason for hiding this comment

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

We might not even need to call parse here because layers doesn't have its own field. This is always an empty object.

let nullFilterComponent = parse(model);

model.children().forEach((child) => {
const childDataComponent = child.component.data;
if (!childDataComponent.source && childDataComponent.nullFilter) {
extend(nullFilterComponent || {}, childDataComponent.nullFilter);
if (model.compatibleSource(child) && !differ(childDataComponent.nullFilter, nullFilterComponent)) {
Copy link
Member

Choose a reason for hiding this comment

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

If two children of the layer have the same nullFilterComponent they still don't get merge here.
Because each of the child won't be equal to the layer's initial nullFilterComponent which is simply {}.

@domoritz
Copy link
Member Author

note to self: timeUnit should not be executed before source in data.ts

mergeMeasures(summaries[key].measures, summary.measures);
} else {
// give the summary a new name
summary.name = model.dataName(SUMMARY) + '_' + keys(summaries).length;
Copy link
Member

Choose a reason for hiding this comment

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

keys(summaries).length

Should we name it by the dimensions included instead of a summary counter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I changed the way summaries are generated and now it would make more sense to use the fields (+the source name?). But I don't want to worry about all the edge cases (explicit values, ...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ups, our key may be wrong in that case...

Copy link
Member

Choose a reason for hiding this comment

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

Not sure what "explicit values" mean in this case?

Copy link
Member

Choose a reason for hiding this comment

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

Ups, our key may be wrong in that case...

?? Can you elaborate?

Copy link
Member Author

Choose a reason for hiding this comment

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

summary_bin_distance_start_bin_distance_mid_bin_distance_end_bin_distance_range nope nope nope

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's use number for now although a semantically meaningful mean could just be summary_bin_distance

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe. I don't quite know what happens if we reference different datasets. I think we should forbid different datasets somehow!

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 forbidding simplify things for now, but not sure if we should forbid this in long run.

export function parseLayer(model: LayerModel) {
// note that we run this before source.parseLayer

// FIXME: null filters are not properly propagated right now
Copy link
Member

Choose a reason for hiding this comment

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

It's not only "not properly propagated". The merge logic below is still incorrect. I'll add this to #1254.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants