equinor / videx-wellog

Well log components
https://equinor.github.io/videx-wellog/
MIT License
20 stars 7 forks source link

[BUG] Individual domains on plots and storybook #182

Open eskildht opened 1 year ago

eskildht commented 1 year ago

Describe the bug In version 0.8.0 I can't set individual domains on LinePlots in the same GraphTrack. It works in version 0.7.3.

EDIT: After testing a bit it seems to me that the domain is set correctly, but the graphLegendConfig does not keep up per plot in version 0.8.0.

Additional secondary issue The storybook when checking HEAD on dev fails to properly render. That is, everything under Log Controller and Log Viewer. The storybook works fine if checking out 0.7.3 or https://github.com/equinor/videx-wellog/commit/228b76da8c00388b8062ec15816dcc37016defdd. Currently it looks like this:

https://user-images.githubusercontent.com/37186215/204307077-d1ab00ed-2c2d-474c-b143-633e1220a0fe.mov

To Reproduce (primary issue) Steps to reproduce the behavior:

  1. Do as below (picked from stories) having the necessary imports and ex2 initialized to some data:

    export const logControllerLegend = () => {
    const div = document.createElement('div');
    
    const logController = new LogController();
    
    const tracks = [new GraphTrack(3, {
      label: 'Some noise',
      abbr: 'noise',
      data: ex2,
      legendConfig: graphLegendConfig,
      plots: [{
        id: 'noise',
        type: 'line',
        options: {
          color: 'blue',
          filterToScale: false,
          dataAccessor: d => d.noise,
          legendInfo: () => ({
            label: 'Plot1',
            unit: 'mm',
          }),
        },
      }, {
        id: 'more_noise',
        type: 'linestep',
        options: {
          scale: 'linear',
          domain: [0, 40],
          color: 'black',
          offset: 0.5,
          dataAccessor: d => d.noise2,
          legendInfo: () => ({
            label: 'Plot2',
            unit: 'Pwr',
          }),
        },
      }],
    }),
    ]
    
    // Using requestAnimationFrame to ensure that the div is attached
    // to the DOM before calling init
    requestAnimationFrame(() => {
    logController
      .init(div)
      .setTracks(tracks);
    });
    
    return div;
  2. See that domain rendered on is [0, 100] for both plots (EDIT: according to graphLegendConfig).

Expected behaviour (primary issue) Plot1 should render on [0, 100]. Plot2 should render on [0, 40].

Desktop (please complete the following information):

eskildht commented 1 year ago

I managed to get it working by trying different combinations of the attributes. I think the definitions, uses and relations between scale, domain and type in both GraphTrack and the plots are not necessarily clear. E.g. I found in a comment in the code that scale on PlotOptions should by default be linear, but without specifying it explicitly I get the default domain of [0, 100].

The storybook issue still remains however.