def test_jqpc_simple_bar_chart_ok2(): """ Tests: test_jqpc_simple_bar_chart_ok2 """ print('::: TEST: test_jqpc_simple_bar_chart_ok2()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_chart_ok2') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='whatever', chart_title='JqPyCharts simple_bar_chart', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', 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) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) resource_dir_path__relpath = path_relpath(resource_dir_path__abspath) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_chart_ok2', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_bar_horizontal_chart_ok2(): """ Tests: test_jqpc_simple_bar_horizontal_chart_ok2 """ print('::: TEST: test_jqpc_simple_bar_horizontal_chart_ok2()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_horizontal_chart_ok2') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='whatever', chart_title='JqPyCharts simple_bar_chart', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=True, 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) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) resource_dir_path__relpath = path_relpath(resource_dir_path__abspath) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_horizontal_chart_ok2', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def main(): html_template = ''' <!DOCTYPE html> <html> <head> {js_css_resources_header} {jqplotchart_script1} </head> <body> <br> {html_chart_insert_tag1} <br> </body> </html> ''' 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)
def test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure(): """ Tests: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure: """ print( '::: TEST: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure()' ) scripts_bar_chart_path = 'scripts_pie_chart_test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure' if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={ 'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000' }, chart_x_label_fontdict=None, chart_ticks_fontdict={ 'fontFamily': 'Courier New', 'fontSize': 12, 'textColor': '#000000' }, 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='Gram', 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) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure(): """ Tests: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure: """ print('::: TEST: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure()') scripts_bar_chart_path = 'scripts_pie_chart_test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure' if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000'}, chart_x_label_fontdict=None, chart_ticks_fontdict={'fontFamily': 'Courier New', 'fontSize': 12, 'textColor': '#000000'}, 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='Gram', 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) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def main(): # common var source_dir_path = path_abspath('scripts') script_src_tag_dir_path = 'scripts' background = '#fffdf6' horizontal = False width_px = 550 height_px = 300 margin_top_px = 0 margin_bottom_px = 0 margin_right_px = 0 margin_left_px = 0 js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, 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='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header2, jqplotchart_script2, html_chart_insert_tag2 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_2', class_str='', chart_title='JqPyCharts Simple Bar Chart: 2 (with no defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '')], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header3, jqplotchart_script3, html_chart_insert_tag3 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_3', class_str='', chart_title='JqPyCharts Simple Bar Chart: 3 (with grid_lines)', 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='Gram', background=background, horizontal=horizontal, draw_grid_lines=True, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header4, jqplotchart_script4, html_chart_insert_tag4 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_4', class_str='', chart_title='JqPyCharts Simple Bar Chart: 4 (with x_label)', chart_x_label='Grams', 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='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header5, jqplotchart_script5, html_chart_insert_tag5 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_5', class_str='', chart_title='JqPyCharts Simple Bar Chart: 5 (with x_label_fontdict)', chart_x_label='Grams', chart_x_label_fontdict={ 'fontFamily': 'Impact', 'fontSize': 20, 'textColor': '#557700' }, 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='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header6, jqplotchart_script6, html_chart_insert_tag6 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_6', class_str='', chart_title='JqPyCharts Simple Bar Chart: 6 (with ticks_fontdict)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict={ 'fontFamily': 'Impact', 'fontSize': 12, 'textColor': '#557700' }, 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='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, jqplotchart_script2=jqplotchart_script2, jqplotchart_script3=jqplotchart_script3, jqplotchart_script4=jqplotchart_script4, jqplotchart_script5=jqplotchart_script5, jqplotchart_script6=jqplotchart_script6, html_chart_insert_tag1=html_chart_insert_tag1, html_chart_insert_tag2=html_chart_insert_tag2, html_chart_insert_tag3=html_chart_insert_tag3, html_chart_insert_tag4=html_chart_insert_tag4, html_chart_insert_tag5=html_chart_insert_tag5, html_chart_insert_tag6=html_chart_insert_tag6, ) with open('example__simple_bar_chart.html', 'w') as file_: file_.write(example_final_html_code)
def main(): # common var source_dir_path = path_abspath('scripts') script_src_tag_dir_path = 'scripts' background = '#fffdf6' horizontal = True width_px = 700 height_px = 300 margin_top_px = 0 margin_bottom_px = 0 margin_right_px = 0 margin_left_px = 0 js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, 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', '57.7 %'), ('Protein', 21, '#4bb2c5', '21.3 %'), ('Carbohydrate', 10, '#c5b47f', '24.0 %') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header2, jqplotchart_script2, html_chart_insert_tag2 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_2', class_str='', chart_title='JqPyCharts Simple Bar Chart: 2 (with no defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header3, jqplotchart_script3, html_chart_insert_tag3 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_3', class_str='', chart_title='JqPyCharts Simple Bar Chart: 3 (with grid_lines)', 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='Gram', background=background, horizontal=horizontal, draw_grid_lines=True, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header4, jqplotchart_script4, html_chart_insert_tag4 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_4', class_str='', chart_title='JqPyCharts Simple Bar Chart: 4 (with x_label)', chart_x_label='Grams', 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='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header5, jqplotchart_script5, html_chart_insert_tag5 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_5', class_str='', chart_title='JqPyCharts Simple Bar Chart: 5 (with x_label_fontdict)', chart_x_label='Grams', chart_x_label_fontdict={'fontFamily': 'Impact', 'fontSize': 20, 'textColor': '#557700'}, 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='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header6, jqplotchart_script6, html_chart_insert_tag6 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_6', class_str='', chart_title='JqPyCharts Simple Bar Chart: 6 (with ticks_fontdict)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict={'fontFamily': 'Impact', 'fontSize': 12, 'textColor': '#557700'}, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, jqplotchart_script2=jqplotchart_script2, jqplotchart_script3=jqplotchart_script3, jqplotchart_script4=jqplotchart_script4, jqplotchart_script5=jqplotchart_script5, jqplotchart_script6=jqplotchart_script6, html_chart_insert_tag1=html_chart_insert_tag1, html_chart_insert_tag2=html_chart_insert_tag2, html_chart_insert_tag3=html_chart_insert_tag3, html_chart_insert_tag4=html_chart_insert_tag4, html_chart_insert_tag5=html_chart_insert_tag5, html_chart_insert_tag6=html_chart_insert_tag6, ) with open('example__simple_bar_horizontal_chart.html', 'w') as file_: file_.write(example_final_html_code)