Open AdamSobieski opened 1 year ago
Hi, Adam,
This is good news, and I'd definitely like to stay abreast of it (participate as I can).
One other area that may be worth thinking about are charting microlanguages, most notably the GraphViz dot language and the MermaidJS diagram language, which I use fairly heavily for incorporating Network Diagrams and Flowcharts among others.
For instance, the following:
flowchart LR
classDef influencer fill:#ff0,stroke:#333,stroke-width:1px;
classDef production fill:#fC0,stroke:#333,stroke-width:1px;
classDef productionType fill:#f00,stroke:#333,color:white,stroke-width:1px;
classDef sponsor fill:#00f,stroke:#333,color:white,stroke-width:1px;
classDef facilitator fill:#f0f,stroke:#333,color:white,stroke-width:1px;
classDef event fill:#808,stroke:#333,color:white,stroke-width:1px;
classDef organizer fill:#040,stroke:#333,color:white,stroke-width:1px;
influencer:Kurt([<b>Influencer</b>\nKurt Cagle]):::influencer
influencer:AshleighFaith([<b>Influencer</b>\nAshleigh Faith]):::influencer
influencer:AmyHodler([<b>Influencer</b>\nAmy Hodler]):::influencer
influencer:AlanMorrison([<b>Influencer</b>\nAlan Morrison]):::influencer
prodType:Interview([<b>Production Type</b>\nInterview]):::productionType
prodType:Blog([<b>Production Type</b>\nBlog]):::productionType
prodType:Feature([<b>Production Type</b>\nFeature]):::productionType
prodType:LinkedInFeed([<b>Production Type</b>\nLinked In Feed]):::productionType
prod:TheCagleReport([<b>Production</b>\nThe Cagle Report]):::production
prod:TheGraph([<b>Production</b>\nThe Graph]):::production
prod:DataTherapist([<b>Production</b>\nThe DataTherapist]):::production
prod:IsADataThing([<b>Production</b>\nIsA Data Thing]):::production
prod:AlanLinkedInFeed([<b>Production</b>\nAlan Morrison LI Feed]):::production
sponsor:nVidia([<b>Sponsor</b>\nnVidia]):::sponsor
sponsor:MarkLogic([<b>Sponsor</b>\nMarkLogic]):::sponsor
sponsor:Microsoft([<b>Sponsor</b>\nMicrosoft]):::sponsor
sponsor:DGraph([<b>Sponsor</b>\nDGraph]):::sponsor
sponsor:DoD([<b>Sponsor</b>\nDept. of Defense]):::sponsor
sponsor:UHC([<b>Sponsor</b>\nUnited Health Care]):::sponsor
event:AIDataForum([<b>Event</b>\nAI Data Forum]):::event
event:DataFabricForum([<b>Event</b>\nData Fabric Forum]):::event
event:DataVentsMesh([<b>Event</b>\nData Vents: Mesh]):::event
organizer:DataForumInc([<b>Organizer</b>\nData Forum Inc]):::organizer
organizer:DataVents([<b>Organizer</b>\nData Vents]):::organizer
influencer:Kurt -- produces --> prod:TheCagleReport
influencer:Kurt -- produces --> prod:TheGraph
influencer:Kurt -- produces --> prod:DataTherapist
prod:TheCagleReport -- is type of --> prodType:Blog
influencer:AmyHodler -- produces --> prod:TheGraph
prod:TheGraph -- is type of --> prodType:Feature
prod:TheGraph -- is sponsored by --> sponsor:nVidia
influencer:AshleighFaith -- produces --> prod:IsADataThing
prod:DataTherapist -- is type of --> prodType:Interview
prod:IsADataThing -- is type of --> prodType:Interview
prod:IsADataThing -- is sponsored by --> sponsor:nVidia
prod:DataTherapist -- is sponsored by --> sponsor:MarkLogic
prod:IsADataThing -- is sponsored by --> sponsor:Microsoft
prod:DataTherapist -- is sponsored by --> sponsor:DGraph
influencer:AlanMorrison -- contributes to --> prod:TheCagleReport
influencer:AlanMorrison -- contributes to --> prod:IsADataThing
influencer:AlanMorrison -- produces --> prod:AlanLinkedInFeed
prod:AlanLinkedInFeed -- is type of --> prodType:LinkedInFeed
sponsor:DoD -- buys from --> sponsor:nVidia
sponsor:DoD -- buys from --> sponsor:Microsoft
sponsor:UHC -- buys from --> sponsor:Microsoft
sponsor:DoD -- buys from --> sponsor:MarkLogic
event:AIDataForum -- organized by --> organizer:DataForumInc
event:AIDataForum -- sponsored by --> sponsor:nVidia
event:AIDataForum -- sponsored by --> sponsor:Microsoft
event:AIDataForum -- sponsored by --> sponsor:Microsoft
event:DataFabricForum -- organized by --> organizer:DataForumInc
event:DataFabricForum -- sponsored by --> sponsor:Microsoft
event:AIDataForum -- organized by --> organizer:DataForumInc
event:DataVentsMesh -- organized by --> organizer:DataVents
event:DataVentsMesh -- sponsored by --> sponsor:Microsoft
influencer:AshleighFaith -- speaks at --> event:AIDataForum
influencer:Kurt -- speaks at --> event:DataVentsMesh
influencer:AmyHodler -- speaks at --> event:DataVentsMesh
Generates the following Network Graph as PNG or SVG:
Note sure how this fits into the overall strategy, but it would be immensely helpful to have some support for these.
@kurtcagle, thank you. Web Charts intends to be flexible to supporting charting microlanguages. The input data, in whichever formats, need to be understood by charts' scripts so that: (1) charts' data models could be populated from the input data, and (2) the data models could be connected to visualization models which might involve HTML, SVG, Canvas, WebGL, WebGPU, or WebXR in the Shadow DOM. With this approach, Web developers would be able to modify input data at runtime and data visualizations would update.
Something like the following should be possible:
<chart>
<source type="text/x-mermaid" src="flowchart.mmd" />
<script src="https://cdn.webcache.org/mermaid-chart.js" />
</chart>
The Mermaid documentation indicates that Mermaid SVG charts can inherit their styling from containing documents and can be provided with custom stylesheets.
<chart>
<source type="text/x-mermaid" src="flowchart.mmd" />
<script src="https://cdn.webcache.org/mermaid-chart.js" />
<style src="custom.css" />
</chart>
Similarly, the GraphViz documentation indicates that GraphViz SVG charts can inherit their styling from containing documents and can be provided with custom stylesheets.
<chart>
<source type="text/x-dot" src="flowchart.dot" />
<script src="https://cdn.webcache.org/graphviz-chart.js" />
<style src="custom.css" />
</chart>
I do really wish that SVG had better i18n support and that Mermaid supported more semantic generation of SVG files. So much of the meaning is right there in text for generation, but not conveyed into the SVG file.
Accessible web charts are currently a real challenge. I think the current best practices are described by https://fizz.studio
To that end it might be worth including a stream element that contains a URL that sends individual deltas rather than an entire dataset. For instance a stock exchange stream would contain just the most immediate updates.
Most chart packages incorporate some form of configuration json. A config attribute on the chart element would contain a URL to that config file.
Finally, a value attribute on chart would, if present, highlight that value in the chart. If the chart is a timeseries of years, value would be a specific year, if a flowchart the id of the resource in that flowchart. The specific mechanism for highlighting would be chart dependentl()
On Wed, May 31, 2023, 20:06 Adam Sobieski @.***> wrote:
@kurtcagle https://github.com/kurtcagle, thank you. Web Charts intends to be flexible to supporting charting microlanguages. The input data, in whichever formats, needs to be understood by charts' scripts so that: (1) charts' data models could be populated from the input data, and (2) the data models could be connected to visualization models which might involve HTML, SVG, Canvas, WebGL, WebGPU, or WebXR in the Shadow DOM. With this approach, Web developers would be able to modify the data at runtime and data visualizations would update.
Something like the following should be possible:
The Mermaid documentation https://mermaid.js.org/syntax/flowchart.html#css-classes indicates that Mermaid SVG charts can inherit their styling from containing documents and can be provided with custom stylesheets.
Similarly, the GraphViz documentation https://graphviz.org/docs/attrs/class/ indicates that GraphViz SVG charts can inherit their styling from containing documents and can be provided with custom stylesheets.
— Reply to this email directly, view it on GitHub https://github.com/WICG/proposals/issues/97#issuecomment-1571261156, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHOAUOMXUZMOB42MPG4BDXJABLZANCNFSM6AAAAAAYOZPWSQ . You are receiving this because you were mentioned.Message ID: @.***>
@kurtcagle, for both aesthetics and integration into the Web Platform, the Web Charts <chart>
element hopes to be a media element and to imitate the <video>
element, its attributes, and its content model, in particular for "data video" scenarios. In these regards, any eventual HTMLChartElement
interface would most probably extend the HTMLMediaElement
interface.
The media element attributes src
, crossorigin
, preload
, autoplay
, loop
, muted
, and controls
apply to all media elements.
With respect to its attributes, the <video>
element supports:
src
— Address of the resourcecrossorigin
— How the element handles crossorigin requestsposter
— Poster frame to show prior to video playbackpreload
— Hints how much buffering the media resource will likely needautoplay
— Hint that the media resource can be started automatically when the page is loadedplaysinline
— Encourage the user agent to display video content within the element's playback arealoop
— Whether to loop the media resourcemuted
— Whether to mute the media resource by defaultcontrols
— Show user agent controlswidth
— Horizontal dimensionheight
— Vertical dimensionWith respect to its content model, the <video>
element can either provide a src
attribute or provide one or more child <source>
elements. The <chart>
element might also follow this approach, though, as presently envisioned, it would add one or more <script>
elements and an optional <style>
element as content.
Most chart packages incorporate some form of configuration json. A config attribute on the chart element would contain a URL to that config file.
That would work. Another possibility is using secondary <script>
elements to declare JSON data blocks which could contain configuration, settings, and options for charts’ scripting logic.
Here are some more examples:
<chart src="data-video.m3u8" poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<script type="text/javascript" src="https://cdn.webcache.org/chart.js" />
<script type="text/json" src="settings.json" />
</chart>
<chart poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<source type="video/mp4" src="data-video.mp4" />
<source type="video/webm" src="data-video.webm" />
<script type="text/javascript" src="https://cdn.webcache.org/chart.js" />
<script type="text/json" src="settings.json" />
</chart>
Here are those same examples with custom styling:
<chart src="data-video.m3u8" poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<script type="text/javascript" src="https://cdn.webcache.org/chart.js" />
<script type="text/json" src="settings.json" />
<style src="custom.css" />
</chart>
<chart poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<source type="video/mp4" src="data-video.mp4" />
<source type="video/webm" src="data-video.webm" />
<script type="text/javascript" src="https://cdn.webcache.org/chart.js" />
<script type="text/json" src="settings.json" />
<style src="custom.css" />
</chart>
Noticing the controls
attribute, charts displaying streaming data could provide UI/UX and controls similar to those for video, e.g., playing, pausing, stopping, resuming, and seeking. There are also some related matters concerning the capability to toggle charts to and from fullscreen and their interoperability with picture-in-picture features.
To that end it might be worth including a stream element that contains a URL that sends individual deltas rather than an entire dataset. For instance a stock exchange stream would contain just the most immediate updates.
Displaying stock market data and sensors' data are important scenarios for Web Charts.
The above examples hope to show how markup for charts could look for (real-time) streaming data. In these examples, video-based MIME types are used for placeholders. Let's put some further thought into the design of markup options for clarifying and declaring whether input data sources are static and non-streaming or are dynamic and streaming.
Finally, a value attribute on chart would, if present, highlight that value in the chart. If the chart is a timeseries of years, value would be a specific year, if a flowchart the id of the resource in that flowchart. The specific mechanism for highlighting would be chart dependent
Let's also put some further thought into the declaration of initially selected data points, scripting API for selecting data points, and how "data video" could make and change selections in a temporal manner.
@mgifford, thank you for sharing the hyperlink to Fizz Studio. Accessibility approaches like those in use there appear to be compatible with the generation of long-form, natural-language, descriptive content intended for consumption by AI systems, e.g., LLMs, discussed below.
With respect to charts and accessibility, I have been thinking about long-form natural-language descriptions, where descriptions could contain one or more sections and sections could contain one or more paragraphs. This would resemble ARIA attributes: aria-describedby
and aria-details
.
By utilizing templates, charts' metadata, document structure, input data, and style could be changed at runtime and responsive, up-to-date, dynamically-(re)generated, long-form descriptions of the charts would be available.
We can consider there to be different kinds of descriptive content. Here are some kinds with examples:
<https://website.org/#chart123> depicts the number of passengers who rode on the Piccadilly Line each year.
<https://website.org/#chart123> is a bar chart.
<https://website.org/#chart123> is titled {...}.
<https://website.org/#chart123> was created by {...}.
<https://website.org/#chart123-bar1> is a bar.
<https://website.org/#chart123-bar2> is a bar.
<https://website.org/#chart123-bar3> is a bar.
<https://website.org/#chart123> is contained in the webpage document <https://website.org>.
<https://website.org/#chart123-bar1> is a component of <https://website.org/#chart123>.
<https://website.org/#chart123-bar2> is a component of <https://website.org/#chart123>.
<https://website.org/#chart123-bar3> is a component of <https://website.org/#chart123>.
<https://website.org/#chart123> has {...} bars.
<https://website.org/#chart123-bar1> indicates that {this.data.y} passengers rode on the Piccadilly Line in {this.data.x}.
<https://website.org/#chart123-bar2> indicates that {this.data.y} passengers rode on the Piccadilly Line in {this.data.x}.
<https://website.org/#chart123-bar3> indicates that {this.data.y} passengers rode on the Piccadilly Line in {this.data.x}.
<https://website.org/#chart123-bar1> has a {this.style.backgroundColor} background.
<https://website.org/#chart123-bar2> has a {this.style.backgroundColor} background.
<https://website.org/#chart123-bar3> has a {this.style.backgroundColor} background.
<https://website.org/#chart123> shows that the number of passengers who rode the Piccadilly Line is increasing each year.
Descriptive content could be accessed for charts and their individual parts. Descriptive content could be accessed by kind, by multiple simultaneous kinds, by all available kinds, and/or with kinds automatically woven together into more coherent and cohesive natural-language compositions.
In theory, AI systems, e.g., LLMs, could process charts’ long-form descriptions and, alongside the natural language from charts' containing documents, better answer questions about, engage in dialogues about, and perform analyses of the charts.
As envisioned, Web Charts can utilize HTML, SVG, Canvas, WebGL, WebGPU, and WebXR, and will utilize CSS to style content. While it is clear how styling interoperates with HTML-based and SVG-based charts, how might we style charts which utilize Canvas, WebGL, WebGPU, and other tools to come?
For discussion, let us consider a simple example: a custom element <webgpu-scene id="scene" />
which utilizes WebGPU in the shadow DOM to display two independently rotating 3D cubes.
How might we utilize style to set:
There are, thus far, considered a DOM and a shadow DOM. Neither of these provide a scene graph which includes the rotating cubes. The DOM element for <webgpu-scene id="scene" />
has zero child elements and one attribute, id
. The shadow DOM tree contains an implementation for WebGPU rendering. Something new, then, appears to be required.
It appears that a new axis is required with which to traverse from DOM elements to their models or proxies which would be DOM trees. As the following options with examples intend to show, either a new property or method could be utilized for obtaining elements' models or proxies.
model
PropertyThis option involves adding a new property, model
, to DOM elements. This property would return either undefined
or a DOM element.
First, let us change the background color of the 3D space.
document.getElementById('scene').model.style.backgroundColor = "black";
Next, let us access one of the two cubes.
var cube = document.getElementById('scene').model.children[0];
Next, let us set the border property of a cube.
document.getElementById('scene').model.children[0].style.border = "2px solid red";
Next, let us change the color of a face or facet of one of the cubes.
document.getElementById('scene').model.children[0].children[0].style.color = "blue";
proxy
PropertyThis option involves adding a new property, proxy
, to DOM elements. This property would return either undefined
or a DOM element.
First, let us change the background color of the 3D space.
document.getElementById('scene').proxy.style.backgroundColor = "black";
Next, let us access one of the two cubes.
var cube = document.getElementById('scene').proxy.children[0];
Next, let us set the border property of a cube.
document.getElementById('scene').proxy.children[0].style.border = "2px solid red";
Next, let us change the color of a face or facet of one of the cubes.
document.getElementById('scene').proxy.children[0].children[0].style.color = "blue";
getModel()
MethodThis option involves adding a new method, getModel()
, to DOM elements. This method would return either undefined
or a DOM element.
First, let us change the background color of the 3D space.
document.getElementById('scene').getModel().style.backgroundColor = "black";
Next, let us access one of the two cubes.
var cube = document.getElementById('scene').getModel().children[0];
Next, let us set the border property of a cube.
document.getElementById('scene').getModel().children[0].style.border = "2px solid red";
Next, let us change the color of a face or facet of one of the cubes.
document.getElementById('scene').getModel().children[0].children[0].style.color = "blue";
getProxy()
MethodThis option involves adding a new method, getProxy()
, to DOM elements. This method would return either undefined
or a DOM element.
First, let us change the background color of the 3D space.
document.getElementById('scene').getProxy().style.backgroundColor = "black";
Next, let us access one of the two cubes.
var cube = document.getElementById('scene').getProxy().children[0];
Next, let us set the border property of a cube.
document.getElementById('scene').getProxy().children[0].style.border = "2px solid red";
Next, let us change the color of a face or facet of one of the cubes.
document.getElementById('scene').getProxy().children[0].children[0].style.color = "blue";
To enable updating Canvas, WebGL, or WebGPU content by updating the styles of models' or proxies' elements, we want to be able to listen for changes to these elements' computed styles.
In addition to listening for style-related changes from their models or proxies, elements' scripting logic could also maintain the freshness and consistency of the structure, attributes, and styles of their models or proxies. The structures, attributes, and styles of their models or proxies could reflect the contents displayed using Canvas, WebGL, or WebGPU.
For the <webgpu-scene id="scene" />
example, if one of the 3D cubes, or a face or facet thereof, were to change color due to some cause within the element's scripting logic, that element's DOM-based model or proxy would be updated and any mutation observers notified.
While elements of models or proxies would implement the DOM Element
interface, they might implement it differently than other, ordinary DOM elements, and might provide more capabilities. Elements of models or proxies would not be intended for layout, rendering, or display and they would route document-side changes, such as those to their structure, attributes, or style, to scripting logic. In this way, these changes could result in changes to Canvas, WebGL, or WebGPU content.
Possibilities with respect to creating elements for models or proxies include, but are not limited to, utilizing the options
parameter of document.createElement()
and document.createElementNS()
, in a manner resembling how that parameter is used with custom elements.
Both of the general-purpose options indicated above, models and proxies, would be applicable to data visualizations. A bar chart, for instance, utilizing WebGPU in the shadow DOM could provide a model or proxy which contains all of the parts of the chart, e.g., one element per bar of the bar chart. This would be a DOM-based model or proxy for purposes including reflection and styling.
If a method is to be utilized for traversing the axis from a DOM element to its model or proxy, e.g., a getModel()
or a getProxy()
method, might such a method have parameters? Might, for instance, there be multiple types of models or proxies, e.g., getProxy({ type: 'style' })
and getProxy({ type: 'accessibility' })
?
Do any other options, other useful examples, other names for related properties or methods, or any other method signatures, beyond those indicated above, come to mind?
How might the proposed options, models or proxies, efficiently interoperate with CSS Animations?
Reflection (any affine transformation, for that matter) is part of CSS now, as are declarative animations. I could see extrusions and surfaces of revolution being definable on svg d path with CSS. Materials can be composited via the background property and filters. That's more or less what dot does, and I believe css has support for basic 3d light sources. What you end up with is more 2.5d, but for charts it should suffice.
On Tue, Jun 6, 2023, 17:08 Adam Sobieski @.***> wrote:
In a recent email discussion about Web Charts, an interesting question was raised regarding extensible and future-forward approaches to styling charts which, beyond HTML or SVG, utilize Canvas, WebGPU, or other tools that may still come.
For discussion, let us consider a simple example, a custom element <webgpu-scene id="scene" /> which utilizes WebGPU in the shadow DOM to render two independently rotating cubes. How might one utilize style to set:
- the background color of the 3D space
- the colors and widths of any lines or borders along the edges of the cubes
- the colors of each face of each cube
There are, thus far considered, a DOM and shadow DOM, but neither of these provide the scene graph containing the rotating cubes. The DOM element for <webgpu-scene id="scene" /> has no child elements and has one attribute, id. The shadow DOM tree contains an implementation for WebGPU rendering. Something new, then, appears to be required. Listening for Style Changes
Custom elements' style https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style property could be overridden to return a new implementation of CSSStyleDeclaration https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration which would be able to interact with the elements' scripting logic, providing notification whenever style properties were modified.
Presently, custom elements support listening for attribute-related changes, e.g., observedAttributes, and attributeChangedCallback. One can also envision a styleChangedCallback which could be connected to the aforementioned new implementation of CSSStyleDeclaration https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration.
What we really want is to be able to subscribe to changes to elements' computed styles https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle . A model Property
In this approach, we provide a new axis to get from elements to their virtual scene graphs (if they have them) which could be provided by the elements' scripting logic. This approach involves adding a new property, model, to DOM elements, such that this property would return either undefined or a DOM element, the root element of a virtual scene graph, if such a virtual scene graph were defined for the element.
Considering this approach, let us change the background color of the 3D space.
document.getElementById('scene').model.style.backgroundColor = "black";
Next, let us access one of the two cubes.
var cube = document.getElementById('scene').model.children[0];
Next, let us set the border property of a cube.
document.getElementById('scene').model.children[0].style.border = "2px solid red";
Next, let us change the color of a face or facet of one of the cubes.
document.getElementById('scene').model.children[0].children[0].style.color = "blue";
Applicability to Charts
These topics are applicable to data visualizations. A bar chart utilizing WebGPU in the shadow DOM could provide a model which contains all of the parts of the chart including one element per bar in the bar chart. This would be a DOM-based model for purposes including reflection and styling. Questions
1.
When elements' style https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style properties were set to string values, would this involve a call to a attributeChangedCallback and/or would the string values be processed and route to subsequent calls to a styleChangedCallback? 2.
Must elements have but one model or might they have multiple models, e.g., a models property such that the examples, above, would utilize models[0]? 3.
Do any other approaches beyond the model property approach come to mind?
— Reply to this email directly, view it on GitHub https://github.com/WICG/proposals/issues/97#issuecomment-1579628594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHOATT4GNFFZD6JONXCZDXJ7A6FANCNFSM6AAAAAAYOZPWSQ . You are receiving this because you were mentioned.Message ID: @.***>
@kurtcagle, for your information: I edited and spruced up the previous post after I initially posted it.
I can imagine CSS Transforms being applicable to 3D content, e.g., WebGL and WebGPU, and how materials and textures could be applied to meshes using style. Interestingly, light sources and cameras could be styleable elements using models/proxies.
Interoperability between the models/proxies approach and CSS Animations should be explored.
If styling 3D content becomes popular, perhaps the style team would want to explore one or more new CSS modules for whichever remaining functionalities that Web developers needed.
For charts-related purposes, I think that we are off to a good start.
I don't quite understand what this proposal is supposed to do.
As envisioned, Web Charts can utilize HTML, SVG, Canvas, WebGL, WebGPU, and WebXR, and will utilize CSS to style content.
This sounds a bit like "what if we make a single element able to do everything".
I would suggest developing a custom element and implement what you have in mind in JS, using the technologies referenced here. If the web platform is missing something specific to make it work well, this exercise should make that clearer.
If your chart is a video, then use video
. If your chart is SVG, then use <svg>
or <img>
. If you want to draw your chart on a canvas with script, use <canvas>
. I think it doesn't make sense to create a new HTML element that supports all of those.
Thank you for taking a look at the proposal, @zcorpan. What the proposal is supposed to do is to represent all kinds of charts with one markup solution.
According to Wikipedia, there are, to consider, the common chart types: histograms, bar charts, pie charts, and line charts. There are also: timeline charts, organizational charts, tree charts, flow charts, area charts, cartograms, pedigree charts, and radial tree charts. There are also the less-common chart types: bubble charts, polar area diagrams, waterfall charts, radar charts, tree maps, streamgraphs, and gapcharts. Beyond all of these types of charts, data visualization designers can also get creative (see also: D3).
Another possibility, in these regards, would be to add a kind
attribute to <chart>
elements with this attribute's values drawn from a controlled vocabulary:
<chart kind="bar" width="600" height="400">
<source type="text/csv" src="data.csv" />
<source type="text/tsv" src="data.tsv" />
</chart>
With custom elements, this example would be:
<web-chart kind="bar" width="600" height="400">
<source type="text/csv" src="data.csv" />
<source type="text/tsv" src="data.tsv" />
</web-chart>
and more complex scenarios might resemble:
<web-chart src="data-video.m3u8" poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<script type="text/javascript" src="https://cdn.webcache.org/bar-chart.js" />
<script type="text/json" src="settings.json" />
<style src="custom.css" />
</web-chart>
<web-chart poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<source type="video/mp4" src="data-video.mp4" />
<source type="video/webm" src="data-video.webm" />
<script type="text/javascript" src="https://cdn.webcache.org/bar-chart.js" />
<script type="text/json" src="settings.json" />
<style src="custom.css" />
</web-chart>
Hopefully, a Web development team reading this is interested in exploring implementations with custom elements and reporting back whether the Web Platform needs or could use anything new.
It may also be the case that a "one markup solution for all kinds of charts" approach, per this proposal, isn't the way to go at all, and that an interested Web development team would choose to, instead, provide a set of similar custom markup elements, one for each type of chart, e.g.,:
<web-bar-chart poster="loading.png" autoplay="true" controls="true" width="600" height="400">
<source type="video/mp4" src="data-video.mp4" />
<source type="video/webm" src="data-video.webm" />
<script type="text/json" src="settings.json" />
<style src="custom.css" />
</web-bar-chart>
If your chart is a video, then use
video
. If your chart is SVG, then use<svg>
or<img>
. If you want to draw your chart on a canvas with script, use<canvas>
. I think it doesn't make sense to create a new HTML element that supports all of those.
I kind of disagree. The more important point of this proposal is that we can abstract the data from the presentation.
Where I will agree is that an HTML chart element should behave rather more like <figure>
in the sense that a chart element should permit img, svg, canvas (and other types) as descendents, rather than offer replacement markup for those types. The point of the element would be to gather the various assets into a meaningful and predictable structure.
A significant problem with relying on authors to make all these choices is that it is very difficult to present the chart data in a presentation-independent way. I'm thinking specifically of accessibility and assistive technology here, which is very poorly served by the dataviz community so far. Yes, there are some excellent attempts to make accessible charts, but each one takes its own custom approach, requiring AT users to learn new patterns of browsing and interaction each time.
Formalizing a way to provide data for a given type of chart would lay the foundation for offering presentation-independent chart content.
I'd like to add that universal chart features such as axes, scale, units and legend are also obvious candidates for formal semantic specification within any HTML charting API. (Unfortunately <legend>
is already a thing).
Is this best achieved by new element types? I don't know, but I'd like to point out that the graphics ARIA semantic called "graphics-document" (which extends "document") has no direct mapping in HTML. A "graphics-document" might contain a SVG, a canvas, an <img>
or rich text. It might also contain a mixture of all of these, and other elements, such as tables.
Specifying a chart semantic allows web authors to make a promise that some content is not just a flat image - it has structure and meaning, and offers affordances which permit non-visual browsing and (perhaps) interaction with a data set. Formalising a way to present the data as something non-visual would allow AT vendors to offer a more consistent experience, regardless of who built the chart.
@brennanyoung, I agree that the abstraction of the data from the presentation, style, and configuration/settings, is an important aspect of this proposal. Thank you for sharing that information about ARIA semantic "graphics-document".
Implementors have expressed some negative feedback with respect to this proposal, as originally formulated, for reasons including that it requires JavaScript to function as a markup element.
I like your new idea that a <chart>
element could behave like a <figure>
element, being capable of having descendent content including, but not limited to, <picture>
, <svg>
, and <canvas>
elements.
Those interested in the Web and charts might find the Vega project to be interesting.
Vega is a visualization grammar, a declarative language for creating, saving, and sharing interactive visualization designs. With Vega, you can describe the visual appearance and interactive behavior of a visualization in a JSON format, and generate web-based views using Canvas or SVG.
A Vega specification defines an interactive visualization in a JSON format. Specifications are parsed by Vega’s JavaScript runtime to generate both static images or interactive web-based views.
Brainstorming, one could use HTML5 custom elements with that Vega specification format in a manner resembling:
<web-chart type="application/vega+json" src="specification.json" />
and, in theory, providing a custom stylesheet would resemble:
<web-chart type="application/vega+json" src="specification.json">
<style src="custom.css" />
</web-chart>
I find the lack of examples with <table>
as a data source for a chart disturbing.
@crissov, I think that we broached that important scenario briefly in the discussion earlier. The original proposal included uses of external data sources (CSV, TSV, HTML) using a <source>
child element. So, at the time, the idea was that a Web chart could refer to and utilize tables in referenced external HTML5 resources.
Projects like Vega, however, can both reference external data resources and inline charts' data in their JSON specifications.
Inlining tables as data sources in HTML5 documents would be useful including for enabling JavaScript-based data modifications for dynamic charting scenarios and, towards crafting some good examples with <table>
elements as inline data sources, the Vega bar-chart example provides the following data:
"data": [
{
"name": "table",
"values": [
{"category": "A", "amount": 28},
{"category": "B", "amount": 55},
{"category": "C", "amount": 43},
{"category": "D", "amount": 91},
{"category": "E", "amount": 81},
{"category": "F", "amount": 53},
{"category": "G", "amount": 19},
{"category": "H", "amount": 87}
]
}
]
and accesses that named data source, table
, throughout that specification, e.g., when defining scales:
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "height"
}
]
One could expand upon the Vega specification format for Data objects for the markup-related scenarios under discussion. One could indicate that a named data source was available inline in an HTML5 document.
Then, a resource, specification.json
, in the Vega specification format, would be able to describe inline tabular data in a manner resembling:
"data": [
{
"name": "table",
"format": { "type": "table" },
"inline": true
}
]
in which case corresponding markup could resemble:
<web-chart type="application/vega+json" src="specification.json">
<table>
<thead>
<th name="category">Category</th>
<th name="amount">Amount</th>
</thead>
<tbody>
<tr><td>A</td><td>28</td></tr>
<tr><td>B</td><td>55</td></tr>
<tr><td>C</td><td>43</td></tr>
<tr><td>D</td><td>91</td></tr>
<tr><td>E</td><td>81</td></tr>
<tr><td>F</td><td>53</td></tr>
<tr><td>G</td><td>19</td></tr>
<tr><td>H</td><td>87</td></tr>
</tbody>
</table>
</web-chart>
Brainstorming, one could also inline other forms of data, e.g., CSV and TSV, in HTML5 documents utilizing <script>
elements.
That is, a resource, specification.json
, in the Vega specification format, could include something like:
"data": [
{
"name": "table",
"format": { "type": "csv" },
"inline": true
}
]
and a corresponding HTML5 document could include something like:
<web-chart type="application/vega+json" src="specification.json">
<script type="text/csv"><![CDATA[
...
]]></script>
</web-chart>
Any thoughts on these ideas or improving upon these examples?
Introduction
Web Charts is a proposal for Web-based data visualizations.
In the Web Charts model, a data visualization, or chart, references a number of candidate input data sources, which should be different formats for the same data, and also references a script with which to process the data from the selected input data source into styleable interactive content in the Shadow DOM. Input data could be static and file-based, perhaps including temporal cues, or (real-time) streaming data, or "data videos".
While Web Components and Custom Elements technologies are expected to be of use for both prototyping and demonstrating Web Charts, a
<web-chart>
custom element, a goal of this proposal is the eventual inclusion of Web Charts in the HTML Living Standard, a<chart>
element.This proposal hopes to gather participants for discussion, to form a team for rapid prototyping, and to build consensus from editors and interest from implementors, towards, during, and after incubation of this proposal with the Web Incubator Community Group.
Examples
In the following examples, a
<chart>
element can have<source>
,<script>
, or<style>
elements as children, a<source>
element can refer to either inline, static, or streaming data, thedata:
URL scheme is utilized for providing inline data, and existing video formats are utilized as placeholders for potential data streaming formats.Example 1: This example shows that a chart could process inline data using an indicated script into content in the Shadow DOM.
Example 2: This example shows that, instead of only inheriting its style from its containing document, a chart could provide a custom style.
Example 3: This example shows that, instead of inline data, a data source could be provided.
Example 4: This example shows that multiple data source options could be provided in a manner resembling
<picture>
,<audio>
, and<video>
elements.Example 5: This example shows that charts could process streaming data, or "data videos", to generate animated data visualizations.
Example 6: This example shows that charts could process and provide visualizations for real-time streaming data.
Accessibility
Accessibility is a priority for this proposal. Adding some complexity to accessibility-related solutions for Web Charts, however, is that charts' Shadow DOM content could utilize multiple technologies, e.g., HTML, SVG, Canvas, WebGL, WebGPU, WebXR.
Templates, e.g., utilizing a Handlebars syntax or JavaScript template literals, could enable charts to provide responsive natural-language descriptions. Changes to a chart's data, metadata, structure, or style would result in updates to its available natural-language description.
Parts of charts (e.g., points, slices, bars) could each have templated natural-language descriptions. Charts could combine and aggregate these contents together into long-form descriptions of charts and their contents.
Internationalization
Web Charts could provide templates for multiple languages and/or could make use of AI systems to translate descriptive natural-language contents.
Web Charts could support internationalization in terms of the natural-language labels provided to and subsequently displayed in interactive data visualizations.
Interoperability
Web Charts, as standard, would enable interoperability scenarios including the portability of data visualizations between software applications, e.g., via clipboarding or drag-and-drop operations.
Interestingly, responsive templated natural-language descriptions for accessibility could also be of use for interoperation with AI systems. AI systems could process both the input data and the natural-language descriptions of charts to answer questions, engage in dialogue, and perform data analysis about charts.
Configurability
What might the nature of configuration be with respect to scripting logic? Will there exist configuration options beyond style-related properties? How might developers utilize custom style variables or properties,
--*
? How might developers utilizedata-*
attributes on<chart>
or<script>
elements? How might developers utilize secondary<script>
elements with either inline script or JSON content?Data Object Model
Charts could provide access to their data through a data object model, or DataOM. With a DataOM, Web developers would be able to interact with visualizations' data, at runtime, and any updates there would be subsequently reflected in the visualizations.
Temporal Cues
Temporal data can be utilized to control visualizations, e.g., to cue animation events. Temporal data could, for instance, annotate data tables in multi-table models, one means of enabling "slideshows" comprised of multiple visualizations to be displayed using single elements.
Data Streaming Formats
Solutions for (real-time) data streaming could utilize the text- and data-related tracks of existing video formats or utilize entirely new formats.
Resembling "data video" concepts, data visualizations for (real-time) streaming data could be played, paused, stopped, and resumed. Data streaming formats could support seeking while simultaneously being error-tolerable, e.g., with respect to packet loss. Data streaming formats could, in these regards, transmit both instantaneous snapshots of charts' data and sequences of DataOM operations.
Reactive technologies connected to a DataOM could enable notifications and live queries, with updates to datasets arriving asynchronously in "data video" streams. Data visualizations could enqueue or schedule animations as updates arrived so as to remain aligned with the underlying dynamic data.
Previous Works
References
<script>
Element<source>
Element<style>
Element<audio>
Element<picture>
Element<video>
Elementdata:
URL SchemeConclusion
Thank you. I look forward to discussing these ideas with you.