date,New York,San Francisco,Austin20111001,63.4,62.7,72.220111002,58.0,59.9,67.720111003,53.3,59.1,69.420111004,70.0,80.0,90.0
What did you mean with functions ? Are these client side parser-functions for csv data ?
But google charts can at the moment not parse csv data directly on the client side ?
On Server-Side is use Spring MVC.. On my Website someone can upload a csv as a MultiPart Upload to my server or directly to my website.on the Server-Side there is a Rest-Service that gets the Multipart csv file:@RequestMapping(value="/upload", method=RequestMethod.POST)@ResponseStatus(value=HttpStatus.NO_CONTENT)public @ResponseBody String handleFileUpload(@RequestParam(value="name", required=false) String name,@RequestParam(value="file1") MultipartFile file){//Reads the CSV FileInputStream inputStream = file.getInputStream();BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));}Is it now possible that i can convert the PartFile with the csv to a DataTable ?
On the Client Side i have the same csv part file.. i can read it with a FileReader();
@Controller
@RequestMapping("REST")
public class LoadDataSource {
@Autowired
private HttpServletRequest request;
@RequestMapping(value="/DataSource/{Id}",method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody DataTable createDataSource( @PathVariable Integer Id){
DataTable data = generateMyDataTable2();
return data;
}
private DataTable generateMyDataTable2() {
// Create a data table,
DataTable data = new DataTable();
ArrayList<ColumnDescription> cd = new ArrayList<ColumnDescription>();
cd.add(new ColumnDescription("id1", ValueType.NUMBER, "Date"));
cd.add(new ColumnDescription("id2", ValueType.NUMBER, "Berlin"));
cd.add(new ColumnDescription("id3", ValueType.NUMBER, "Offenburg"));
cd.add(new ColumnDescription("id4", ValueType.NUMBER, "Zunsweier"));
data.addColumns(cd);
// Fill the data table.
try {
data.addRowFromValues(2010, 10, 12, 22);
data.addRowFromValues(2011, 20, 34, 33);
data.addRowFromValues(2012, 30, 23, 45);
data.addRowFromValues(2013, 40, 25, 50);
} catch (TypeMismatchException e) {
System.out.println("Invalid type!");
}
return data;
}
{"rows":[{"cells":[{"value":{"value":2010.0,"type":"NUMBER","null":false,"objectToFormat":2010.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":10.0,"type":"NUMBER","null":false,"objectToFormat":10.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":12.0,"type":"NUMBER","null":false,"objectToFormat":12.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":22.0,"type":"NUMBER","null":false,"objectToFormat":22.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false}],"customProperties":{}},{"cells":[{"value":{"value":2011.0,"type":"NUMBER","null":false,"objectToFormat":2011.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":20.0,"type":"NUMBER","null":false,"objectToFormat":20.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":34.0,"type":"NUMBER","null":false,"objectToFormat":34.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":33.0,"type":"NUMBER","null":false,"objectToFormat":33.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false}],"customProperties":{}},{"cells":[{"value":{"value":2012.0,"type":"NUMBER","null":false,"objectToFormat":2012.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":30.0,"type":"NUMBER","null":false,"objectToFormat":30.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":23.0,"type":"NUMBER","null":false,"objectToFormat":23.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":45.0,"type":"NUMBER","null":false,"objectToFormat":45.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false}],"customProperties":{}},{"cells":[{"value":{"value":2013.0,"type":"NUMBER","null":false,"objectToFormat":2013.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":40.0,"type":"NUMBER","null":false,"objectToFormat":40.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":25.0,"type":"NUMBER","null":false,"objectToFormat":25.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false},{"value":{"value":50.0,"type":"NUMBER","null":false,"objectToFormat":50.0},"formattedValue":null,"customProperties":{},"type":"NUMBER","null":false}],"customProperties":{}}],"customProperties":{},"warnings":[],"localeForUserMessages":null,"columnDescriptions":[{"id":"id1","type":"NUMBER","label":"Date","pattern":"","customProperties":{}},{"id":"id2","type":"NUMBER","label":"Berlin","pattern":"","customProperties":{}},{"id":"id3","type":"NUMBER","label":"Offenburg","pattern":"","customProperties":{}},{"id":"id4","type":"NUMBER","label":"Zunsweier","pattern":"","customProperties":{}}],"numberOfColumns":4,"numberOfRows":4}
date,New York,San Francisco,Austin20111001,63.4,62.7,72.220111002,58.0,59.9,67.720111003,53.3,59.1,69.420111004,70.0,80.0,90.0
data = new google.visualization.arrayToDataTable([
['date','New York','Austin','San Francisco','Country','Popularity'],
[new Date("8/6/1975"),2,3,15,'Germany',200],
[new Date("8/6/1980"),5,6,19,'Brazil',400],
[new Date("8/6/2000"),8,9,23,'United States',300],
[new Date("8/6/2010"),11,12,35,'RU',700]
]);
New York63 $58.3 $53.59 $70.2 $
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Director (Year)', {label: "Rotten", type: "number", pattern: "#.## $"}, 'IMDB'],
['Alfred Hitchcock (1935)', 8.4 $, 7.9],
['Ralph Thomas (1959)', 6.9 $, 6.5],
['Don Sharp (1978)', 6.5 $, 6.4],
['James Hawes (2008)', 4.4 $, 6.2]
]);
var options = {
width: 600, height: 400,
title: 'The decline of \'The 39 Steps\'',
vAxis: {title: 'Accumulated Rating'},
isStacked: true
};
var chart = new google.visualization.SteppedAreaChart(document.getElementById('visualization'));
chart.draw(data, options);
}