Skip to content

Commit

Permalink
csv export in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
pirbo committed Jan 6, 2017
1 parent a47a434 commit 8a355cf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 27 deletions.
12 changes: 12 additions & 0 deletions api/api_data.ml
Expand Up @@ -130,3 +130,15 @@ let api_simulation_status
in
{ Api_types_j.simulation_info_progress = progress ;
Api_types_j.simulation_info_output = output ; }

let plot_values
?(separator : string = ",")
(plot : Api_types_j.plot) : string =
Format.asprintf "@[<v>%a@]"
(Pp.list Pp.space Format.pp_print_string)
((String.concat separator plot.Api_types_j.plot_legend)::
List.rev_map
(Format.asprintf "@[<h>%a@]"
(Pp.list (fun f -> Format.pp_print_string f separator)
(Pp.option ~with_space:false (fun f -> Format.fprintf f "%e"))))
plot.Api_types_j.plot_time_series)
16 changes: 1 addition & 15 deletions api/api_data_v1.ml
Expand Up @@ -21,20 +21,6 @@ let plot_pg_store
plot.Api_types_v1_j.time_series
}

let plot_values
?(separator : string = ",")
(plot : Api_types_v1_j.plot) : string =
Format.asprintf "@[<v>%a@]"
(Pp.list Pp.space Format.pp_print_string)
((String.concat
separator
("time"::plot.Api_types_v1_j.legend))::
List.rev_map
(Format.asprintf "@[<h>%a@]"
(Pp.list (fun f -> Format.pp_print_string f separator)
(Pp.option ~with_space:false (fun f -> Format.fprintf f "%e"))))
plot.Api_types_v1_j.time_series)

let api_file_line (file_line : Data.file_line) : Api_types_v1_j.file_line =
{ Api_types_v1_j.file_name = file_line.Data.file_line_name
; Api_types_v1_j.line = file_line.Data.file_line_text
Expand Down Expand Up @@ -384,7 +370,7 @@ let api_files (f : Api_types_j.file_line) : Api_types_v1_j.file_line =
{ Api_types_v1_j.file_name = f.Api_types_j.file_line_name ;
Api_types_v1_j.line = f.Api_types_j.file_line_text ; }

let api_plot (p) =
let api_plot p =
{ Api_types_v1_j.legend = p.Api_types_j.plot_legend ;
Api_types_v1_j.time_series = p.Api_types_j.plot_time_series;
}
Expand Down
7 changes: 2 additions & 5 deletions api/kappa_facade.ml
Expand Up @@ -434,11 +434,8 @@ let start

let () =
t.plot <-
{ Api_types_j.plot_legend =
Array.to_list legend;
Api_types_j.plot_time_series =
[ Some (Counter.current_time t.counter)
:: first_values ]} in
{ Api_types_j.plot_legend = Array.to_list legend;
Api_types_j.plot_time_series = [ first_values ]} in
run_simulation ~system_process:system_process ~t:t stop
)
)
Expand Down
2 changes: 1 addition & 1 deletion ide/Info.plist.skel
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleGetInfoString</key>
<string>See http://www.kappalanguage.org/</string>
<key>NSHumanReadableCopyright</key>
<string>2010-2016 CNRS - Harvard Medical School - INRIA - IRIF</string>
<string>2010-2017 CNRS - Harvard Medical School - INRIA - IRIF</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
Expand Down
6 changes: 3 additions & 3 deletions js/js_plot.ml
Expand Up @@ -6,7 +6,7 @@
(* |_|\_\ * GNU Lesser General Public License Version 3 *)
(******************************************************************************)

module ApiTypes = Api_types_v1_j
module ApiTypes = Api_types_j

class type plot_configuration =
object
Expand Down Expand Up @@ -105,10 +105,10 @@ let create_data ~(plot : ApiTypes.plot)
configuration##.legend := Js.array
(Tools.array_map_of_list
Js.string
plot.ApiTypes.legend);
(List.tl plot.ApiTypes.plot_legend));
configuration##.timeSeries := Js.array
(Tools.array_map_of_list (fun o -> create_observable ~observable:o)
plot.ApiTypes.time_series);
plot.ApiTypes.plot_time_series);
()
in configuration

Expand Down
3 changes: 1 addition & 2 deletions js/tab_plot.ml
Expand Up @@ -149,8 +149,7 @@ let update_plot
~ok:(fun _ (data : Api_types_t.plot) ->
let () = serialize_json := (fun _ -> Api_types_j.string_of_plot data) in
let () = plot##setDimensions(get_dimension ()) in
let data : Api_types_v1_j.plot = Api_data_v1.api_plot data in
let () = serialize_csv := fun _ ->Api_data_v1.plot_values data in
let () = serialize_csv := fun _ -> Api_data.plot_values data in
let data : Js_plot.plot_data Js.t = Js_plot.create_data ~plot:data in
let () = plot##setPlot(data) in
Lwt.return_unit
Expand Down
2 changes: 1 addition & 1 deletion shared/plot.js
Expand Up @@ -638,7 +638,7 @@ function observable_plot(configuration){
var rawData = that.getRawData();
var timeSeries = rawData.timeSeries;
var legend = rawData.legend;
var header = "'time'\t"+legend.join("\t");
var header = legend.join("\t");
var body = timeSeries.map(function(d)
{ var row = [d["time"]];
row = row.concat(d["values"]);
Expand Down

0 comments on commit 8a355cf

Please sign in to comment.