BathHacked/energy-sparks

View on GitHub
app/components/chart_component/chart_component.html.erb

Summary

Maintainability
Test Coverage
<% if valid_config? %>

  <div id="chart_wrapper_<%= chart_type %>" class="chart-wrapper">

    <% if title %>
      <h4 id="chart-section-<%= chart_type %>" class="chart-title"><%= title %></h4>
    <% end %>

    <% if subtitle %>
      <h5 class="chart-subtitle"><%= subtitle %></h5>
    <% end %>

    <%= header %>

    <%= render 'shared/analysis_controls',
               chart_id: chart_id,
               axis_controls: axis_controls,
               analysis_controls: analysis_controls %>

    <div id="<%= chart_id %>" class="<%= html_class %>"
         data-autoload-chart="<%= autoload_chart %>"
         data-chart-config="<%= chart_config_json %>">
    </div>
    <div id='chart-error' class='d-none'><%= I18n.t('chart_data_values.standard_error_message') %></div>

  </div>

  <%= footer %>

<% else %>

  <div class="padded-row">
    <div class="bg-negative-light">
      <p>The chart can't be displayed - please check the configuration</p>
    </div>
  </div>

<% end %>