...
Plotly is a popular graphing and charting library that Rich Data Services serializes to. However, unlike amCharts and Google Charts, Plotly charts will expect different formats based on the type of chart that is being used. Due to this users will have to be specific with how they want the data formatted.
Supported Formats
PLOTLY_AREA | Area Graph |
---|---|
PLOTLY_BAR | Bar Chart |
PLOTLY_BOXPLOT | Box Plot |
PLOTLY_BUBBLE | Bubble Chart |
PLOTLY_HIST | Histogram |
PLOTLY_H_BAR | Horizontal Bar Chart |
PLOTLY_H_HIST | Horizontal Histogram |
PLOTLY_LINE | Line Chart |
PLOTLY_PIE | Pie Chart |
PLOTLY_SCATTER | Scatter Plot |
PLOTLY_TS | Time Series |
Step By Step
- In this example we will create a dataProvider object that can be used with amCharts. We will assume that we have a collection named "test" and a view named "view" with a variable named "var" that has the values 1, 2, and 3. In this example we will run a tabulation that will count the frequencies of each of these values that could be used to create a chart.
Running the tabulation would normally look something like this:
Code Block title Tabulation http://{host}/rds/test/view/tabulate?dims=var
Code Block title Tabulation Output { "records": [ [ 1, 182 ], [ 2, 354 ], [ 3, 126 ] ], "info": { "colCount": 2, "format": "MTNA", "includeMetadata": false, "limit": 20, "offset": 0, "moreRows": false } }
We can look at some of the formatting changes by running several of the different formats.
Code Block title Pie Chart http://localhost:8080 {host}/rds/catalog/test/NES1948/tabulate?dims=V480003&format=plotly_pie
Code Block title Pie Output [ { "values": [ 182, 354, 126 ], "labels": [ "1", "2", "3" ], "type": "pie" } ]
Code Block title Bar Chart http://localhost:8080 {host}/rds/catalog/test/NES1948/tabulate?dims=V480003&format=plotly_bar
Code Block title Bar Output [ { "x": [ 1, 2, 3 ], "y": [ 182, 354, 126 ], "type": "bar" } ]
In addition to formatting the values in a Plotly compliant way, we can also substitute the numeric values for the categories they represent if the variable has a classification associated with it. In this example we will assume that var has the following classification:
1 METROPOLITAN AREA 2 TOWN OR CITY 3 OPEN COUNTRY Code Block title Pie Chart http://localhost:8080 {host}/rds/catalog/test/NES1948/tabulate?dims=V480003&format=plotly_pie
Code Block title Pie Output [ { "values": [ 182, 354, 126 ], "labels": [ "METROPOLITAN AREA", "TOWN OR CITY", "OPEN COUNTRY" ], "type": "pie" } ]
Code Block title Bar Chart http://localhost:8080 {host}/rds/catalog/test/NES1948/tabulate?dims=V480003&format=plotly_bar
Code Block title Bar Output [ { "x": [ "METROPOLITAN AREA", "TOWN OR CITY", "OPEN COUNTRY" ], "y": [ 182, 354, 126 ], "type": "bar" } ]