Skip to content

Commit f284638

Browse files
Merge pull request #511 from plotly/release-3-0-0
Release 3.0.0
2 parents 7139241 + 0b83047 commit f284638

14 files changed

+41
-704
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</a>
99
</div>
1010

11-
Version: 2.2.10
11+
Version: 3.0.0
1212

1313
*MATLAB is a registered trademarks of The MathWorks, Inc.*
1414

plotly/plotly_aux/makecall.m

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
function st = makecall(args, origin, structargs)
1+
function st = makecall(args, origin, kwargs)
22
% check if signed in and grab username, key, domain
33
[un, key, domain] = signin;
4+
45
if isempty(un) || isempty(key)
56
error('Plotly:CredentialsNotFound',...
67
['It looks like you haven''t set up your plotly '...
@@ -13,21 +14,16 @@
1314

1415
platform = 'MATLAB';
1516

16-
args = m2json(args);
17-
kwargs = m2json(structargs);
1817
url = [domain '/clientresp'];
19-
payload = {'platform', platform, 'version', plotly_version, ...
20-
'args', args, 'un', un, 'key', key, 'origin', origin, ...
21-
'kwargs', kwargs};
22-
23-
if (is_octave)
24-
% use octave super_powers
25-
resp = urlread(url, 'post', payload);
26-
else
27-
% do it matlab way
28-
resp = urlread(url, 'Post', payload);
29-
end
18+
payload = struct( ...
19+
platform=platform, ...
20+
version=plotly_version, ...
21+
args=args, ...
22+
un=un, ...
23+
key=key, ...
24+
origin=origin, ...
25+
kwargs=kwargs ...
26+
);
3027

31-
st = jsondecode(resp);
32-
response_handler(resp);
28+
st = webwrite(url, payload);
3329
end

plotly/plotly_aux/plotly_version.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function version = plotly_version()
2-
version = '2.2.10';
2+
version = "3.0.0";
33
end

plotly/plotly_aux/plotlygenimage.m

+12-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function plotlygenimage(figure_or_data, filename, varargin)
2-
[pathstr, name, ext] = fileparts(filename);
2+
[~, ~, ext] = fileparts(filename);
33
if nargin < 3
44
format = ext(2:length(ext));
55
else
@@ -23,46 +23,23 @@ function plotlygenimage(figure_or_data, filename, varargin)
2323
figure = struct('data', data);
2424
end
2525

26-
body = struct('figure', figure, 'format', format);
27-
28-
payload = m2json(body);
26+
payload = struct(figure=figure, format=format);
2927

3028
[un, key, domain] = signin;
3129

3230
url = [domain, '/apigenimage/'];
3331

34-
headers = struct(...
35-
'name',...
36-
{...
37-
'plotly-username',...
38-
'plotly-apikey',...
39-
'plotly-version',...
40-
'plotly-platform',...
41-
'user-agent'
42-
},...
43-
'value',...
44-
{...
45-
un,...
46-
key,...
47-
plotly_version,...
48-
'MATLAB',...
49-
'MATLAB'
50-
});
51-
% return the response as bytes -
52-
% convert the bytes to unicode chars if the response fails or isn't
53-
% (pdf, png, or jpeg) ... gnarly!
54-
[response_string, extras] = urlread2(url, 'Post', payload, headers, ...
55-
'CAST_OUTPUT', false);
56-
if ( extras.status.value ~= 200 || ...
57-
~(strcmp(extras.allHeaders.Content_Type, 'image/jpeg') || ...
58-
strcmp(extras.allHeaders.Content_Type, 'image/png') || ...
59-
strcmp(extras.allHeaders.Content_Type, 'application/pdf')))
60-
response_string = native2unicode(response_string);
61-
end
32+
headerFields = [ ...
33+
"plotly-username", string(un); ...
34+
"plotly-apikey", string(key); ...
35+
"plotly-version", plotly_version; ...
36+
"plotly-platform", "MATLAB"; ...
37+
"user-agent", "MATLAB" ...
38+
];
39+
40+
response_object = webwrite(url, payload, weboptions("HeaderFields", headerFields));
41+
image_data = response_object;
6242

63-
response_handler(response_string, extras);
64-
image_data = response_string;
65-
6643
fileID = fopen(filename, 'w');
6744
fwrite(fileID, image_data);
6845
fclose(fileID);

plotly/plotly_aux/plotlygetfile.m

+8-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
function figure = plotlygetfile(file_owner, file_id)
22
[un, key, domain] = signin;
33

4-
headers = struct(...
5-
'name',...
6-
{...
7-
'plotly-username',...
8-
'plotly-apikey',...
9-
'plotly-version',...
10-
'plotly-platform',...
11-
'user-agent'
12-
},...
13-
'value',...
14-
{...
15-
un,...
16-
key,...
17-
plotly_version,...
18-
'MATLAB',...
19-
'MATLAB'
20-
});
21-
4+
headerFields = [ ...
5+
"plotly-username", string(un); ...
6+
"plotly-apikey", string(key); ...
7+
"plotly-version", plotly_version; ...
8+
"plotly-platform", "MATLAB"; ...
9+
"user-agent", "MATLAB" ...
10+
];
2211
url = [domain, '/apigetfile/', file_owner, '/', num2str(file_id)];
2312

24-
[response_string, extras] = urlread2(url, 'Get', '', headers);
25-
response_handler(response_string, extras);
26-
response_object = jsondecode(response_string);
13+
response_object = webread(url, weboptions("HeaderFields", headerFields));
2714
figure = response_object.payload.figure;
2815
end

plotly/plotly_aux/response_handler.m

-41
This file was deleted.

plotly/plotly_aux/urlread2/http_createHeader.m

-11
This file was deleted.

plotly/plotly_aux/urlread2/http_paramsToString.m

-62
This file was deleted.

plotly/plotly_aux/urlread2/license.txt

-24
This file was deleted.

0 commit comments

Comments
 (0)