How to represent complex and hybrid data

2019-07-01 12:40发布

I have a quite complicated question.

I'm looking for a javascript or PHP script that can take about any data (arrays, mysql queries ...) and make a table / pivot table / chart of it.

to be simple, I want an app that is able to take any data and represent it as we ask.

For example take content rated by a user.

I want to be able to make a graph of the number of person that rated 1,2,3,4 or 5. I want to make a table with the number of users that rated in july and in august. I want to get the contents that were the most rated. I want to get the users that voted the most.

I know I could could code each of these graphs, but I want to make something that any user can use. and make his own representations.

Is there something like that out there ?

If not in php / javascript, maybe in another language on another platform ?

Thanks in advance

3条回答
\"骚年 ilove
2楼-- · 2019-07-01 13:24

I don't think it is possible to automatically interpret any data format without explicitly defining how that format should be interpreted. What if you pass in a CSV format? how will your application know the meaning of CSV data? how could it know that columns are separated by commas? How could it know what a column means? What if you pass in JSON? How will it know how to interpret that data? How will it know to treat it differently from the CSV data? You will need to explicitly define ways of interpreting the formats that you are interested in. You can use existing parsers for this.

You could store the interpreted data in a relational structure once you have interpreted it. This would allow you to query a single type of data source to get data from multiple different formats. For example, if you wanted to represent any data in a tabular form, you could define a relational structure such as:

Table
-----
id (PK)
name


Column
-------
id (PK)
table (FK to Table's id)
title


Row
---
id (PK)
table (FK to Table's id)


DataPoint
---------
id (PK)
row (FK to Row's id)
column (FK to Column’s id)
value

With this structure, you could represent any table of data. It's arguably a rather awful design though. But for your goals, it may fulfil your requirements. Here's an article on possible objections to this kind of design. If you can implement something along these lines in 6NF, it could be awesome.

You could extend this to cope with pivot tables and charts.

I don't know of anything that exists that does this for you.

查看更多
【Aperson】
3楼-- · 2019-07-01 13:37

You can look into using ExtJS combined with their design tool. If you can provide your data as a JSON object, you should be able to craft an application fairly easily that would allow the user to manipulate the data as he or she sees fit.

See the ExtJS chart demos.

查看更多
你好瞎i
4楼-- · 2019-07-01 13:40

I don't know of anything out of the box, but at least some of your work has been done for you:

For example, you could build a simple PHP function that would dump the given input as an HTML table. Then, with that HTML table, deploy a couple of jQuery plugins to sort the table (DataTables) and to create graphs from tabular data (graphTable).

Obviously, the more robust you want your system to be, the more upfront effort it will take.

查看更多
登录 后发表回答