Skip to content

De-circularize plotly.js require statements #236

Closed
@etpinard

Description

@etpinard
Contributor

@mdtusz

Latest list of circular dependencies:

  • Plots < --- > Annotations
  • Plots < --- > Legend
  • Plots < --- > Axes (the only Plots calls in axes.js are traceIs)
  • Plots < --- > plotApi
  • plotApi < --- > Annotations
  • plotApi < --- > Shapes
  • plotApi < --- > Titles
  • plotApi < --- > Fx
  • plotApit < --- > Legend

Possible partial solutions:

  • Make a component registry and register the components (e.g. Annotations, Shapes, Titles, Fx, Legend), so plot_api.js doesn't have to require the full component modules (similar to trace and subplot modules). Blocking: we'll need a centralized api for the component module, e.g. all component modules should have a draw method and possible and init method.
  • Use a more OO pattern (in the long term). Attach relayout and restyle to a plot object so that files requiring plot_api.js (e.g Annotations, Shapes and Fx) can use gd.relayout() instead of plotApi.relayout(gd, ...).

Activity

added this to the Decirculise the src directory dependencies milestone on Aug 10, 2016
etpinard

etpinard commented on Feb 17, 2017

@etpinard
ContributorAuthor

The World Calendar push of #1220 added a new circular dependency pattern to src/:

image

as src/registry.js requires Lib for and src/lib/dates.js requires Registry to use the calendars component methods.

To solve this, we can either:

  • make lib/dates.js a component module (as one could argue that src/lib/ files should have to use the registry)
  • require lib functions directly in registry.js instead of requiring the whole Lib module
added a commit that references this issue on Feb 17, 2017
alexcjohnson

alexcjohnson commented on Feb 22, 2017

@alexcjohnson
Collaborator

In the course of #1403 I made some circular deps involving Lib. In the short term I'm fixing these by breaking up Lib and just requiring the pieces I need, but longer term perhaps the right solution is to only allow things in Lib that do not require code from elsewhere in plotly.js. That would make it safe to import Lib anywhere, without forcing us to break it into a million little files. Would be a bit of an effort though...

etpinard

etpinard commented on Nov 17, 2017

@etpinard
ContributorAuthor

Refer to PR #2032 for the most up-to-date findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @alexcjohnson@mdtusz@etpinard

      Issue actions

        De-circularize plotly.js require statements · Issue #236 · plotly/plotly.js