renderFinancialChart method

  1. @override
RenderedChartJS renderFinancialChart(
  1. Element output,
  2. ChartTimeSeries chartSeries, {
  3. bool? ohlc,
  4. bool? candlestick,
})
override

Renders financial chart.

ohlc Renders a OHLC chart (default). candlestick Renders a Candlestick chart.

Implementation

@override
RenderedChartJS renderFinancialChart(
    Element output, ChartTimeSeries chartSeries,
    {bool? ohlc, bool? candlestick}) {
  checkRenderParameters(output, chartSeries);
  checkLoadedFinancial();

  candlestick ??= false;
  ohlc ??= !candlestick;

  if (ohlc && candlestick) {
    print(
        'renderFinancialChart> Conflicting parameters: ohlc = $ohlc ; candlestick = $candlestick! Will use ohlc as primary.');
  }

  var canvas = asCanvasElement(output);

  var seriesPairs = chartSeries.seriesAsEntriesOfTOHLC(
      sortSeriesByCategory: chartSeries.options.sortCategories,
      mapDateTimeToMillis: true);

  chartSeries.ensureColors(colorGenerator);

  var colors = chartSeries.colors!;
  var colorsUp = chartSeries.colorsLighter;
  var colorsDown = chartSeries.colorsDarker;
  var colorsUnchanged = chartSeries.disabledColors!;

  var renderArgs = [
    canvas,
    chartSeries.title,
    chartSeries.xTitle,
    chartSeries.yTitle,
    _xAxisMinMax(chartSeries),
    _yAxisMinMax(chartSeries),
    JsObject.jsify(seriesPairs),
    _verticalLinesConfig(chartSeries),
    JsObject.jsify(colors),
    JsObject.jsify(colorsUp),
    JsObject.jsify(colorsDown),
    JsObject.jsify(colorsUnchanged),
    ohlc,
    _onClick(chartSeries)
  ];

  var chartObject = _jsWrapper!.callMethod('renderFinancial', renderArgs);

  return RenderedChartJS(this, 'financial-${ohlc ? 'ohlc' : 'candlestick'}',
      chartObject, chartSeries);
}