Skip to content

CSS classes & SVG export #381

Open
Open
@ericemc3

Description

@ericemc3
  1. I discern few CSS classes in a Plot:
<svg class="plot " ...
<g class="tick" ...

For now, all texts inherit a generic .plot class (10px, system-ui...) In the following example, there is no visual difference between the axis label and the orange bar label :

image

It would be useful to tag each chart component with a specific class, especially regarding texts and axes (everything that is not linked to a channel). This would allow us to differentiate and style them with CSS, without having to do it by hand in the form of attributes added to the Plot spec:

  • axis labels
  • tick labels
  • facet labels
  • more broadly: title, subtitle and source of the graph, annotations...

An alternative, which is not exclusive, is to specify attributes as in D3, but it seems to me much more elegant, light, standard and extensible to do it in CSS, especially if it is repetitive.

It would also be useful to be able to assign an id to a Plot.

  1. The SVG export (download SVG) is not of good quality for texts, it does not include relevant CSS classes.
    image
    These should be inserted into the SVG. A simple mechanism could also allow custom CSS definitions to be linked to the current Plot, so that they can also be found in the SVG export.

PS: Plot is a great library, very intellectually stimulating, and the 21 beautifully written articles in the https://observablehq.com/collection/@observablehq/plot collection should be read by all data scientists!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions