<commit_before># The big picture: the chart object renders a chart that can be based on
# jqPlot (IE<9) or D3 (newer browsers). The chart will be rendered inside a
# holder element and might have a header with some buttons.
#
class @Chart extends Backbone.Model
  initialize : ->
    # every chart has a series (=~ gqueries) collection. This helps us handling
    # them
    @series = switch @get('type')
      when 'block' then new BlockChartSeries()
      when 'scatter' then new ScatterChartSeries()
      else new ChartSeries()
    @bind('change:type', @render)
    @render()

  render : =>
    return false unless @supported_by_current_browser()

    klass = @find_view_class()
    @view = new klass(
      model: this
      el: @outer_container()
    )

    @view.update_header()

  # -- view class detection --------------------------------------------------

  find_view_class: =>
    d3_support = Browser.hasD3Support() && !window.disable_d3
    switch @get('type')
      when 'bezier'
        if d3_support then D3.bezier.View else BezierChartView
      when 'mekko'
        if d3_support then D3.mekko.View else MekkoChartView<commit_msg>documentation<commit_after># The big picture: the chart object renders a chart that can be based on
# jqPlot (IE<9) or D3 (newer browsers). The chart will be rendered inside a
# holder element:
#
#     #charts_wrapper
#       .chart_holder
#         header           - optional
#         .chart_canvas#id - where the chart is actually rendered
#       .chart_holder      - the wrapper can hold multiple charts
#         ...
#
# The holder element is created dynamically using underscore templates; we can
# specify the element that will contain it; the default is #charts_wrapper,
# but popup elements might use something else
#
# TODO: the chart constructor immediately triggers the render method, although
# we could still be waiting for the API response. The event chain should be
# refactored.
#
class @Chart extends Backbone.Model
  initialize : ->
    # every chart has a series (=~ gqueries) collection. This helps us handling
    # them
    @series = switch @get('type')
      when 'block' then new BlockChartSeries()
      when 'scatter' then new ScatterChartSeries()
      else new ChartSeries()
    @bind('change:type', @render)
    # this should be called later! It's still here for backwards compatibility
    # with the old jqplot charts. See ETPlugin charts for a better approach.
    @render()

  render : =>
    return false unless @supported_by_current_browser()

    klass = @find_view_class()
    @view = new klass(
      model: this
      el: @outer_container()
    )

    @view.update_header()

  # -- view class detection --------------------------------------------------

  find_view_class: =>
    d3_support = Browser.hasD3Support() && !window.disable_d3
    switch @get('type')
      when 'bezier'
        if d3_support then D3.bezier.View else BezierChartView
      when 'mekko'
        if d3_support then D3.mekko.View else MekkoChartView
{'fraction_non_alphanumeric': 0.11604774535809019, 'fraction_numerical': 0.005968169761273209, 'mean_word_length': 2.6973039215686274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2936', 'n_tokens_mistral': 859, 'n_tokens_neox': 835, 'n_words': 314}