Skip to content

Using different fields for ordering and labeling #309

@belmarca

Description

@belmarca

Hi,

My data looks like this:

[
 {'commit': 'a', 'timestamp': 1234, 'benchmark': 'b', 'value': 1}
 ...
]

I am trying to plot ordinal values on the x axis using a temporal scale (timestamps). This

  vl.markLine()
    .encode(
      vl.x()
        .fieldT('timestamp')
        .title("Commit")
        .axis({
          labelAngle: 90,
        }),
      vl.y().fieldQ('value').scale({ zero: false }).title("Run time (s)"),
      vl.color().fieldN('benchmark').title("Benchmark"),
      vl.tooltip().fieldN('commit')
    )

puts each point in its proper place. However the axis labels are the timestamps themselves. I would like to print the commit field instead, placed at the proper timestamp (thus possibly irregularly spaced). I have tried a few things such as defining a new scale for the axis and proving a list of values, or registering a new vega.expressionFunction and calling it from a labelExpr, without success. The labelExpr is passed objects with scaled values. The information loss prevents me from easily retrieving the proper label.

I am sure this can be done in vega/vega-lite as this sounds relatively trivial. However I could not figure it out by reading the docs or the examples.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions