syampillai / SOCharts

A wrapper around the "echarts" JavaScript library to use it as a Vaadin component.
Apache License 2.0
27 stars 11 forks source link

Enabling "aria.enable" to generate aria-label for accessibility #30

Closed hazren-sulaiman closed 6 months ago

hazren-sulaiman commented 9 months ago

Hi, is there a way to enable "aria.enable" in order to generate "aria-label" for accessibility? This will be useful for screenreader to describe the chart.

Reference: https://echarts.apache.org/handbook/en/best-practices/aria/

syampillai commented 6 months ago

This is not supported currently. However, you can append additional JSON to the generated output via new addCustomEncoding methods added recently in version 3.2.5.

        SOChart soChart = new SOChart() {
            @Override
            protected void addCustomEncoding(ComponentPart componentPart, StringBuilder buffer) {
                if(componentPart == null) {
                    buffer.append("""
                            "aria": {
                                "show": true
                              },
                            """);
                }
            }
        };