Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2592219

Browse files
committed
Update reportspec.md
1 parent 3b33e89 commit 2592219

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

specs/reportspec.md

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
After importing plotly, a Report object is created behind-the-scenes.
66
There is only one report object per Python session.
7-
Grids and plots returned from plot.ly are automatically appended to the report object during the Python session,
7+
Plots returned from plot.ly are automatically appended to the report object during the Python session,
88
so that when you create a report:
99

1010
```python
1111
import plotly
1212
rp = plotly.report
1313
```
1414

15-
It is pre-loaded with a list of plots, grids, and widget boxes that you've created during your session. Something like
15+
It is pre-loaded with a list of plots and widget boxes that you've created during your session. Something like
1616

1717
```python
1818
rp.save()
@@ -23,56 +23,65 @@ Would then compile and save the report to a local html file.
2323
#### Item class
2424

2525
Reports would be structured as a list of Item objects.
26-
Text, Plot, or Grid objects would subclass from an Item class.
26+
Text, Plot, or Table objects would subclass from an Item class.
2727

2828
Item objects would have these methods and attributes:
2929

30-
* inline -- True or False. Defaults to false. >=2 sequential Items in report with inline=True will display inline.
30+
* inline -- True or False. Defaults to false. 2 sequential Items in report with inline=True will display inline. Start with max. allowance of 2 inline items.
31+
** Uses bootstraps 1-12 grid layout for fluid horizontal layout. Defaults to 3 for Table and vertical WidgetBox objects and 9 for plots. Coud add a "layout" attribute in the future for further control of this.
3132
* to_html() -- Returns the Item's representation as an html string, including container div.
32-
* serialize() -- Returns the Item's representation as a dict.
33+
* to_json() -- Returns the Item's representation as a dict.
3334

3435
#### Text class
3536

36-
Methods / attributes:
37+
###### Methods / attributes:
3738

3839
* markdown -- True or False. Defaults to False. Used by to_html() to convert content to html.
3940
* content -- plain text, html, or markdown string of content.
4041
* type (optional) -- for the html or markdown noob, adds css class to parent div for styling and parent html tags on to_html().
4142
* possible types: caption, latex, paragraph, title, subtitle.
4243

43-
Usage examples:
44+
###### Usage examples:
4445

4546
```python
4647
t1 = Text( 'Hello, world', type='title' ) # plain text with type
4748
t2 = Text( '# Hello, world', markdown=True ) # markdown
4849
t3 = Text( '<table>...</table>' ) # html
4950
```
5051

51-
#### Grid class
52+
#### Table class
5253

53-
Methods / attributes:
54+
###### Methods / attributes:
5455

5556
* max_rows -- maximum number of rows to display
57+
* max_cols -- maximum number of columns to display
5658

57-
Usage examples:
59+
###### Usage examples:
5860

5961
```python
60-
g1 = Grid( 234 ) # fid of user's grid
61-
g2 = Grid( 'https://plot.ly/~jackp/1724', inline=True ) URL of user's grid
62-
g3 = Grid( ('msunds',34), inline=True ) tuple for another user's grid, placed next to g2
62+
tb1 = Table( pd, title="Q1 earnings" ) # pandas dataframe, optional title kwarg (=HTML caption)
63+
tb2 = Table( '1,2,3\n4,5,6\n7,8,9' ) # csv string
64+
tb3 = Table( [ [1,2,3], [4,5,6], [7,8,9] ] ) # list of lists
65+
tb4 = Table( fig ) # plotly figure object
66+
tb5 = Table( data ) # plotly data object
67+
68+
# vvv When Plotly grid's support GET requests, could read grids into Table objects
69+
tb1 = Table( 234 ) # fid of user's grid
70+
tb2 = Table( 'https://plot.ly/~jackp/1724', inline=True ) URL of user's grid
71+
tb3 = Table( ('msunds',34), inline=True ) tuple for another user's grid, placed next to g2
6372
```
6473

6574
#### Plot class
6675

67-
Methods / attributes:
76+
###### Methods / attributes:
6877

69-
* None?
78+
* format = 'pdf' | 'png' | 'interactive'
7079

71-
Usage examples:
80+
###### Usage examples:
7281

7382
```python
7483
p1 = Plot( 234 ) # fid of user's plot
75-
p2 = Plot( 'https://plot.ly/~jackp/1724', inline=True ) URL of user's plot
84+
p2 = Plot( 'https://plot.ly/~jackp/1724', inline=True, format='pdf' ) URL of user's plot
7685
p3 = Plot( ('msunds',34), inline=True ) tuple for another user's plot, placed next to p2
7786
```
7887

@@ -81,37 +90,36 @@ p3 = Plot( ('msunds',34), inline=True ) tuple for another user's plot, placed ne
8190
In order to save reports, some serialization structure will be needed. Here's a suggestion:
8291

8392
```python
84-
{
85-
name: 'my report',
86-
items: [
87-
{ class: 'text', content: '## Subsection', markdown=True },
88-
{ class: 'grid', inline: True, fid: 123, username: 'alex' },
89-
{ class: 'plot', inline: True, fid: 234, username: 'alex' },
90-
{ class: 'text', content: 'Hello, hello', type='caption' },
91-
]
92-
}
93+
[
94+
{ class: 'text', content: 'Title', type='caption' },
95+
{ class: 'text', content: '## Subsection', markdown=True },
96+
{ class: 'table', position: 'inline', content: '[[1,2,3],[4,5,6],[7,8,9]]' },
97+
{ class: 'plot', position: 'inline', fid: 234, username: 'alex' },
98+
{ class: 'text', content: 'Hello, hello', type='caption' },
99+
{ class: 'table', fid: 123, username: 'alex' }, # table uses fid and username if grid
100+
]
93101
```
94102

95103
## Report class methods
96104

97105
#### Subclass from Python list
98106
Subclass from lists so user can get all the list behavior they would expect from a list-like object? pop(), splicing, copying...
99107

100-
#### rp.print()
101-
Prints the current report structure.
108+
#### rp.prettyprint()
109+
Idea: print the current report structure in a way that's understandable at-a-glance.
102110
What's the most helpful way to give the user a quick view of their report structure and item order?
103111
Points to consider:
104112
* How do we show items share the same vertical level (ie a grid (html table) and plot side-by-side)
105113
* Do we limit text to ~50 chars with ellipses?
106114
* Show indices for help with splicing out items?
107115

108116
```python
109-
[0] Text: '# Report Title' (BLOCK1)
110-
[1] Plot: https://plot.ly/~jackp/1 (BLOCK2)
111-
[2] Grid: https://plot.ly/~jackp/2 (BLOCK2)
112-
[3] Text: 'Lorem ipsum dolor sit amet, cons...' (BLOCK3)
117+
[0] Text: '# Report Title' (ROW1)
118+
[1] Plot: https://plot.ly/~jackp/1 (ROW2)
119+
[2] Grid: https://plot.ly/~jackp/2 (ROW2)
120+
[3] Text: 'Lorem ipsum dolor sit amet, cons...' (ROW3)
113121
```
114-
Where BLOCK-N specifies vertical placement.
122+
Where ROW-N specifies vertical placement.
115123

116124
#### rp.append()
117125

0 commit comments

Comments
 (0)