2 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 * Main entry point for the rendering of the Viewer component.
10 * @param {Event} evt File select event.
12 function handleFileSelectEvent(evt
) {
13 var file
= evt
.target
.files
[0];
14 var fileReader
= new FileReader();
16 fileReader
.onload
= (function(theFile
) {
18 var dataSet
= createViewerDataset(e
.target
.result
);
19 var viewer
= new Viewer({ownerDocument
:window
.document
});
20 viewer
.id
= 'csvContentsDataTable';
21 viewer
.dataSet
= dataSet
;
22 viewer
.barChartElementId
= 'barChart';
26 fileReader
.readAsText(file
);
30 * Splits the csv file contents, and creates a square array of strings for
31 * each token in the line.
33 * @return {String[][]} The data set with the contents of the csv file.
35 function createViewerDataset(fileContents
) {
36 var rows
= fileContents
.split('\n');
38 rows
.forEach(function (row
, index
, array
) {
39 if (row
.trim().length
== 0) {
44 var columns
= row
.split(',');
45 columns
.forEach(function (element
, index
, array
) {