question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Differentiate nominal and ordinal stroke dash encoding

See original GitHub issue

Good to see the new strokeDash channel encoding. Quite reasonably, encoding for anything other than nominal or ordinal data generates a warning. But I wonder if it would be possible to make the default nominal stroke dash sequence less ordered (i.e. alternating higher ink dashes with lower ink ones). And then for ordinal encoding, contrast this with a clearly ordered sequence from high ink to low ink.

Here is the default sequence, which is currently the same for nominal and ordinal data encoding:

strokeDash1

Any change in defaults could also take the opportunity to have a longer sequence than the 5 current dash styles. Here for example is a set of 10 dash styles with nominal unordered and ordinal in dark to light sequence:

strokeDash2

In this example, the nominal sequence is

"strokeDash": {
  "field": "cat",
    "type": "nominal",
      "scale": {
        "domain": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        "range": [ [1, 0], [5, 4], [2, 4], [8, 4, 4, 4], [1, 3], [16, 4], [6, 4], [8, 4], [4, 6], [10, 4] ]
      }
}

and the ordinal sequence:

"strokeDash": {
  "field": "cat",
    "type": "nominal",
      "scale": {
        "domain": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        "range": [ [1, 0], [16, 4], [10, 4], [8, 4], [8, 4, 4, 4], [6, 4], [5, 4], [4, 6], [2, 4], [1, 3] ]
      }
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jwoLondoncommented, Feb 16, 2020

I take your point about fluctuating lines. Appropriate dash sizes are likely to relate to the size of the view and frequency of variation in line position. Perhaps one possibility would be to allow a scaling parameter that could be applied to all dash arrays so that the dash frequency can be matched with the frequency of line variation. So, a dash scale of 0.5 applied to a dash [8,2,3,2] results in [4,1,1.5,1].

Here is an example showing various dash scales for some fluctuating lines all using the ordered sequence of dash styles is mentioned above:

dashScales

And the code to produce the tests (I’ve applied the scaling externally in elm-vegalite, so the code below just shows the default dash scaling of 1)

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "title": {"text": "Dash scale 1"},
  "width": 300,
  "height": 300,
  "data": {"sequence": {"start": 0, "stop": 100, "step": 0.1, "as": "x0"}},
  "transform": [
    {"calculate": "abs(sin(datum.x0+random()))", "as": "y0"},
    {"calculate": "datum.x0 %10", "as": "x"},
    {"calculate": "floor(datum.x0 / 10)", "as": "cat"},
    {"calculate": "datum.y0 + datum.cat", "as": "y"}
  ],
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "axis": {"grid": false}},
    "y": {"field": "y", "type": "quantitative", "axis": {"grid": false}},
    "strokeDash": {
      "field": "cat",
      "type": "ordinal",
      "scale": {
        "domain": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
        "range": [ [1, 0], [16, 4], [10, 4], [8, 4], [8, 4, 4, 4], [6, 4], [5, 4], [4, 6], [2, 4], [1, 3] ]
      }
    }
  },
  "mark": "line"
}
0reactions
kanitwcommented, Feb 23, 2020

Perhaps a contribution to the solution is to allow the legend symbolSize property to control the line length of linear symbols.

Since that uses a point (Vega symbol) shape, it might be just easier to change the default shape to be a longer line symbol. Changing the size would be trickier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nominal Vs Ordinal Data: 13 Key Differences & Similarities
Nominal data is a group of non-parametric variables, while Ordinal data is a group of non-parametric ordered variables. Although, they are both ...
Read more >
Nominal vs Ordinal Scale. Know the difference! - Voxco
The ordinal scale is the opposite of the nominal scale because in this measurement scale the variables are arranged into ranks and orders....
Read more >
Encodings — Altair 4.2.0 documentation
As an example of this, here we will represent the same data three different ways, with the color encoded as a quantitative, ordinal,...
Read more >
Unicode Chart
Position Decimal Name 0x0000 0 : NULL 0x0001 1 : START OF HEADING 0x0002 2 : START OF TEXT
Read more >
Graphics.Vega.VegaLite - Hackage
Commonly these will include at least a data, mark, and encoding specification. While simple properties like mark may be provided directly, it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found