To make a Simple Multiple Chart with
pyhtmlchart. Follow the given code below:
import pyhtmlchart as chart
line_chart = chart.line_chart.LineChart(location='line', title='Chart')
columns = ['Time', 'Number1', 'Number2']
all_data = [[1, 200, 300], [2, 500, 400]]
line_chart.add_data(data=all_data, data_titles=columns)
column_chart = chart.column_chart.ColumnChart(location='column', title='Chart')
columns = ['Time', 'Number1', 'Number2']
all_data = [[1, 200, 300], [2, 500, 400]]
column_chart.add_data(data=all_data, data_titles=columns)
area_chart = chart.area_chart.AreaChart(location='area', title='Chart')
columns = ['Time', 'Number1', 'Number2']
all_data = [[1, 200, 300], [2, 300, 500], [3, 100, 200]]
area_chart.add_data(data=all_data, data_titles=columns)
bar_chart = chart.bar_chart.BarChart(location='bar', title='Chart')
columns = ['Time', 'Number1', 'Number2']
all_data = [[1, 200, 300], [2, 500, 400]]
bar_chart.add_data(data=all_data, data_titles=columns)
pie_chart = chart.pie_chart.PieChart(location='pie', title='Chart')
columns = ['Time', 'Number1']
all_data = [['1', 200], ['2', 500]]
pie_chart.add_data(data=all_data, data_titles=columns)
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)
multiple_chart = chart.multiple_charts.MultipleCharts(location='chart', title='All Types')
multiple_chart.add_chart(['line.html', 'column.html', 'area.html', 'bar.html', 'pie.html', 'table.html'])
multiple_chart.open()
The above code will open many charts on one page!
The MultipleCharts Class:
Parameters:
The multiple chart class is the class to make a multiple chart. It contains following parameters:
- location :- The location of the chart to be saved.
- title :- The title of the chart.
- height :- The height of each chart.
- width :- The width of each chart.
- frame_border :- The frame border of the chart..
- border :- The border of each chart.
- border_color :- The border color of each chart.
Functions:
add_chart(chart_locations, frame_value=[], frame_size=[]) :-
The function to add a svaed chart to the multiple chart. Make sure that the charts to be added are given in a list with the extension .html. Refer the above Code. If you want to change the size of one chart in a page then give the chart's list index according to the 'chart_locations' list and use the frame_size parameter to set a different size for that specified chart. If you pass the 'frame_size' parameter, then give the size of that chart in a 2-d list. First is height and then width.
open() :-
The function to automatically open the chart in the browser.
print_chart_settings() :-
The function to print the chart settings.