Reputation: 523
Looking for some advice in displaying reports with Google charts (for now table reports, but will go on to other types later)
Are people creating a view for each specific report? Or is it better to re-use an existing view and dynamically create the table from it.
I've found some resources where the table columns are dynamically generated, but I am not quite sure how to check and specify the column to be a string or numeric data type.
If I create views for each report, I know ahead of time what the table structure will be and thus making it easier to create, but perhaps more of a nightmare to maintain down the road.
Any thoughts?
Upvotes: 0
Views: 205
Reputation: 7128
Depending on how often the columns/tables change, one of these will work for you.
If your data doesn't change too often, just create 10 different DataView
s based on the 10 tables you want to create. Since they all use the same underlying data, any change to the original DataTable will automatically be reflected in all 10 tables, and the performance will be much quicker than creating 10 different tables.
If you change the views often, maintenance may be a hassle, so I would suggest a different approach.
You can create a function that will take an array of columns and create a DataView from those columns. This way you can change the views easily by changing the function call only, and will make your code look simpler. Depending on how you want to set the DataView (whether you use filtered rows and/or columns) the function will be slightly different, but this will allow you the most flexibility to change things while giving all the benefits of having 10 dataviews (updating based on changes to the datatable, etc.).
If you're going to go that far, you can just automate the entire process. Select the rows/columns you want from the DataTable, give a <div>
name (or create a <div>
automatically), then create the view and the new table chart drawing function. This will work great if your tables all behave the same (have the same events, options, etc.) as it is going to be of use far in to the future.
On the other side, it is more work than the above two to initially create.
Upvotes: 1