|
3 | 3 | % the current working directory. The file will be saved as:
|
4 | 4 | % 'plotlyfig.PlotOptions.FileName'.html.
|
5 | 5 |
|
6 |
| - % grab the bundled dependencies |
7 |
| - userhome = getuserdir(); |
8 |
| - plotly_config_folder = fullfile(userhome,'.plotly'); |
9 |
| - plotly_js_folder = fullfile(plotly_config_folder, 'plotlyjs'); |
10 |
| - bundle_name = 'plotly-matlab-offline-bundle.js'; |
11 |
| - bundle_file = fullfile(plotly_js_folder, bundle_name); |
12 |
| - |
13 |
| - % check that the bundle exists |
14 |
| - try |
15 |
| - bundle = fileread(bundle_file); |
16 |
| - catch |
17 |
| - error(['Error reading: %s.\nPlease download the required ', ... |
18 |
| - 'dependencies using: >>getplotlyoffline \n', ... |
19 |
| - 'or contact support@plot.ly for assistance.'], ... |
20 |
| - bundle_file); |
| 6 | + % create dependency string unless not required |
| 7 | + if plotlyfig.PlotOptions.IncludePlotlyjs |
| 8 | + % grab the bundled dependencies |
| 9 | + userhome = getuserdir(); |
| 10 | + plotly_config_folder = fullfile(userhome,'.plotly'); |
| 11 | + plotly_js_folder = fullfile(plotly_config_folder, 'plotlyjs'); |
| 12 | + bundle_name = 'plotly-matlab-offline-bundle.js'; |
| 13 | + bundle_file = fullfile(plotly_js_folder, bundle_name); |
| 14 | + |
| 15 | + % check that the bundle exists |
| 16 | + try |
| 17 | + bundle = fileread(bundle_file); |
| 18 | + % template dependencies |
| 19 | + dep_script = sprintf('<script type="text/javascript">%s</script>\n', ... |
| 20 | + bundle); |
| 21 | + catch |
| 22 | + error(['Error reading: %s.\nPlease download the required ', ... |
| 23 | + 'dependencies using: >>getplotlyoffline \n', ... |
| 24 | + 'or contact support@plot.ly for assistance.'], ... |
| 25 | + bundle_file); |
| 26 | + end |
| 27 | + else |
| 28 | + dep_script = ''; |
21 | 29 | end
|
22 | 30 |
|
23 | 31 | % handle plot div specs
|
|
35 | 43 | jdata = m2json(plotlyfig.data);
|
36 | 44 | jlayout = m2json(plotlyfig.layout);
|
37 | 45 | clean_jdata = escapechars(jdata);
|
38 |
| - clean_jlayout = escapechars(jlayout); |
39 |
| - |
40 |
| - % template dependencies |
41 |
| - dep_script = sprintf('<script type="text/javascript">%s</script>', ... |
42 |
| - bundle); |
| 46 | + clean_jlayout = escapechars(jlayout); |
43 | 47 |
|
44 | 48 | % template environment vars
|
45 | 49 | plotly_domain = plotlyfig.UserData.PlotlyDomain;
|
46 |
| - env_script = sprintf(['\n<script type="text/javascript">', ... |
| 50 | + env_script = sprintf(['<script type="text/javascript">', ... |
47 | 51 | 'window.PLOTLYENV=window.PLOTLYENV || {};', ...
|
48 | 52 | 'window.PLOTLYENV.BASE_URL="%s";', ...
|
49 | 53 | 'Plotly.LINKTEXT="%s";', ...
|
|
0 commit comments