diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-20 17:29:04 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:28 +0200 |
commit | 2524685b37a6c629f0318518642019a96bcba36a (patch) | |
tree | d3f32a49323a5afbf419b0ff6018b0f9e8db4997 /ishtar_common | |
parent | c14fd82ec677282c7a43ad30981a2c5676788921 (diff) | |
download | Ishtar-2524685b37a6c629f0318518642019a96bcba36a.tar.bz2 Ishtar-2524685b37a6c629f0318518642019a96bcba36a.zip |
JS: use patch version of jqplot - truncate label of plot category
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 23 | ||||
-rw-r--r-- | ishtar_common/templates/base.html | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index caff11986..40592f0db 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -51,6 +51,15 @@ function manage_async_link(event){ if (modal_open) $(modal_open).modal('show'); } +text_truncate = function(str, length) { + var ending = "..."; + if (str.length > length) { + return str.substring(0, length - ending.length) + ending; + } else { + return str; + } +}; + /* default function to prevent undefined */ function get_next_table_id(){} function get_previous_table_id(){} @@ -1502,8 +1511,10 @@ var _render_stats_table = function(stats_values, name){ current_row = new Array(); html += "<tr><td>" + stats_values[idx][0] + "</td>"; current_row.push(stats_values[idx][0]); - html += "<td>" + stats_values[idx][1] + "</td></tr>"; - current_row.push(stats_values[idx][1]); + var cvalue = stats_values[idx][1]; + if (cvalue == null) cvalue = 0; + html += "<td>" + cvalue + "</td></tr>"; + current_row.push(cvalue); rows.push(current_row); } } @@ -1573,11 +1584,11 @@ var render_stats = function(stats_values, name){ }; if (modality_2 && modality_2 != modality_1){ for (idx in stats_values){ - ticks.push(stats_values[idx][0]); + ticks.push(text_truncate(stats_values[idx][0], 40)); var serie_values = stats_values[idx][1]; var current_serie_values = new Array(); for (inner_idx in serie_values){ - var serie_value = serie_values[inner_idx][0]; + var serie_value = text_truncate(serie_values[inner_idx][0], 40); if (series.indexOf(serie_value) == -1){ series.push(serie_value); var fill_values = new Array(); @@ -1601,6 +1612,9 @@ var render_stats = function(stats_values, name){ } stats_xaxis['ticks'] = ticks; } else { + for (idx in stats_values){ + stats_values[idx][0] = text_truncate(stats_values[idx][0], 40); + } jqvalues = [stats_values]; series.push("Total"); if (stats_type != "pie"){ @@ -1654,6 +1668,7 @@ var render_stats = function(stats_values, name){ stats_options["cursor"] = { show: true, zoom: true, + constrainOutsideZoom: false, showTooltip: false } } diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index aec214238..c43f0a081 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -42,7 +42,7 @@ <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.barRenderer.min.js?ver={{VERSION}}"></script> <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.pieRenderer.min.js?ver={{VERSION}}"></script> <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.dateAxisRenderer.min.js?ver={{VERSION}}"></script> - <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.cursor.min.js?ver={{VERSION}}"></script> + <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.cursor.js?ver={{VERSION}}"></script> <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jquery-resizable.js?ver={{VERSION}}"></script> {{EXTRA_JS|safe}} <script type='text/javascript'> |