HighchartsChart constructor

HighchartsChart(
  1. HighchartsOptions options, {
  2. Key? key,
  3. String? css,
  4. bool debug = kDebugMode,
  5. String? javaScript,
  6. List<String> javaScriptModules = const ['https://code.highcharts.com/highcharts.js', 'https://code.highcharts.com/highcharts-more.js', 'https://code.highcharts.com/highcharts-3d.js', 'https://code.highcharts.com/modules/solid-gauge.js', 'https://code.highcharts.com/modules/annotations.js', 'https://code.highcharts.com/modules/boost.js', 'https://code.highcharts.com/modules/broken-axis.js', 'https://code.highcharts.com/modules/data.js', 'https://code.highcharts.com/modules/exporting.js', 'https://code.highcharts.com/modules/offline-exporting.js', 'https://code.highcharts.com/modules/accessibility.js'],
  7. Map<String, void Function(Object?)> events = const {},
  8. bool keepAlive = true,
  9. Widget onError(
    1. HighchartsChart,
    2. Object?
    )?,
  10. FutureOr<void> onLoaded(
    1. HighchartsChart
    )?,
  11. Widget onLoading(
    1. HighchartsChart
    )?,
})

Implementation

HighchartsChart(
  this.options, {
  super.key,
  this.css,
  this.debug = kDebugMode,
  this.javaScript,
  this.javaScriptModules = const [
    'https://code.highcharts.com/highcharts.js',
    'https://code.highcharts.com/highcharts-more.js',
    'https://code.highcharts.com/highcharts-3d.js',
    'https://code.highcharts.com/modules/solid-gauge.js',
    'https://code.highcharts.com/modules/annotations.js',
    'https://code.highcharts.com/modules/boost.js',
    'https://code.highcharts.com/modules/broken-axis.js',
    'https://code.highcharts.com/modules/data.js',
    'https://code.highcharts.com/modules/exporting.js',
    'https://code.highcharts.com/modules/offline-exporting.js',
    'https://code.highcharts.com/modules/accessibility.js',
  ],
  this.events = const {},
  this.keepAlive = true,
  this.onError,
  this.onLoaded,
  this.onLoading,
}) {
  final String json = options.toJSON();

  if (debug) {
    debugPrint(json);
  }

  view = HighchartsView(
    debug: debug,
    keepAlive: keepAlive,
    head: css == null ? null : HighchartsHelpers.styleTag(css),
    body: javaScriptModules.map(HighchartsHelpers.scriptTag).join('\n'),
    foot: [
      '''
        highcharts_flutter.debug=${debug};
        highcharts_flutter.factory=Highcharts.chart;
      ''',
      javaScript,
      'highcharts_flutter.init($json);',
    ].map(HighchartsHelpers.scriptTag).join('\n'),
    onError: (onError != null
        ? (_, error) {
            return onError!(this, error);
          }
        : null),
    onLoaded: (onLoaded != null
        ? (_) {
            return onLoaded!(this);
          }
        : null),
    onLoading: (onLoading != null
        ? (_) {
            return onLoading!(this);
          }
        : null),
  );
}