@@ -452,6 +452,111 @@ def add_series(self, *series):
452452
453453 self .options .series = updated_series
454454
455+ @classmethod
456+ def from_array (cls ,
457+ value ,
458+ series_type = 'line' ,
459+ series_kwargs = None ,
460+ options_kwargs = None ,
461+ chart_kwargs = None ,
462+ is_maps_chart = False ):
463+ """Create a :class:`Chart <highcharts_core.chart.Chart>` instance with
464+ one series populated from the array contained in ``value``.
465+
466+ .. seealso::
467+
468+ The specific structure of the expected array is highly dependent on the type of data
469+ point that the series needs, which itself is dependent on the series type itself.
470+
471+ Please review the detailed :ref:`series documentation <series_documentation>` for
472+ series type-specific details of relevant array structures.
473+
474+ :param value: The array to use to populate the series data.
475+ :type value: iterable
476+
477+ :param series_type: Indicates the series type that should be created from the array
478+ data. Defaults to ``'line'``.
479+ :type series_type: :class:`str <python:str>`
480+
481+ :param series_kwargs: An optional :class:`dict <python:dict>` containing keyword
482+ arguments that should be used when instantiating the series instance. Defaults
483+ to :obj:`None <python:None>`.
484+
485+ .. warning::
486+
487+ If ``series_kwargs`` contains a ``data`` key, its value will be *overwritten*.
488+ The ``data`` value will be created from ``df`` instead.
489+
490+ :type series_kwargs: :class:`dict <python:dict>`
491+
492+ :param options_kwargs: An optional :class:`dict <python:dict>` containing keyword
493+ arguments that should be used when instantiating the :class:`HighchartsOptions`
494+ instance. Defaults to :obj:`None <python:None>`.
495+
496+ .. warning::
497+
498+ If ``options_kwargs`` contains a ``series`` key, the ``series`` value will be
499+ *overwritten*. The ``series`` value will be created from the data in ``df``.
500+
501+ :type options_kwargs: :class:`dict <python:dict>` or :obj:`None <python:None>`
502+
503+ :param chart_kwargs: An optional :class:`dict <python:dict>` containing keyword
504+ arguments that should be used when instantiating the :class:`Chart` instance.
505+ Defaults to :obj:`None <python:None>`.
506+
507+ .. warning::
508+
509+ If ``chart_kwargs`` contains an ``options`` key, ``options`` will be
510+ *overwritten*. The ``options`` value will be created from the
511+ ``options_kwargs`` and the data in ``df`` instead.
512+
513+ :type chart_kwargs: :class:`dict <python:dict>` or :obj:`None <python:None>`
514+
515+ :param is_maps_chart: if ``True``, enforces the use of
516+ :class:`HighchartsStockOptions <highcharts_stock.options.HighchartsStockOptions>`.
517+ If ``False``, applies
518+ :class:`HighchartsOptions <highcharts_stock.options.HighchartsOptions>`.
519+ Defaults to ``False``.
520+
521+ .. note::
522+
523+ The value given to this argument will override any values specified in
524+ ``chart_kwargs``.
525+
526+ :type is_maps_chart: :class:`bool <python:bool>`
527+
528+ :returns: A :class:`Chart <highcharts_core.chart.Chart>` instance with its
529+ data populated from the data in ``value``.
530+ :rtype: :class:`Chart <highcharts_core.chart.Chart>`
531+
532+ """
533+ series_type = validators .string (series_type , allow_empty = False )
534+ series_type = series_type .lower ()
535+ if series_type not in SERIES_CLASSES :
536+ raise errors .HighchartsValueError (f'series_type expects a valid Highcharts '
537+ f'series type. Received: { series_type } ' )
538+
539+ series_kwargs = validators .dict (series_kwargs , allow_empty = True ) or {}
540+ options_kwargs = validators .dict (options_kwargs , allow_empty = True ) or {}
541+ chart_kwargs = validators .dict (chart_kwargs , allow_empty = True ) or {}
542+
543+ series_cls = SERIES_CLASSES .get (series_type , None )
544+
545+ series = series_cls .from_array (value , series_kwargs = series_kwargs )
546+
547+ options_kwargs ['series' ] = [series ]
548+ chart_kwargs ['is_maps_chart' ] = is_maps_chart
549+
550+ if is_maps_chart :
551+ options = HighchartsMapsOptions (** options_kwargs )
552+ else :
553+ options = HighchartsOptions (** options_kwargs )
554+
555+ instance = cls (** chart_kwargs )
556+ instance .options = options
557+
558+ return instance
559+
455560 @classmethod
456561 def from_series (cls , * series , kwargs = None ):
457562 """Creates a new :class:`Chart <highcharts_core.chart.Chart>` instance populated
0 commit comments