I am using Fusionchart Multi-series column 3d + line with dual y axis,
I put my data in an array like this
mttr.push({
:label => Date::MONTHNAMES[month],
:value => (monthly_failure[month] / total_circuit)
})
and the dataset field like this
:dataset => [
{
:seriesname => 'Downtime',
:color => 'AFD8F8',
:showvalues => '0',
:data => downtime
},
{
:seriesname => 'MTTR',
:color => 'F6BD0F',
:showvalues => '0',
:data => mttr
},
{
:seriesname => 'SLA',
:color => '8BBA00',
:showvalues => '0',
:parentyaxis => 'S',
:renderas => 'Line',
:data => sla
}
]
I have tried my code and there is no problem with the data, but the graph still blank. is it becacuse i am not using the "categories" field ?
For implementing multi series charts you need to have categories objects as they are used to specify x axis labels for multi series charts.
Also note that FusionCharts have dedicated Ruby on Rails wrapper.
You can check the documentation from here http://www.fusioncharts.com/dev/using-with-server-side-languages/ruby-on-rails/introduction.html
Related
I am using roo to parse out an excel sheet like this
worksheet.parse(
:partNo => "PM_PartNo",
:salePartNo => "PM_SalesPartNo",
:appSearchInclude => "PM_AppSearchInclude",
:desc => "PM_WebApp_Description",
:brand => "PM_Brand",
:appSegment => "PM_ApplicationSegment",
:group => "PM_ProductGroup",
:design => "PM_ProductDesign",
:material => "PM_Material",
:line => "PM_ProdLine",
:baseSeries => "PM_BaseSeries",
:colorCode => "PM_ColorCode",
:series => "PM_Series",
:weightType => "PM_oz_gram",
:appRim => "PM_ApplicationRim",
:coating => "PM_Coating",
:pcs => "PM_PCSconversion",
:clean => true
) do |hash|
However, Roo keeps giving me a number 200275577.0 for the PM_PartNo column. In the excel sheet, this column has all cells formatted as text. What is should return in the parse is "200275577" as text, not 200275577.0 as a number. Is there a way to ensure it adheres to the excel formatting?
This is an open issue with roo. There is a general workaround contributed by a user in the issue, or you can just convert the value yourself with .to_i.to_s.
I'm using the Lazy HighCharts gem in my rails application and I have an array set up for my categories on my xAxis. I want to show just the first and last array, having the first appear on the left hand side and the last appear on the far right. Is this possible?
dates = [10,11,12,13,14,15,16]
#graph = LazyHighCharts::HighChart.new('graph') do |f|
f.xAxis(:categories => dates)
f.series(:type => 'spline', :name => 'Average', :data => [1,2,3,4,5,6,7], :color => '#b20838', marker: {enabled: false})
f.legend({:align => 'right', :y => 10, :verticalAlign => 'top', :floating => "true", :borderWidth => 0})
end
So instead of showing all dates on x-axis :
I would like the first and last array to show.
Try to use :tickPositions => [0, lengthOfCategories-1] for xAxis.
If you can find out the first and last values of the labels and store them in variables before itself, then you can do some thing like this http://jsfiddle.net/E7GBd/ using
formatter: function(){}
Hope this will help you.
In order to ensure consistent experience i want to set header image and business on paypal's page, view items with their names and description and ask the customer to select shipping address.
I'm using active_paypal_adaptive_payment gem (https://github.com/jpablobr/active_paypal_adaptive_payment) and the option to set_payment_options:
response = ADAPTIVE_GATEWAY.setup_purchase(
:action_type => 'CREATE',
:receiver_list => recipients,
...
)
ADAPTIVE_GATEWAY.set_payment_options(
:display_options => {
:business_name => 'Big Business',
:header_image_url => 'url goes here'
},
:sender_options => {
:require_shipping_address_selection => true },
:receiver_options => [{
:description => _description,
:invoice_data => {
:item => [{
:name => _title,
:item_count => 1,
}],
:total_shipping => 10.0,
:total_tax => 10
},
:receiver => {
:email => email
}
}])
)
The issue is that it doesn't work - i do not see any business names or image, i see generic names on the left column (the one with the items and the flow doesn't ask for shipping address).
Could you please advise?
You can also do so by logging into PayPal, then going to My Selling Tools and update the Custom payment pages option to create a new page style with the color combination and logo of your choice (there are size restrictions for the logo images)
I have 34 elements, but I only need to know which are the top 5 ranked.
I am using a comparison "A versus B" type questionaire across all 34 elements.
Right now, it isn't dynamic, so I cannot change the questions based on the prior questions.
What is the minimum number of questions in the questionaire I can ask?
What is the sorting algorithm you would use?
Right now I am using manualation and using Excel, but want to know how to eventually do it in Ruby for a basic Rails app.
If you just have simple integers, floats or strings, you can sort an array easily:
a = [ 3,3,1,6,2,8 ]
a.sort # => [1,2,3,3,6,8]
But this sorts ascending.
To sort descending, you can do:
a.sort {|x,y| y <=> x } # => [8,6,3,3,2,1]
or
a.sort.reverse # => [8,6,3,3,2,1]
Then to get the first 5 elements, just use:
a.sort.reverse.take(5) # => [8,6,3,3,2]
If the elements you are sorting are actually structures, you can change the code inside a sort_by block to account for that easily, eg:
a = [{:score => 5, :name => "Bob"}, {:score => 51, :name => "Jane"}, \
{:score => 15, :name => "Joe"}, {:score => 23, :name => "John"}, \
{:score => 35, :name => "Sam"}, {:score => 1, :name => "Rob"}]
a.sort_by{|x| x[:score] }.reverse.take(5)
# => [{:score => 51, :name => "Jane"},{:score => 35, :name => "Sam"},...]
I have a list of shows in a database that need to be output in a certain JSON style in order to work with Polymaps.
Part of this includes the need to iterate over one section in order to create a list of points. I'm pretty certain that this needs to be achieved using :include in the render :json => #results bit of the code.
Here's the code as it stands:
def gigs
#gigs = Show.where(:displayname => "Vans Warped Tour 2011")
#giggage = [{
:type => "FeatureCollection",
:features => [
#gigs.each do |gig|
:type => "feature",
:geometry => {
:coordinates => [
gig['lng'],
gig['lat']
],
:type => "Point"
},
:properties => gig
end
]
}]
render :json => #giggage
end
There's an each loop inside a hash which I know you can't do, but that's the best way to illustrate what I'm going for, I'm going in circles on this.
I did try this which got me some of the way there, but only returned the one result because of the structure of the loop:
def gigs
#gigs = Show.where(:displayname => "Vans Warped Tour 2011")
#gigs.each do |gig|
#gigs_to_render = {
:type => "FeatureCollection",
:features => [
:type => "feature",
:geometry => {
:coordinates => [
gig['lng'],
gig['lat']
],
:type => "Point"
},
:properties => gig
]
}
end
render :json => #gigs_to_render
end
Thanks for your help! Anyone. Everyone!
The code as it stands should be very close to working. Just change each to map and surround the body of the block in curlies so it all gets returned as a hash for each gig.