Hi i am using Fusion charts free with Rail 2.3.5
I tried to simulate the single_array example provided in the documentation but instead of graph it is showing me the following message
The method used is setDataXML.The XML is
#Creates xml with values for sales data of products #along with their names.
#The values required for building the xml is obtained as parameter arr_data
#It expects an array in which each element is
#itself an array with first element as label and second element as value
xml = Builder::XmlMarkup.new xml.graph(:caption=>'Sales by Product', :numberPrefix=>'$', :formatNumberScale=>'0',:decimalPrecision=>'0') do
for item in arr_data xml.set(:name=>item[0], :value=>item[1],:color=>''+get_FC_color)
end
end
Anybody seen this message before >? i am using Firefox with flash player > 9
"The method used is setDataXML.The XML is" is a log message from FusionCharts RoR.
After this, it should print the xml.
Looks like your xml is incorrect. Please remove the comments from the builder file and see if it works.
Please see a sample application posted at FusionCharts in RoR 2.3.5
Related
I am building a site with Ruby on Rails where I can display items that are for sale. Currently I can add new items by filling a form with title, price, some text and upload a couple of pictures.
Since there might be many items I would like to have a text file with the data, one item on each line, data separated with comma or whatever. Then I'd like to give this file to my Rail's application that will create the items in the application. Would this be possible?
What you're basically talking about is importing and exporting CSV files.
You can learn about the basic ruby functions available to you when working with CSV files here: http://ruby-doc.org/stdlib-2.3.0/libdoc/csv/rdoc/CSV.html
Here's a video about exporting to csv and here's a video about importing from csv.
You essentially will call :to_csv on some collection, and then use CSV's foreach or some method of iterating the items in the CSV, and you will create your rows from the parsed data.
I have a datetime value which comes from the API in this format: 2015-07-07T17:30:00+00:00. I simply want to split it up between the date and time values at this point. I am not using an Active Record model and I prefer not to use an sql database if I can.
The way I have set up the app means that the value is "stored" like this in my view: #search.dining_date_and_time
I have tried two approaches to solving this problem:
Manually based on this previous stackoverflow question from 2012: Using multiple input fields for one attribute - but the error I get is the attribute is "nil" even though I put a "try"
Using this gem, https://github.com/ccallebs/split_date_time which is a bit more recent and seems to be a more elegant solution, but after closely following the doc, I get this error, saying my Search model is not initalized and there is no method: undefined method dining_date' for #<Search not initialized>
This is when instead I put #search.dining_date in the view, which seems to be the equivalent of the doc's example (its not that clear). The doc also says the method will be automatically generated.
Do I need to alter my model so I receive the data from the API in another way? ie. not get the variable back as #search.dining_date_and_time from the Search model for any of this to work?
Do I need an Active Record model so that before_filter or before_save logic works - so i can (re)concatenate after splitting so the data is sent back to the API in a format it understands. Can I avoid this - it seems a bit of overkill to restructure the whole app and put in a full database just so I can split and join date/time as needed.
Happy to provide further details, code snippets if required.
As I am not using a conventional Rails DB like MySql Lite or Postgresql, I found that the best solution to the problem was by using this jQuery date Format plugin: https://github.com/phstc/jquery-dateFormat to split the date and time values for display when I get the data back from the API.
The Github docs were not too expansive, but once I put the simply put the library file in my Rails javascript assets folder, I just had to write a few lines of jQuery to get the result and format I wanted:
$(function() {
var rawDateTime = $('#searchDiningDateTime').html();
// console.log(rawDateTime);
var cleanDate = $.format.date(rawDateTime, "ddd, dd/MM/yyyy");
// console.log(cleanDate);
$('#searchDiningDateTime').html(cleanDate);
var cleanTime = $.format.date(rawDateTime, "HH:mm");
// console.log(cleanTime);
$('#searchTime').html(cleanTime);
});
Next challenge: rejoin the values on submit, so the API can read the data by sending/receiving a valid request/response. (The values can't be split like this when sent to the remote service).
Hello SO Ruby/Rails/Google community!
I'm looking for the correct way of making changes to the body of a Google Doc stored in Google Drive using Drive API Ruby Client.
Let's say I've required 'google/api_client', have an authorized client and drive instance, and have a starting template written in HTML.
I have no trouble creating fresh templates and multipart-uploading them to drive using
#drive.files.insert
to join file metadata:
#file = #drive.files.insert.request_schema.new({
'title' => "#{Time.now.strftime('%m_%d_%Y_')}EOD",
'description' => "The End of Day Log for #{Time.now.strftime('%m_%d_%Y')}",
'mimeType' => 'text/html',
'parents' => [{'id' => folder_id}]
})
and the html template represented by:
#media = Google::APIClient::UploadIO.new('eod_template.html', 'text/html')
Having successfully uploaded the base template to Drive and capturing its file_id, I would like users to be able to append text entries to the base template using a form on my Rails site.
Given the existence of a micropost model and form, I suspect I'll be writing a method that get called on save that appends the submitted text to the Google Doc Template but I can't find how to do this in any of the Drive API documentation.
I'm looking for functionality identical to the apps-script appendText(text) method found at
https://developers.google.com/apps-script/reference/document/text
Anyone have any clever solutions? Documentation I should read? The Perfect Gem?
Thanks a mil for your time!
-B
I gather from the deafening silence that such a thing is not (easily) possible.
Bummer!
Not to be deterred, I implemented the following workaround - hope it works for you, future readers.
Instead of writing posts to a document dynamically, I let a day's worth of posts pool in my app until the end of day, at which point I write all posts to the Google Doc at once with Nokogiri. It's not great, but with some front-end trickery whereby I simulate the feel of a Google Doc, it's good enough.
I am trying to extract data from a website (http://oregonpinotnoirwine.com/) using Mechanize.
I am able to go to the website and select search field. But I am not able to get the data. I am doing this on Ruby IRB.
require 'mechanize'
agent = Mechanize.new
agent.get("http://oregonpinotnoirwine.com/search.php")
form = agent.page.forms[0]
form["wineava"] = "Dundee Hills"
form.submit
Then I am trying to extract all the list of wines that are on the website. So in order to do that, I looked up CSS of the website and decided to use .a like
agent.page.search(".a")
But that didn't return anything. But when I type
agent.page.search(".")
It returns all the data from the website. Now I'm just trying different variations.. when I type
agent.page.search("#wineava")
It returns with the dropdown option from the site but not the wine list..
So I was over-thinking with this.
All the data I needed was on the dropdown menu. So after accessing the website through
agent.get("http://oregonpinotnoirwine.com/search.php")
I was able to get the data I need by
agent.page.search("#winemaker")
But this method will not work if the items were not displayed in the dropdown menu.. Would it?
I'm creating a new "web engine" (i.e. gallery format) for Lightroom, which uses Lua templates to generate HTML for the gallery pages.
I've got both the SDK and Programmers Guide from here: http://www.adobe.com/devnet/photoshoplightroom/
But none of the SDK docs, examples, nor the Programmers Guide give me any hint of what variables I need to use to add, for example, "image 1 of 50" to the page heading.
There are a couple of objects, $model and $image which I suspect will have this information in - is there a way to dump the full data contained within these as text/html, so I can output to the HTML page and figure out what variable I want?
Update: half way there... found the variable $index which provides the current image number, so now I just need to figure out what/where the total count variable is.
On page 133 of the guide pdf it lists the variable "numImages". Is that what you need?