Serializing the DataTables config object?

Serializing the DataTables config object?

cthooloocthooloo Posts: 1Questions: 1Answers: 0

I see many similarities between DataTables and Vega-Lite, in the sense that both provide a way of visually rendering a dataset based on a declarative specification of what that visualization should look like and how it should behave under user interaction.

In Vega-Lite, this specification comes in the form of a pure JSON object that gets passed to an embedding function, whereas in DataTables this description comes in the form of the Options object that gets passed to the DataTable constructor. The main difference I see between these two approaches is how they deal with functions; for example, both Vega-Lite and DataTables provide an ability to filter or transform points from the raw dataset before they are displayed. DataTables allows you to just provide a javascript function object (thus losing the ability to serialize the Options object to JSON), whereas VegaLite essentially has you write the function as a string and does a sandboxed eval.

The Vega-Lite way is admittedly pretty wonky, but I think they made a calculated decision to sign up for some extra pain because there are lots of benefits to being able to serialize that config. First of all, that allows you to separate the concern of displaying your data from everything else you might be doing in javascript. Secondly it lets them do some really interesting and fun things like encoding the visualization spec into a URL parameter to share visualizations in their Editor. Third, it allows them to publish a JSON Schema standardizing their spec, which gives great editor support and has allowed for the wide adoption of their visualizations, such as native rendering in the Jupyter Lab datascience environment.

I'm not here to argue that DataTables should change to the way Vega-Lite does things (there are lots of reasons that being able to specify function directly is a good thing and it's way too late to change anyway) -- but I wonder if folks here have considered ways of supporting or working with a serialized configuration, maybe for the portions of the config object that don't involve functions?

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    DataTables 2 will support renders defined by arrays / strings in order to invoke functions. With that it will be possible to generate a DataTables configuration object with JSON. That sounds a lot like the examples, but a full design configuration is outside the scope of DataTables.

    Allan

Sign In or Register to comment.