US Consumption of Plant Nutrients
Created: 2011-09-21 07:09:00
Last updated: 2011-09-21 07:08:58
This workflow takes data from the ERS, TVA (Tennessee Valley Authority), AAPFCO (Association of American Plant Food Control Officials), and the TFI (The Fertilizer Institute) and represents them in a bar chart.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
US Consumption of Plant Nutrients |
Descriptions (1)
This workflow takes data from the ERS, TVA (Tennessee Valley Authority), AAPFCO (Association of American Plant Food Control Officials), and the TFI (The Fertilizer Institute) and represents them in a bar chart.
|
Dependencies (0)
Processors (5)
Name |
Type |
Description |
SpreadsheetImport |
spreadsheet |
Imports the supplied Excel file. |
GenerateGraphURL |
beanshell |
Generates a URL (Google Charts format). ScriptStringBuilder sb = new StringBuilder();
sb.append("http://chart.apis.google.com/chart?");
sb.append("cht=bvg");
sb.append("&chs=1000x300");
sb.append("&ch=");
sb.append("&chxt=x,y,y");
sb.append("&chbh=5,1,5");
sb.append("&chxr=0,");
sb.append(Float.parseFloat(years.get(0)).intValue());
sb.append(",");
sb.append(Float.parseFloat(years.get(years.size() - 1)).intValue());
sb.append(",500|4000,0,11000");
sb.append("&chds=0,20");
sb.append("&chxl=2:|1000%20nutrient%2ftons");
sb.append("&chxp=2,50");
sb.append("&chco=FF0000,00FF00,0000FF");
sb.append("&chdl=");
for (int i = 0; i < headers.size(); i++) {
sb.append(headers.get(i).replace(" ", "%20"));
if (i+1 < data.size()) {
sb.append("|");
}
}
if (title != void) {
sb.append("&chtt=");
sb.append(type);
}
if (data != void) {
sb.append("&chd=t:");
for (int i = 0; i < data.size(); i++) {
List data1 = (List) data.get(i);
for (int j = 0; j < data1.size(); j++) {
Float value = Float.parseFloat(data1.get(j));
sb.append(value.intValue());
if (j+1 < data1.size()) {
sb.append(",");
}
}
if (i+1 < data.size()) {
sb.append("|");
}
}
}
graphURL = sb.toString(); |
Get_Image_From_URL |
localworker |
Retrieves chart output from Google in an image format to be displated in Taverna. ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
} else {
inputURL = new URL(url);
}
byte[] contents;
if (inputURL.openConnection().getContentLength() == -1) {
// Content size unknown, must read first...
byte[] buffer = new byte[1024];
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
totalBytesRead += bytesRead;
bytesRead = is.read(buffer, 0, 1024);
}
contents = new byte[totalBytesRead];
} else {
contents = new byte[inputURL.openConnection().getContentLength()];
}
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
bytesRead = is.read(contents, totalBytesRead, contents.length - totalBytesRead);
totalBytesRead += bytesRead;
if (contents.length==totalBytesRead) break;
}
image = contents;
|
Beanshell |
beanshell |
This Beanshell script takes the values from SpreadsheetImport and prepares them to be passed to the Google Chart URL creator in the next step. Scriptdata = new ArrayList();
headers = new ArrayList();
headers.add(phosphate.remove(0));
headers.add(nitrogen.remove(0));
headers.add(potash.remove(0));
data.add(phosphate);
data.add(nitrogen);
data.add(potash);
year.remove(0);
years = year; |
url_value |
stringconstant |
URL file supplied for the user is an Excel file, or .xls. Valuehttp://www.myexperiment.org/files/568/download/FertilizerUse.xls |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
GenerateGraphURL |
Generates a URL (Google Charts format). |
title
data
headers
years
|
graphURL
|
Beanshell |
This Beanshell script takes the values from SpreadsheetImport and prepares them to be passed to the Google Chart URL creator in the next step. |
year
phosphate
nitrogen
potash
|
data
headers
years
|
Datalinks (10)
Source |
Sink |
url_value:value |
SpreadsheetImport:fileurl |
Beanshell:data |
GenerateGraphURL:data |
Beanshell:headers |
GenerateGraphURL:headers |
Beanshell:years |
GenerateGraphURL:years |
GenerateGraphURL:graphURL |
Get_Image_From_URL:url |
SpreadsheetImport:year |
Beanshell:year |
SpreadsheetImport:phosphate |
Beanshell:phosphate |
SpreadsheetImport:nitrogen |
Beanshell:nitrogen |
SpreadsheetImport:potash |
Beanshell:potash |
Get_Image_From_URL:image |
graph |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (1)
(People/Groups)
Attributions (2)
(Workflows/Files)
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment