From c93f3fafc7af747939be27803194fc3578e6f51f Mon Sep 17 00:00:00 2001 From: Tasio Mendez Date: Thu, 1 Feb 2018 13:46:51 +0100 Subject: [PATCH] Charts --- config_copy.yml | 25 +++++++++ templates/css/main.css | 73 +++++++++++++++++++++++++- templates/index.html | 94 ++++++++++++++++++++++----------- templates/js/socket.js | 68 ++++++++++++++++++++++-- templates/js/template.js | 27 ++++++++-- templates/js/visualization.js | 97 +++++++++++++++++++++++++++++++---- 6 files changed, 335 insertions(+), 49 deletions(-) create mode 100644 config_copy.yml diff --git a/config_copy.yml b/config_copy.yml new file mode 100644 index 0000000..f972a46 --- /dev/null +++ b/config_copy.yml @@ -0,0 +1,25 @@ +name: ControlModelM2_sim +max_time: 100 +num_trials: 2 +network_params: + generator: barabasi_albert_graph + n: 100 + m: 2 +network_agents: + - agent_type: ControlModelM2 + weight: 0.1 + state: + id: 1 + - agent_type: SpreadModelM2 + weight: 0.9 + state: + id: 0 +environment_params: + prob_neutral_making_denier: 0.035 + prob_infect: 0.075 + prob_cured_healing_infected: 0.035 + prob_cured_vaccinate_neutral: 0.035 + prob_vaccinated_healing_infected: 0.035 + prob_vaccinated_vaccinate_neutral: 0.035 + prob_generate_anti_rumor: 0.035 + standard_variance: 0.055 diff --git a/templates/css/main.css b/templates/css/main.css index f67a731..e329697 100644 --- a/templates/css/main.css +++ b/templates/css/main.css @@ -17,7 +17,16 @@ html, body { } .navbar { - box-shadow: 0px -2px 5px 3px rgba(0, 0, 0, .3); + box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, .2) +} + +.nav.navbar-right { + margin-right: 10px !important; +} + +.dropdown-menu > li > a:hover { + background-color: #d4d3d3; + cursor: pointer; } .node { @@ -49,6 +58,10 @@ svg#graph, #configuration { padding: 15px; border-left: none !important; overflow: auto; + display: flex; + flex-direction: column; + align-items: inherit; + justify-content: space-evenly; } button { @@ -86,8 +99,14 @@ button.pressed { background-color: white; } -.config-item { +hr { margin-top: 15px !important; + margin-bottom: 15px !important; + width: 100%; +} + +#update .config-item { + margin-top: 15px !important; } /** LOADER **/ @@ -203,6 +222,16 @@ button.pressed { padding: 5px 2px; } +#percentTable .no-data-table { + font-size: 10px; + justify-content: center; + align-items: center; + display: flex; + flex: 1; + height: 100%; + font-weight: 100; +} + hr { margin-top: 15px !important; margin-bottom: 15px !important; @@ -304,6 +333,19 @@ table#link-distance .max { padding: 15px !important; height: 100%; overflow-y: auto; + overflow-x: hidden; +} + +#wrapper-settings.none { + font-weight: bold; + display: flex; + flex: 1; + justify-content: center; + align-items: center; +} + +#wrapper-settings.none:before { + content: 'No configuration provided'; } #wrapper-settings .btn-group button:focus { @@ -329,3 +371,30 @@ table#link-distance .max { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); background-color: #ccc; } + +/** CHARTS **/ +#charts { + height: 100%; + padding-left: 0 !important; + padding-top: 15px !important; + padding-bottom: 15px !important; +} + +.chart { + height: 50%; +} + +.chart.no-data:before { + content: 'No data'; + position: absolute; + font-size: 10px; + padding-bottom: 35px; +} + +.chart.no-data { + font-weight: bold; + display: flex; + flex: 1; + justify-content: center; + align-items: center; +} diff --git a/templates/index.html b/templates/index.html index 20ddfeb..c81c55d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,6 +20,10 @@ + + + + @@ -41,6 +45,11 @@ play, slider; + var width_chart = (window.innerWidth - 30) / 2 - 15, + height_chart = (window.innerHeight - 230) / 2, + chart_nodes, + chart_attrs; + window.onload = function() { "use strict"; @@ -56,6 +65,7 @@ $('#update #file').change(function() { var file = $('#file')[0].files[0]; + $('.console').append('
'); self.GraphVisualization.reset(); $('#load').show(); @@ -83,11 +93,6 @@ }); - // Select 'trials' - $('.config-item #trials').change(function() { - _socket.send($(this).val(), 'get_trial'); - }); - // Select 'attributes' $('.config-item #properties').change(function() { self.GraphVisualization.update_graph($(this).val(), slider.value(), function() { @@ -95,8 +100,38 @@ }) }); - $('[data-toggle="tooltip"]').tooltip() - + chart_nodes = c3.generate({ + size: { + width: width_chart, + height: height_chart + }, + data: { + columns: [], + type: 'area-spline' + }, + axis: { + x: { label: 'Time' }, + y: { label: 'Number of nodes' } + }, + point: { show: false }, + bindto: '#chart_nodes' + }); + chart_attrs = c3.generate({ + size: { + width: width_chart, + height: height_chart + }, + data: { + columns: [], + type: 'area-spline' + }, + axis: { + x: { label: 'Time' }, + y: { label: 'Attributes' } + }, + point: { show: false }, + bindto: '#chart_attrs' + }); } ///]] @@ -113,7 +148,7 @@
Please, upload a YAML file that defines all the parameters of a simulation.
If you don't know how to write the file, please visit this page:
- http://soilsim.readthedocs.io/en/latest/quickstart.html

+ http://soilsim.readthedocs.io/en/latest/quickstart.html
@@ -127,13 +162,15 @@ - +
- Trials: - + +
- + @@ -141,19 +178,23 @@