Encapsulate common chart "recipes" in reusable form

Issue #877 resolved
Brian Lewis repo owner created an issue

The RowColChart component sets up the chart according to more than a dozen input bindings. For tweaking of the chart beyond these basic setups, we can use the onRenderChart callback to modify the echart option object before it is rendered.

Modifying the option requires a good knowledge of the structure of this object; and experience shows that a number of common patterns tend to re-occur.

The new ChartOps class provides methods to act on a higher level on the option object, to achieve more “macro-level” outcomes.

ChartOpts has a fluent interface so methods can be chained. Create the ChartOps using the static chartOpsfunction:

        public onChartRender(option, echarts, renderedType) {
            Sw.Charts.chartOps(option)
                .showLegend(renderedType != "pie" && (option.series.count > 1))
                .showPieLabels(renderedType == "pie")
                .minimalInk()
                .lookups(this.lookups)
                .translateLabels("authorities");
        }

Comments (1)

  1. Log in to comment