Class: Pyk::Highcharts
- Inherits:
-
Object
- Object
- Pyk::Highcharts
- Defined in:
- lib/pyk/highcharts.rb
Class Method Summary collapse
-
.area(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil, stacking = "normal") ⇒ Object
Pyk::Highcharts.column.
-
.areaspline_by_date(data, render_to_name, background_color, start_date, end_date, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.areaspline_by_date(data, render_to_name, background_color, start_date, end_date).
-
.bar(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.bar(data, categories, render_to_name, background_color).
-
.column(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil, stacking = "normal") ⇒ Object
Pyk::Highcharts.column(data, categories, render_to_name, background_color).
-
.donut(data, series_name, render_to_name, background_color, chart_title, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.donut(data, series_name, render_to_name, background_color).
-
.funnel(data, series_name, render_to_name, background_color, show_in_legend = false, data_labels = false, text_color = "black", neck_width = "30%", neck_height = "25%") ⇒ Object
Pyk::Highcharts.funnel(data, series_name, render_to_name, background_color, show_in_legend=false, data_labels=false, text_color=“black”, neck_width=“30%”, neck_height=“25%”).
- .line(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil) ⇒ Object
-
.pie(data, series_name, render_to_name, background_color, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.pie(data, series_name, render_to_name, background_color).
-
.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil) ⇒ Object
Pyk::Highcharts.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color).
Class Method Details
.area(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil, stacking = "normal") ⇒ Object
Pyk::Highcharts.column
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pyk/highcharts.rb', line 43 def self.area(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil, stacking="normal") LazyHighCharts::HighChart.new('area') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"area", height: height} ) data.each do |d| f.series(:name=>d[0],:data=> d[1], borderWidth: 0, color: d[2]) end f.xAxis({categories: categories, tickmarkPlacement: 'on', title: { enabled: false }, :labels=>{:align => 'center'}, type: :string}) f.yAxis({gridLineWidth: 0, title: nil, :min => 0}) f.title({ :text=> nil}) f.({:area=>{:stacking=>stacking, lineColor: '#666666', lineWidth: 1, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}}) end end |
.areaspline_by_date(data, render_to_name, background_color, start_date, end_date, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.areaspline_by_date(data, render_to_name, background_color, start_date, end_date)
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/pyk/highcharts.rb', line 81 def self.areaspline_by_date(data, render_to_name, background_color, start_date, end_date, show_in_legend=false, data_labels=false) categories = [] (start_date..end_date).each do |d| categories << d end return LazyHighCharts::HighChart.new('graph') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"areaspline"} ) data.each do |d2| f.series(:name=>d2[0],:data=> d2[1], borderWidth: 0) end f.xAxis({categories: categories, gridLineWidth: 0, :labels=>{:rotation=>-45 , :align => 'right'}, type: :datetime}) f.legend({layout: "horizontal", :borderWidth => 0}) f.yAxis({gridLineWidth: 0, title: nil, :min => 0}) f.title({ :text=> nil}) f.({:area=>{pointInterval: 1.day, marker: {enabled: false, symbol: 'circle',radius: 2,states: {hover: {enabled: true}}}, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}}) end end |
.bar(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.bar(data, categories, render_to_name, background_color)
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pyk/highcharts.rb', line 15 def self.(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false) LazyHighCharts::HighChart.new('column') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, defaultSeriesType: "bar"} ) data.each do |d| f.series(:name=>d[0],:data=> d[1], borderWidth: 0) end f.xAxis({categories: categories, gridLineWidth: 0, :labels=>{:align => 'right'}, type: :string}) f.yAxis({gridLineWidth: 0, title: nil, :min => 0}) f.title({ :text=> nil}) f.({:bar=>{:stacking=>"normal", dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}}) end end |
.column(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil, stacking = "normal") ⇒ Object
Pyk::Highcharts.column(data, categories, render_to_name, background_color)
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pyk/highcharts.rb', line 29 def self.column(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil, stacking="normal") LazyHighCharts::HighChart.new('column') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column", height: height} ) data.each do |d| f.series(:name=>d[0],:data=> d[1], borderWidth: 0, color: d[2]) end f.xAxis({categories: categories, gridLineWidth: 0, :labels=>{:align => 'center'}, type: :string}) f.yAxis({gridLineWidth: 0, title: nil, :min => 0}) f.title({ :text=> nil}) f.({:column=>{:stacking=>stacking, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}}) end end |
.donut(data, series_name, render_to_name, background_color, chart_title, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.donut(data, series_name, render_to_name, background_color)
70 71 72 73 74 75 76 77 78 |
# File 'lib/pyk/highcharts.rb', line 70 def self.donut(data, series_name, render_to_name, background_color, chart_title, show_in_legend=false, data_labels=false) LazyHighCharts::HighChart.new('pie') do |f| f.chart({:defaultSeriesType=>"pie" , :margin=> [0, 0, 0, 0], backgroundColor: background_color, renderTo: render_to_name}) f.title({verticalAlign: 'middle',floating: true,text: chart_title}) f.series({:type=> 'pie', :name=> series_name, :data=> data, borderWidth: 0, innerSize: '67%', size: '100%'}) f.legend(:layout=> 'vertical',:style=> {:left=> '0', :bottom=> '0',:right=> '0',:top=> '0'}) f.(series: {pointPadding: 0,groupPadding: 0}, :pie=>{:allowPointSelect=>true, :cursor=>"pointer" , showInLegend: show_in_legend, :dataLabels=>{:enabled=>data_labels}}) end end |
.funnel(data, series_name, render_to_name, background_color, show_in_legend = false, data_labels = false, text_color = "black", neck_width = "30%", neck_height = "25%") ⇒ Object
Pyk::Highcharts.funnel(data, series_name, render_to_name, background_color, show_in_legend=false, data_labels=false, text_color=“black”, neck_width=“30%”, neck_height=“25%”)
100 101 102 103 104 105 106 107 |
# File 'lib/pyk/highcharts.rb', line 100 def self.funnel(data, series_name, render_to_name, background_color, show_in_legend=false, data_labels=false, text_color="black", neck_width="30%", neck_height="25%") LazyHighCharts::HighChart.new('graph') do |f| f.chart({type: "funnel" , margin: [0, 0, 0, 0], backgroundColor: background_color, renderTo: render_to_name}) f.series({name: series_name, data: data}) f.[:title][:text] = nil f.plotOptions(series: {:dataLabels=>{:enabled=>data_labels, format: '<b>{point.name}</b> ({point.y:,.0f})', color: text_color, softConnector: true}, neckWidth: neck_width, neckHeight: neck_height}) end end |
.line(data, categories, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pyk/highcharts.rb', line 56 def self.line(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil) LazyHighCharts::HighChart.new('graph') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"line", height: height} ) data.each do |d| f.series(:name=>d[0],:data=> d[1], color: d[2]) end f.xAxis({categories: categories, title: { enabled: false }, :labels=>{:align => 'center'}, type: :string}) f.yAxis({title: nil, plotLines: [{value: 0, width: 1, color: '#F7F7F7'}]}) f.title({ :text=> nil}) f.legend({ :enabled=> show_in_legend}) end end |
.pie(data, series_name, render_to_name, background_color, show_in_legend = false, data_labels = false) ⇒ Object
Pyk::Highcharts.pie(data, series_name, render_to_name, background_color)
4 5 6 7 8 9 10 11 12 |
# File 'lib/pyk/highcharts.rb', line 4 def self.pie(data, series_name, render_to_name, background_color, show_in_legend=false, data_labels=false) LazyHighCharts::HighChart.new('pie') do |f| f.chart({:defaultSeriesType=>"pie" , :margin=> [0, 0, 0, 0], backgroundColor: background_color, renderTo: render_to_name}) f.series({:type=> 'pie', :name=> series_name, :data=> data, borderWidth: 0}) f.[:title][:text] = nil f.legend(:layout=> 'vertical',:style=> {:left=> '0', :bottom=> '0',:right=> '0',:top=> '0'}) f.(series: {pointPadding: 0,groupPadding: 0}, :pie=>{:allowPointSelect=>true, :cursor=>"pointer" , showInLegend: show_in_legend, :dataLabels=>{:enabled=>data_labels}}) end end |
.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color, show_in_legend = false, data_labels = false, height = nil) ⇒ Object
Pyk::Highcharts.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color)
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/pyk/highcharts.rb', line 110 def self.(data, categories, pie_data, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil) LazyHighCharts::HighChart.new('column') do |f| f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column", height: height} ) if pie_data.first.present? pie_data.each do |pie| f.series(:type=> 'pie',:name=> nil, :data=> [{:name=> pie[0], :y=> pie[1], :color=> pie[2]}], :center=> [pie[3], 5], :size=> 20, :showInLegend=> false, enableMouseTracking: false) end end data.each do |d| f.series(:type=> 'column',:name=> d[0],:data=> d[1], borderWidth: 0, stack: d[2], color: d[3]) end f.xAxis({categories: categories, gridLineWidth: 0, :labels=>{:rotation=>0 , :align => 'right'}, type: :date}) f.legend({layout: "horizontal", :borderWidth => 0, enabled: show_in_legend}) f.yAxis({gridLineWidth: 0, title: nil, :min => 0}) f.title({ :text=> nil}) f.({:column=>{:stacking => "normal"}, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}) end end |