StataBS / indikatoren

Portal für Statistische Indikatoren des Kantons Basel-Stadt, Schweiz.
http://www.statistik.bs.ch/zahlen/indikatoren/portal.html
3 stars 11 forks source link

Optimize template001.js #1559

Open bl99 opened 5 years ago

bl99 commented 5 years ago

Move content of function from chart.events.load to separate function onLoadFunction() which can be called in chart-templates, e.g. when there are chart-specific functions in chart-templates that would override chart.events.load.

bl99 commented 4 years ago

check if this works with SVG-Generator

scheme, e.g. template001.js:

// call this in chart.events.load: function () {onLoadFunction(this);}
var onLoadFunction = function (chart) {

    //remove default function for credits-link
    chart.credits.element.onclick = function () { };

    //for top-left legends with no x defined: move legend to x position of first yAxis
    if (chart['legend']['options']['align'] == 'left' && chart['legend']['options']['verticalAlign'] == 'top' && chart['legend']['options']['x'] == 0) {
        chart.update({
            legend: {
                x: chart.yAxis[0].left - chart.spacingBox.x - chart.legend.padding
            }
        });
    }
};

(function () {
    return {
        chart: {
            events: {
                load: function () {
                    onLoadFunction(this);
                }
            }
        },
[...]