This module is the main JqPyCharts code module
JqPyCharts is simple to use.
There are many ways to do this.
Python-Example
html_template = '''
<!DOCTYPE html>
<html>
<head>
{js_css_resources_header}
{jqplotchart_script1}
</head>
<body>
<br>
{html_chart_insert_tag1}
<br>
</body>
</html>
'''
Python-Example
js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_pie_chart(
absolute_source_dir_path=path_abspath('scripts'),
script_src_tag_dir_path='scripts',
chart_id='id_1',
chart_title='JqPyCharts Simple Pie Chart',
chart_data_matrix=[
('Fat', 200, '#EAA228', 'Fat: 200 g'),
('Protein', 21, '#4bb2c5', 'Protein: 21 g'),
('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g')
],
highlighter_prefix='Grams',
background='#fffdf6',
legend_font_px=15,
data_label_threshold=9.0,
width_px=550,
height_px=300,
margin_top_px=0,
margin_bottom_px=0,
margin_right_px=0,
margin_left_px=0
)
example_final_html_code = html_template.format(
js_css_resources_header=js_css_resources_header1,
jqplotchart_script1=jqplotchart_script1,
html_chart_insert_tag1=html_chart_insert_tag1,
)
with open('usage_example__simple_pie_chart.html', 'w') as file_:
file_.write(example_final_html_code)
This will look like:
There are many ways to do this.
Python-Example
html_template = '''
<!DOCTYPE html>
<html>
<head>
{js_css_resources_header}
{jqplotchart_script1}
</head>
<body>
<br>
{html_chart_insert_tag1}
<br>
</body>
</html>
'''
Python-Example
horizontal set to False
js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart(
absolute_source_dir_path=path_abspath('scripts'),
script_src_tag_dir_path='scripts',
chart_id='id_1',
class_str='',
chart_title='JqPyCharts Simple Bar Chart: 1 (with defined legends)',
chart_x_label='',
chart_x_label_fontdict=None,
chart_ticks_fontdict=None,
chart_data_matrix=[
('Fat', 200, '#EAA228', '200 g (57.7 %)'),
('Protein', 21, '#4bb2c5', '21 g (21.3 %)'),
('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')
],
highlighter_prefix='Grams',
background='#fffdf6',
horizontal=False,
draw_grid_lines=False,
width_px=550,
height_px=300,
margin_top_px=0,
margin_bottom_px=0,
margin_right_px=0,
margin_left_px=0
)
example_final_html_code = html_template.format(
js_css_resources_header=js_css_resources_header1,
jqplotchart_script1=jqplotchart_script1,
html_chart_insert_tag1=html_chart_insert_tag1,
)
with open('example__simple_bar_chart.html', 'w') as file_:
file_.write(example_final_html_code)
This will look like:
Python-Example
horizontal set to True
js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart(
absolute_source_dir_path=path_abspath('scripts'),
script_src_tag_dir_path='scripts',
chart_id='id_1',
class_str='',
chart_title='JqPyCharts Simple Bar Chart: 1 (with defined legends)',
chart_x_label='',
chart_x_label_fontdict=None,
chart_ticks_fontdict=None,
chart_data_matrix=[
('Fat', 200, '#EAA228', '200 g'),
('Protein', 21, '#4bb2c5', '21 g'),
('Carbohydrate', 10, '#c5b47f', '10 g')
],
highlighter_prefix='Grams',
background='#fffdf6',
horizontal=True,
draw_grid_lines=False,
width_px=650,
height_px=300,
margin_top_px=0,
margin_bottom_px=0,
margin_right_px=0,
margin_left_px=0
)
example_final_html_code = html_template.format(
js_css_resources_header=js_css_resources_header1,
jqplotchart_script1=jqplotchart_script1,
html_chart_insert_tag1=html_chart_insert_tag1,
)
with open('usage_example__simple_bar_horizontal_chart.html', 'w') as file_:
file_.write(example_final_html_code)
This will look like:
Returns the defined: resource_dict
Parameters: | resource_dict_name – (str) name of resource_dict |
---|---|
Returns: | (dict) dictionary with b85encode files |
Raises Err: |
Helper: writes a complete resource dict to path absolute_source_dir_path: decodes it to separate files If ‘absolute_source_dir_path does not exist it will be created (inclusive intermediate folders)
Parameters: |
|
---|---|
Raises Err: |
Helper: writes selected resources to path absolute_source_dir_path: decodes it to separate files If ‘absolute_source_dir_path does not exist it will be created (inclusive intermediate folders)
Parameters: |
|
---|---|
Raises Err: |
Returns a html string with the javascript / css resources
Parameters: |
|
---|---|
Returns: | (str) html string Javascripts: <script type="text/javascript" src="script_src_tag_dir_path/jquery.min.js"></script>
css: <link rel="stylesheet" type="text/css" href="script_src_tag_dir_path/jquery.jqplot.min.css">
|
Raises Err: |
Returns a html string with the html tag for the chart
Parameters: |
|
---|---|
Returns: | (str) html string <div id="id_1" class='my-pie-charts' style="width:550px; height:300px; margin-top:20px; margin-bottom:0px; margin-right:20px; margin-left:0px;"></div>
|
Returns a html string with the html tag for the chart
Parameters: |
|
---|---|
Returns: | (str) html chart script string |
Raises Err: |
Returns all (js_css_resources_header, jqplotchart_script, html_chart_insert_tag) for a simple pie chart
uses default indent
Parameters: |
|
---|---|
Returns: | (tuple) js_css_resources_header, jqplotchart_script, html_chart_insert_tag |
Raises Err: |
Returns all (js_css_resources_header, jqplotchart_script, html_chart_insert_tag) for a simple pie chart
uses default indent
Parameters: |
|
---|---|
Returns: | (tuple) js_css_resources_header, jqplotchart_script, html_chart_insert_tag |
Raises Err: |