Sha256: bccc23e6237452c8ecf97b35c7810d8145aae50346ceef2a5fdee6cf02003d4b

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

class RailsDataExplorer
  class Chart

    include ActionView::Helpers::NumberHelper
    attr_accessor :output_buffer # required for content_tag
    include ActionView::Helpers::TagHelper

    def dom_id
      "rde-chart-#{ object_id }"
    end

    # Returns true if this chart will be rendered. Sometimes we can't make that
    # decision until render time. Override this method in sub classes, e.g.,
    # to avoid rendering ParallelCoordinates when all data series are categorical.
    def render?
      true
    end

  protected

    # Renders an HTML table
    # @param[OpenStruct, Struct] table_struct
    def render_html_table(table_struct)
      content_tag(:table, :class => 'table rde-table') do
        table_struct.rows.map { |row|
          content_tag(row.tag, :class => row.css_class) do
            row.cells.map { |cell|
              if cell.ruby_formatter
                content_tag(
                  cell.tag,
                  instance_exec(cell.value, &cell.ruby_formatter),
                  :class => cell.css_class,
                  :title => cell.title,
                  :style => cell.style,
                )
              else
                content_tag(
                  cell.tag,
                  cell.value,
                  :class => cell.css_class,
                  :title => cell.title,
                  :style => cell.style,
                )
              end
            }.join.html_safe
          end
        }.join.html_safe
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-data-explorer-0.1.0 lib/rails-data-explorer/chart.rb
rails-data-explorer-0.0.1 lib/rails-data-explorer/chart.rb