Code Monkey home page Code Monkey logo

highcharts-js-rails's Introduction

Highcharts JS Rails

Easily configure a Highcharts JS chart for use in a Rails application.

All major options in Highcharts are available to be used with Highcharts JS Rails. However, the exporting and navigation options are not yet built in. You will need to do those manually.

The Highcharts class's methods match up to the corresponding Highcharts options. Take a look at http://www.highcharts.com/ref/ for the full reference.

Many have a default option assigned to them. Those that have one are listed below:

  • chart: renderTo (String)
  • credits: enabled (Boolean)
  • legend: enabled (Boolean)
  • plotOptions.marker: enabled (Boolean)
  • subtitle: text (String)
  • title: text (String)
  • xAxis: categories (Array)
  • xAxis.events: setExtremes (function)
  • xAxis.labels: enabled (Boolean)
  • xAxis.title: text (String)
  • yAxis: title (String)
  • yAxis.events: setExtremes (function)
  • yAxis.stackLabels: enabled (Boolean)
  • yAxis.labels: enabled (Boolean)
  • yAxis.title: text (String)

xAxis Notes

  • The categories option's array of values will be automatically formatted based on its class unless you pass :skip_category_formatting => true.
  • The tickInterval option is only necessary if you want to override automatic tickInterval creation. If the option is not passed or :auto is passed, the tickInterval will be calculated based on the number of categories passed.

For the xAxis, yAxis, and series options, you must pass an array of hashes. Each of those hashes will be converted into the appropriate set of options.

Example

Ruby:

chart = Highcharts.new
chart.chart({:renderTo => 'graph'})
chart.title('Highcharts Example')
chart.xAxis([{:categories => ['October 12', 'October 13', 'October 14']}])
chart.yAxis([{:title => 'Impressions', :min => 0}])
chart.series([{:name => 'Impressions', :yAxis => 0, :type => 'line', :data => [100000, 122000, 127000]}])
chart.legend({:layout => 'vertical', :align => 'right', :verticalAlign => 'top', :x => -10, :y => 100, :borderWidth => 0})
chart.tooltip({:formatter => "function(){ return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y; }"})

HTML/ERB:

<%= chart %>
<div id="graph" style="width: 400px; height: 200px;"></div>

highcharts-js-rails's People

Contributors

agrobbin avatar tanelj avatar

Watchers

 avatar  avatar

Forkers

priidikvaikla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.