• Stars
    star
    1,048
  • Rank 43,968 (Top 0.9 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 15 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make highcharts a la ruby , works in rails 5.X / 4.X / 3.X, and other ruby web frameworks

LazyHighCharts

Gitter

This gem provides a simple and extremely flexible way to use HighCharts from ruby code. Tested on Ruby on Rails, Sinatra and Nanoc, but it should work with others too. Highcharts is not free for commercial use, so make sure you have a valid license to use Highcharts.

Build Status Code Climate

VERSION ChangeLog

Information

Getting Help

  • Please report bugs on the issue tracker but read the "getting help" section in the wiki first.

Installation

Installation with rubygems

To install it, you just need to add it to your Gemfile:

gem 'lazy_high_charts'

edge version on trial

gem 'lazy_high_charts' --pre

then run

bundle install

and make sure to get the latest version (unless you'd like an older version for some reason)

rake highcharts:update

and add this in the application.js

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require turbolinks

//= require highcharts/highcharts
//= require highcharts/highcharts-more
//= require highcharts/highstock

to install it.

Usage:

Controller code:

@chart = LazyHighCharts::HighChart.new('graph') do |f|
  f.title(text: "Population vs GDP For 5 Big Countries [2009]")
  f.xAxis(categories: ["United States", "Japan", "China", "Germany", "France"])
  f.series(name: "GDP in Billions", yAxis: 0, data: [14119, 5068, 4985, 3339, 2656])
  f.series(name: "Population in Millions", yAxis: 1, data: [310, 127, 1340, 81, 65])

  f.yAxis [
    {title: {text: "GDP in Billions", margin: 70} },
    {title: {text: "Population in Millions"}, opposite: true},
  ]

  f.legend(align: 'right', verticalAlign: 'top', y: 75, x: -50, layout: 'vertical')
  f.chart({defaultSeriesType: "column"})
end

@chart_globals = LazyHighCharts::HighChartGlobals.new do |f|
  f.global(useUTC: false)
  f.chart(
    backgroundColor: {
      linearGradient: [0, 0, 500, 500],
      stops: [
        [0, "rgb(255, 255, 255)"],
        [1, "rgb(240, 240, 255)"]
      ]
    },
    borderWidth: 2,
    plotBackgroundColor: "rgba(255, 255, 255, .9)",
    plotShadow: true,
    plotBorderWidth: 1
  )
  f.lang(thousandsSep: ",")
  f.colors(["#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354"])
end

View Helpers:

<%= high_chart_globals(@chart_globals) %>
<%= high_chart("some_id", @chart) %>

high_chart_globals is optional. Use it to set the global options of all charts that are currently displayed on the page. More info here.

No Data

When your series has no data and you want to display a message using Highcharts' noData feature (Highcarts doc) you have to include the no-data-to-display.js file like so:

//= require highcharts/highcharts
//= require highcharts/highcharts-more
//= require highcharts/modules/no-data-to-display

You can then set the actual message that is displayed like so:

    @chart = LazyHighCharts::HighChart.new('graph') do |f|
      f.options[:lang] = { noData: "My beautiful noData message" }
      f.title(text: nil)
      f.series([])
    end

Demo projects:

Nanoc App

Rails App

Sinatra App

Update to latest js library. Additional command line

To update to the current highcharts.js directly from http://code.highcharts.com/", you can always run

rake highcharts:update

And HC will be copied to your vendor/assets directory on your app

Deprecation notice:

If you use rails 2.3.x or 3.0.x or 3.1.x, please use versions less than 1.3.3.

Contributing

We're open to any contribution. It has to be tested properly though.

  • Fork the project
  • Do your changes and commit them to your repository
  • Test your changes. We won't accept any untested contributions (except if they're not testable).
  • Create an issue with a link to your commits.

Thanks for all contributors

Maintainers

License

More Repositories

1

Dante

Just another Medium wysiwyg editor clone
JavaScript
2,004
star
2

dante2

A complete rewrite of dante editor in draft-js
JavaScript
910
star
3

espinita

Audit activerecord models like a boss (and works with rails 4!)
Ruby
220
star
4

chaskiq-newsletters

Newsletter Rails engine
Ruby
127
star
5

BigBroda

GoogleBig Query ActiveRecord Adapter & API client
Ruby
110
star
6

rails-ui

A collection of components based on Ruby ViewComponent & Stimulus, heavily inspired by shadcn/ui
HTML
27
star
7

lazy_google_analytics

google analytics api client for the lazy
Ruby
22
star
8

autocontext

An Elixir Ecto utility library that provides ActiveRecord-like callbacks, simplifying the management of database operations. This includes before_save, after_save, create, update, and delete functions.
Elixir
12
star
9

detached-carrot

A port of SimplifiedStarling plugin for push-pop active_record tasks with RabbitMQ
Ruby
11
star
10

acts_as_uploaded

a simple rails plugin for upload_nginx module and amazon s3 service, inspired in attachment_fu, (work in progress but in production in artenlinea.com)
Ruby
8
star
11

osc-puredata-ruby

JavaScript
5
star
12

dante2-tests

dante tests using es6 modules
JavaScript
3
star
13

apidone-client

api done client made in ruby (coding) dojo
Ruby
3
star
14

ws-celluloid

JavaScript
3
star
15

discobolo

ruby worker system for disque
Ruby
3
star
16

needish-gem

this gem provides basic methods to access needish.com api, profile, friends, needs and helps
Ruby
3
star
17

faye-tests

Ruby
2
star
18

go_4_live

Go and ableton live OSC experiment
Go
2
star
19

componium-beat

a set of gui abstractions for PD
Pure Data
2
star
20

sinatra-oa-consumer

sinatra-oauth-consumer
1
star
21

LoadTester

This is a simple package to benchmark http requests, This especially shows you how many requests per second a http server is capable of serving.
Go
1
star
22

code-test

Ruby
1
star
23

mongo_mail_store

Rails plugin to catch outcoming emails and store it in MongoDB
Ruby
1
star
24

nginx-chef

clone of nginx-chef v 2.7.5
Ruby
1
star