Responsive bar charts in HTML and CSS
Creating responsive bar charts in HTML and CSS for international websites poses challenges with SVG for dynamic data. A hybrid approach using minimal JavaScript ensures accessibility and responsiveness without extensive logic.
Read original articleThis article discusses the creation of responsive bar charts in HTML and CSS for international websites. It highlights the challenges of using SVG for dynamic data visualizations due to its lack of layout techniques like Flexbox and Grid. The article explains the implementation of a hybrid bar chart using HTML, CSS, and minimal JavaScript for responsiveness. It also addresses the complexities of internationalization, bidirectional text, positive and negative values, and accessibility considerations in data visualizations. The use of logical properties in CSS simplifies handling left-to-right and right-to-left text directions. The article emphasizes the importance of creating accessible data visualizations and showcases examples of screen reader interactions with the charts. Overall, the article advocates for leveraging HTML and CSS for creating responsive and accessible data visualizations without the need for extensive JavaScript logic.
Related
SVG: The Good, the Bad, and the Ugly (2021)
SVG, scalable vector graphics, is a versatile format for web design, supporting various graphic elements like paths, shapes, text, and animations. Despite its power, its complexity and extensive specifications can be challenging for users.
Flow Charts with CSS Anchor Positioning
The article explains using CSS Anchor Positioning to create flow charts and diagrams. It covers positioning elements, creating nodes with CSS tricks, expanding charts, and making nodes draggable with JavaScript. It aims to assist developers in creating interactive charts.
CSS Surprise Manga Lines
The article explains creating a manga-style surprise effect with CSS, focusing on replicating character facial lines. It suggests using GIF overlays for better performance than CSS animations. Published on July 2, 2024.
Fluid Breakout Layout with CSS Grid
Nathan Long, a Senior UI Developer, explains creating a fluid breakout layout with CSS Grid. It accommodates various component widths without media queries, using grid areas and CSS variables for scalability.
Replicating D3 Charts with Swift Charts
The GitHub repository showcases various D3 charts recreated with Swift Charts, such as Histogram, Area Chart, Bar Chart, and more. Each chart is accompanied by a visual demonstration image.
I also started writing a simple responsive SVG charting library[2], but the author is right in that there are some fluid layouts that are just impossible to realise with SVG at the moment.
[1]: https://poll.lowyinstitute.org/report/2024/global-powers-and...
Full disclosure: I worked with those peeps a decade ago and really love their work.
This is not really true — you can position elements inside the SVG coordinate system using percentages and you can mix absolute coordinates and percentages. This allows you to have elements grow and shrink in reaction to width and height without distortion.
Wrapping text is possible with <foreignObject>, simply let HTML/CSS do the text layout wherever you need text within the SVG.
However it is still true that you usually want to do a bunch of calculations in JS based on the width to know how many chart ticks you want, how many labels, etc. But that is pretty easy to compute with the helpers from D3.
> When the container size changes, for example due to a browser resize or orientation change, the JavaScript needs to compute all SVG positions and sizes from scratch. Assuming this takes 50-100ms per chart, a page with 20 charts freezes the browser for 1-2 seconds.
I was once calculating positions for some complex labels on a timeline like chart (e.g. you have two entries close to each other and you would align the labels left and right to fit, but if there more you needed to stack them etc) and it did not take 50-100ms even for hundreds of entries. My code was neither pretty nor very efficient. Their 5-10 data points especially would not take that long. But even then you can always calculate them one by one and not block page interaction.
In addition people don't really resize their browsers that much anymore, if they ever did. The majority of traffic is mobile and there even the occasional phone rotation is not really that common, especially not for reading articles.
I'm not hip enough to find this funny.
an oxymoron, given that many assistive devices don't run JS [eg text-browsers like lynx]
Related
SVG: The Good, the Bad, and the Ugly (2021)
SVG, scalable vector graphics, is a versatile format for web design, supporting various graphic elements like paths, shapes, text, and animations. Despite its power, its complexity and extensive specifications can be challenging for users.
Flow Charts with CSS Anchor Positioning
The article explains using CSS Anchor Positioning to create flow charts and diagrams. It covers positioning elements, creating nodes with CSS tricks, expanding charts, and making nodes draggable with JavaScript. It aims to assist developers in creating interactive charts.
CSS Surprise Manga Lines
The article explains creating a manga-style surprise effect with CSS, focusing on replicating character facial lines. It suggests using GIF overlays for better performance than CSS animations. Published on July 2, 2024.
Fluid Breakout Layout with CSS Grid
Nathan Long, a Senior UI Developer, explains creating a fluid breakout layout with CSS Grid. It accommodates various component widths without media queries, using grid areas and CSS variables for scalability.
Replicating D3 Charts with Swift Charts
The GitHub repository showcases various D3 charts recreated with Swift Charts, such as Histogram, Area Chart, Bar Chart, and more. Each chart is accompanied by a visual demonstration image.