VegaLite.jl icon indicating copy to clipboard operation
VegaLite.jl copied to clipboard

Axis scale zero:false not behaving correctly

Open seanlaff opened this issue 4 years ago • 2 comments

I'm notice a discrepancy with the same spec in the vega editor, vs plotted with this lib, with regards to "scale": {"zero": false}.

Julia image vs the vega editor https://vega.github.io/editor/ image

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "width": 400,
  "data": {
    "values": [
      {
        "time": "2020-01-02T11:30:00",
        "open": 3000,
        "close": 3100,
        "high": 3200,
        "low": 2980,
        "volume": 100
      },
      {
        "time": "2020-02-02T11:30:00",
        "open": 3000,
        "close": 3100,
        "high": 3200,
        "low": 2980,
        "volume": 100
      }
    ]
  },
  "encoding": {
    "x": {"field": "time", "type": "temporal"},
    "y": {
      "type": "quantitative",
      "scale": {"zero": false},
      "axis": {"title": "Price"}
    },
    "color": {
      "condition": {"test": "datum.open < datum.close", "value": "#06982d"},
      "value": "#ae1325"
    }
  },
  "layer": [
    {
      "mark": "rule",
      "encoding": {"y": {"field": "low"}, "y2": {"field": "high"}}
    },
    {
      "mark": "bar",
      "encoding": {"y": {"field": "open"}, "y2": {"field": "close"}}
    }
  ]
}

I init'd this with vl"""..."""

If Im misusing the api, please let me know :)

seanlaff avatar Nov 18 '20 23:11 seanlaff

Tried to debug this a little more, when I specify the zero on both y and y2, things look good 👍

smp |> @vlplot(
	mark=:bar,
        x={"dateTime:t"},
	y={"open:q", scale={zero=false}},
	y2={"close:q", scale={zero=false}}
)

however, trying this exhibits the incorrect behavior

smp |> @vlplot(
	mark=:bar,
        encoding={
		y={scale={zero=false}}
	},
	y={"open:q"},
	y2={"close:q"}
)

Seems like the scale = zero from the encoding block is overwritten

seanlaff avatar Nov 22 '20 19:11 seanlaff

I just tagged a new version of the package, with updated versions of the underlying Javascript libraries. My best guess is that we had been using an outdated version of vega-lite. Could you try again with the latest version of VegaLite.jl, v2.4.0?

davidanthoff avatar Mar 11 '21 01:03 davidanthoff