(fig, chart_format, plot_name, mk_dir, additional='')
| 58 | |
| 59 | ######## This is where we store the image data in a dictionary with a list of images ######### |
| 60 | def save_image_data(fig, chart_format, plot_name, mk_dir, additional=''): |
| 61 | if not os.path.isdir(mk_dir): |
| 62 | os.mkdir(mk_dir) |
| 63 | if additional == '': |
| 64 | filename = os.path.join(mk_dir, plot_name + "." + chart_format) |
| 65 | else: |
| 66 | filename = os.path.join(mk_dir, plot_name + additional + "." + chart_format) |
| 67 | ################################################################################## |
| 68 | if chart_format == 'svg': |
| 69 | ###### You have to add these lines to each function that creates charts currently ## |
| 70 | imgdata = io.StringIO() |
| 71 | fig.savefig(filename, dpi='figure', format=chart_format) |
| 72 | imgdata.seek(0) |
| 73 | svg_data = imgdata.getvalue() |
| 74 | return svg_data |
| 75 | else: |
| 76 | ### You have to do it slightly differently for PNG and JPEG formats |
| 77 | imgdata = BytesIO() |
| 78 | fig.savefig(filename, format=chart_format, dpi='figure') |
| 79 | # fig.savefig(imgdata, format=chart_format, bbox_inches='tight', pad_inches=0.0) |
| 80 | imgdata.seek(0) |
| 81 | figdata_png = base64.b64encode(imgdata.getvalue()) |
| 82 | return figdata_png |
| 83 | |
| 84 | |
| 85 | #### This module analyzes a dependent Variable and finds out whether it is a |
no outgoing calls
no test coverage detected