Skip to content
Snippets Groups Projects
Commit c6eb2903 authored by Jan Mach's avatar Jan Mach
Browse files

Reject: Rejected current time scatter chart implementation.

The current implementation is flawed and is holding back the release of the next version. I am rejecting the code and will revisit the idea sometime in the future. (Redmine issue: #4321)
parent cb433f16
No related branches found
No related tags found
No related merge requests found
......@@ -158,54 +158,6 @@ function render_chart_timeline_multi(chid, chart_data, params) {
});
}
// Render multi-timescatter chart.
function render_chart_timescatter_multi(chid, chart_data, params) {
console.log('Rendering chart: ' + chid);
nv.addGraph(function() {
var chart = nv.models.scatterChart()
.color(d3.scale.category20().range())
;
//Axis settings
chart.xDomain([0,23]);
chart.xAxis.ticks(24).tickFormat(d3.format('02,d'));
chart.yAxis.ticks(7).tickFormat(function(d) {
return {
'0': 'Monday',
'1': 'Tuesday',
'2': 'Wednesday',
'3': 'Thursday',
'4': 'Friday',
'5': 'Saturday',
'6': 'Sunday'
}[''+d];
});
//var contentGeneratorOrig = chart.tooltip.contentGenerator();
//chart.tooltip.contentGenerator(function (d) {
// console.log(d);
// return contentGeneratorOrig(d);
//});
//tooltip.headerFormatter(function (d) { return tsFormat(new Date(d)); });
//We want to show shapes other than circles.
//chart.scatter.onlyCircles(false);
// Select the appropriate SVG element and bind datum to the chart.
d3.select("#" + chid + " svg")
.datum(chart_data)
.transition().duration(350)
.call(chart);
nv.utils.windowResize(chart.update);
register_visualisation(chid, chart);
return chart;
});
}
function get_dataset_timeline_list(raw_data, data_serie_list) {
return raw_data.timeline.map(function(data) {
result = {_date: data[0]};
......@@ -216,18 +168,6 @@ function get_dataset_timeline_list(raw_data, data_serie_list) {
});
}
function get_dataset_timescatter_list(raw_data, data_serie_list) {
return raw_data.timescatter.map(function(data_days) {
return data_days.map(function(data_hours) {
result = {};
data_serie_list.forEach(function(data_serie) {
result[data_serie.ident] = data_serie.ident in data_hours ? data_hours[data_serie.ident] || 0 : 0;
});
return result;
});
});
}
function get_dataset_timeline_dict(raw_data, data_serie_list, dict_key) {
return raw_data.timeline.map(function(data) {
result = {_date: data[0]};
......
......@@ -163,33 +163,6 @@
});
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given timescatter
chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_chart_timescatter(chart_id, cfg_params) %}
// Render the timescatter chart '{{ chart_id }}'.
$(document).ready(function () {
render_chart_timescatter_multi(
'{{ chart_id }}_chart',
dsts_to_chart(
{{ chart_id }}_dataset,
{{ chart_id }}_series,
),
{
'xlabel': '{{ _("Date") }}',
'ylabel': '{{ _("Count [#]") }}'
}
);
});
{%- endmacro %}
{#-
Render JavaScript code responsible for subsequent rendering of given pie
......@@ -346,48 +319,6 @@
});
{%- endmacro %}
{#-
Render JavaScript code responsible handling JavaScript events related to given
timescatter chart.
string chart_id: Unique identifier of the chart. This will be used for
generating all other required unique identifiers.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro _snippet_ecbks_timescatter(chart_id, cfg_params) %}
// Enable necessary event callbacks to appropriate DOM elements.
$(document).ready(function () {
// Event handler for downloading chart as SVG.
$("#{{ chart_id }}_export_svg").click(function () {
chart = $("#{{ chart_id }}_chart svg").get(0);
serializer = new XMLSerializer();
data = serializer.serializeToString(chart);
blob = new Blob([data], {type: "image/svg+xml"}),
url = window.URL.createObjectURL(blob);
this.href = url;
this.target = '_blank';
// target filename
this.download = 'export_{{ chart_id }}.svg';
});
// Event handler for downloading chart dataset as JSON.
$("#{{ chart_id }}_export_json").click(function () {
data = JSON.stringify({{ chart_id }}_dataset);
blob = new Blob([data], {type: "application/json"}),
url = window.URL.createObjectURL(blob);
this.href = url;
this.target = '_blank';
// target filename
this.download = 'export_{{ chart_id }}.json';
});
});
{%- endmacro %}
{#-
Render JavaScript code responsible handling JavaScript events related to given
......@@ -501,51 +432,6 @@
{%- endmacro %}
{#-
Calculate dataset from given list of requested keys and render it as TIMESCATTER
chart with appropriate toggable data table.
dict full_data: Full statistical data as dictionary structure.
string data_var_name: Name of the JavaScript variable containing a dump of
full_data within the HTML page.
string id_prefix: Chart identifier prefix. Will be used as name prefix for
generating identifiers for all required HTML and JS elements.
string list_keys: List of requested subkeys from which the target dataset will
be constructed.
dict cfg_params: Additional chart configuration and customization parameters.
-#}
{%- macro render_chart_timescatter(full_data, data_var_name, id_prefix, list_keys, cfg_params = {}) %}
{%- set chart_id = 'chart_timescatter_' + id_prefix %}
<!------------------------------------------------------------------
Dataset visualisation '{{ chart_id }}'
------------------------------------------------------------------->
{{ _snippet_columns_toggable(chart_id) }}
<script>
// Define dataset series.
var {{ chart_id }}_series = [
{%- for subkey in list_keys %}
{
ident: '{{ subkey[0] }}',
key: '{{ subkey[1] }}'
}{%- if not loop.last %},{%- endif %}
{%- endfor %}
];
// Calculate dataset '{{ chart_id }}'.
var {{ chart_id }}_dataset = get_dataset_timescatter_list(
{{ data_var_name }},
{{ chart_id }}_series
);
{{ _snippet_chart_timescatter(chart_id, cfg_params) }}
{{ _snippet_ecbks_timescatter(chart_id, cfg_params) }}
</script>
{%- endmacro %}
{#-
......
......@@ -163,15 +163,6 @@
)
}}
{{
macros_chart.render_chart_timescatter(
statistics,
'search_result_statistics',
'reporting_stats',
data_series
)
}}
<br>
{{
macros_chart.render_dataset_pie_list(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment