chiasm-project / chiasm

A browser based environment for interactive data visualizations.
MIT License
184 stars 27 forks source link

Support Global Property Values #65

Open curran opened 8 years ago

curran commented 8 years ago

In this example , the following configuration is repeated over and over for each chart:

        "xAxisLabelTextOffset": xAxisLabelTextOffset,
        "yAxisLabelTextOffset": yAxisLabelTextOffset,
        "margin": margin

This is ugly. There needs to be a solution for sharing certain properties across all component instances. Perhaps a new component called "chiasm-globals" can be created that will propagate certain property values to all other component instances within the application. Configuration might look like this:

    "myGlobals": {
      "plugin": "globals",
      "state": {
        "properties": {
          "xAxisLabelTextOffset": 40,
          "yAxisLabelTextOffset": 50,
          "margin": { top: 10, right: 10, bottom: 50, left: 80 }
        }
      }
    },

Since it only makes sense to apply these properties to visualization components, perhaps a blacklist can be included in the configuration, like this:

    "myGlobals": {
      "plugin": "globals",
      "state": {
        "properties": {
          "xAxisLabelTextOffset": 40,
          "yAxisLabelTextOffset": 50,
          "margin": { top: 10, right: 10, bottom: 50, left: 80 }
        },
        "except": ["myLinks", "myLoader", "myVisWithUniqueCustomSettings"]
      }
    },

As another alternative, maybe this functionality could be added to https://github.com/chiasm-project/chiasm-links using a new DSL expression like this:

"links": {
  "plugin": "links",
  "state": {
    "bindings": [
      "vis1.xAxisLabelTextOffset -> *.xAxisLabelTextOffset"
    ]
  }
}