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

vgplot Mark TipOptions format - possibly incorrect parsing. #709

Open
venkat-oss opened this issue Mar 10, 2025 · 5 comments
Open

vgplot Mark TipOptions format - possibly incorrect parsing. #709

venkat-oss opened this issue Mar 10, 2025 · 5 comments
Assignees

Comments

@venkat-oss
Copy link

I have a mosaic vgplot yaml specification that looks like this:

plot:
- mark: lineY
  data: { from: tabular_data }
  x: TimeMinutes
  y: Value
  stroke: MetricName
  tip: {format: {x: true, y: true, stroke: true, z: false }}
width: 900
height: 580

Expected behavior of the plot tip with format option:
MetricName system.cpu.load_average.1m {color}

Observed behavior of the plot tip with format option:
stroke system.cpu.load_average.1m {color}

Image for reference:
Image

Is this expected or am I providing an incorrect chart specification? Thank you for the great work on this!!

@domoritz
Copy link
Member

Image

I can repro this with a small plain example

import { coordinator, wasmConnector } from '@uwdata/mosaic-core';
import { loadParquet } from '@uwdata/mosaic-sql';
import * as vg from '@uwdata/vgplot';

async function init() {
  const wasm = await wasmConnector({ log: false });
  coordinator().databaseConnector(wasm);

  await vg.coordinator().exec([
    loadParquet("aapl", `${window.location}stocks.parquet`, {where: "Symbol = 'AAPL'"})
  ]);

  document.getElementById("plot").replaceChildren(
    vg.plot(
      vg.lineY(
        vg.from("aapl"),
        {x: "Date", y: "Close", stroke: "Symbol", tip: {x: true, y: true, stroke: true}}
      ),
      vg.width(680),
      vg.height(200)
    )
  )
}

init();

Doesn't seem to be an issue with plain plot (https://observablehq.com/d/624cb8a94175eea2).

Image

@domoritz domoritz self-assigned this Mar 11, 2025
@jheer
Copy link
Member

jheer commented Mar 11, 2025

vgplot marks rename some fields when creating database queries. The workaround is to provide your desired names using the label methods (such as vg.colorLabel("Symbol")). For an example of this in action, see the WNBA Shot Chart example.

@jheer
Copy link
Member

jheer commented Mar 11, 2025

A potential fix for this could be to automatically set the scale labels (if not explicitly defined) when we marshal a Plot spec within vgplot.

@venkat-oss
Copy link
Author

I was able to partially work around this issue by explicitly specifying the mark channel. Looks like that gets passed to Plot transparently.

plot:
- mark: lineY
  data: { from: tabular_data }
  x: TimeMinutes
  y: Value
  stroke: MetricName
  channels:
     MetricName: MetricName
  tip: {format: {x: true, y: true, stroke: false, z: false }}
width: 900
height: 580

This spec has the expected behavior, but without the color encoding. 😄

Image

Thank you @jheer for the proper workaround. 🚀
@domoritz Thank you for the quick reproducer.
Thank you @jheer and @domoritz again for Mosaic.

@domoritz
Copy link
Member

Image
vg.plot(
  vg.lineY(
    vg.from("aapl"),
    {x: "Date", y: "Close", stroke: 'Symbol', tip: true}
  ),
  vg.colorLabel("Symbol"),
  vg.width(680),
  vg.height(200)
)

works as expected

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

No branches or pull requests

3 participants