Sinatra

Require it after you require 'sinatra/base'.

require 'sinatra/base'
require 'apexcharts'

To add the asset (ApexCharts.JS), include a script tag in your template as follows:

template :index do
  <<~INDEX
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
    <% series = {...} %>
    <%= pie_chart(series, legend: "left") %>
  INDEX
end

For more details, see example.

Last updated