pyhtmlchart
Table Page
Home Tutorial History Help

Table

To make a Simple Table with pyhtmlchart. Follow the given code below:
import pyhtmlchart as chart
table = chart.table.Table(location='table', title='Table')
columns = ['Number1', 'Number2']
all_data = [[1, 200], [2, 500]]
table.add_data(data=all_data, columns=columns)
table.open()

The above code will open the following table in the browser:

Explanation:
The Table Class:
Parameters:

The table class is the class to make a table. It contains following parameters:
  1. location :- The location of the table to be saved.

  2. title :- The title of the table.

  3. table_border :- The border of the table in integer format.

  4. border_color :- The border color of the table.

  5. cell_padding :- The space between the cell contents and cell border.

  6. cell_spacing :- The space between the cell and the table border.

  7. cell_horizontal_text_align :- The horizontal text align of a cell.

  8. cell_vertical_text_align :- The vertical text align of a cell.

  9. column_bg_color :- The background colour of the columns.

  10. data_bg_color :- The background colour of the data.

  11. column_text_color :- The text colour of the columns.

  12. data_text_color :- The text colour of the data.

  13. print_log :- Set it to True if you want the table log to be printed out.

  14. font :- The font of the table.
Functions:
add_data(data, columns) :-
The function to add the data to the table. Check the above code to understand it.
enable_auto_update(time=5000) :-
The function to enable the auto update to the table. Give the time parameter an 'int' value in milliseconds.
disable_auto_update() :-
The function to disable auto update to the table.
update_data(data, append=False, wait=True) :-
The function to update the given data. Give the data parameter the nested list to be added. Set append to True if you want the data to append and set wait to True if you want the program to wait for the update time and then update the data.
open() :-
The function to automatically open the table in the browser.
print_settings() :-
The function to print the table settings.

Making a simple auto update table:

Following is a simple code that auto updates a table using random values:
import pyhtmlchart as chart
import random
table = chart.table.Table(location='table', title='Chart')
columns = ['Time', 'Number1', 'Number2']
all_data = [[1, 200, 300], [2, 500, 400]]
table.add_data(data=all_data, columns=columns)
table.enable_auto_update(time=5000)
table.open()

i = 3
while True:
    data = [i, random.randint(1, 1000), random.randint(1, 1000)]
    table.update_data(data=[data], append=True)
    i += 1


Multiple Charts:
To display multiple charts on one page go to Multiple Charts Tutorial.