kHighchartsGanttJS top-level constant
String
const kHighchartsGanttJS
Implementation
const String kHighchartsGanttJS = '''
(function (scope) {
const HighchartsFlutter = scope.HighchartsFlutter = {
chart: void 0,
factory: Highcharts.ganttChart,
init: function (options) {
if (scope.self === scope.top && scope.document.readyState === 'loading') {
addEventListener('load', function () { HighchartsFlutter.update(options, true); });
} else {
HighchartsFlutter.update(options, true);
}
},
update: function (options, redraw = true, animation = true) {
let chart = HighchartsFlutter.chart;
// Make sure to use flexible sizing inside the webview (#54)
if (typeof options?.chart?.height !== 'undefined') {
options.chart.height = options.chart.height === 0 ? null : options.chart.height;
}
if (typeof options?.chart?.width !== 'undefined') {
options.chart.width = options.chart.width === 0 ? null : options?.chart?.width;
}
// Create chart on initial update.
if (!chart) {
chart = HighchartsFlutter.chart = HighchartsFlutter.factory(
'container',
Highcharts.merge(
{
chart: {
backgroundColor: '#FFF0'
},
exporting: {
enabled: false
},
title: {
text: void 0
},
},
options
)
);
// Recreate chart if no update for options3d.
} else if (
!chart.options.options3d?.enabled &&
options.chart?.options3d?.enabled
) {
chart.destroy();
HighchartsFlutter.chart = HighchartsFlutter.factory('container', options);
// Regular chart update.
} else {
chart.update(options, redraw, true, animation);
}
// Sync the document title with the chart title for accessibility.
if (scope.document.title !== chart.title) {
scope.document.title = chart.title.textStr || 'Chart';
}
}
};
})(window);
''';