diff --git a/charts_app/models.py b/charts_app/models.py index 13c2131..0551e5f 100644 --- a/charts_app/models.py +++ b/charts_app/models.py @@ -43,7 +43,7 @@ class Chart(models.Model): ) layer = models.ForeignKey(Layer, validators=[validate_wfs]) - title = models.CharField(max_length=128, blank=True) + title = models.CharField(max_length=128, blank=False) category = models.CharField(max_length=200) quantity = models.CharField(max_length=200) type = models.SmallIntegerField(choices=CHART_TYPES, default=0) @@ -77,4 +77,4 @@ class ChartForm(ModelForm): class Meta: model = Chart - fields = '__all__' \ No newline at end of file + fields = '__all__' diff --git a/haitidata/static/js/csv.js b/haitidata/static/js/csv.js index 373a620..226e8a0 100644 --- a/haitidata/static/js/csv.js +++ b/haitidata/static/js/csv.js @@ -150,6 +150,10 @@ var getCsv = function(csv_link, category, quantity, agg, chartType, id){ .datum(dati) .call(line); } + loading = false; + var cog = document.getElementById("rotella"); + cog.parentNode.removeChild(cog); + document.getElementById("preview_btn").disabled = false; }; create(chartType); diff --git a/haitidata/static/js/donut.js b/haitidata/static/js/donut.js index 03348e2..9312517 100644 --- a/haitidata/static/js/donut.js +++ b/haitidata/static/js/donut.js @@ -87,7 +87,11 @@ function donutChart(cat, qnt, title, id){ .selectAll('polyline') .data(pie) .enter().append('polyline') - .attr('points', calculatePoints); + .attr('points', calculatePoints) + .style('opacity', 0.3) + .style('stroke', 'black') + .style('width', '2px') + .style('fill', 'none'); // =========================================================================================== // =========================================================================================== @@ -412,4 +416,4 @@ function donutChart(cat, qnt, title, id){ }; return chart; -} \ No newline at end of file +} diff --git a/haitidata/static/js/getChart.js b/haitidata/static/js/getChart.js index 3108370..6e6d8f0 100644 --- a/haitidata/static/js/getChart.js +++ b/haitidata/static/js/getChart.js @@ -1,6 +1,8 @@ var dict_title_tc = {0:"Bar",1:"Pie", 2:"Donut", 3:"Line"}; var dict_title_agg = {0:"Sum",1:"Mean",2:"Count", 3:"Max", 4:"Min"}; +var loading = false; + function get_chart_detail(){ var id = "chart_area_plain" //create area for chart @@ -46,11 +48,27 @@ function get_chart_popup(){ createChartArea(); }; }; + + var createCog = function(){ + var cog_div = document.createElement("div"); + cog_div.innerHTML = 'Loading data...'; + cog_div.setAttribute("id", "rotella"); + cog_div.setAttribute("style", "display:flex;justify-content:center;align-items:center;"); + var doc_chart = document.getElementById(id); + element = doc_chart.parentNode; + element.insertBefore(cog_div, doc_chart); + + }; + if (document.getElementById("id_title").value == ""){ document.getElementById("chart_title").innerHTML = suggestedTitle; }else document.getElementById("chart_title").innerHTML = document.getElementById("id_title").value; +if (loading == false) { + loading = true; + createCog(); createChartArea(); replaceChart(); attachAbstract(); getCsv(csv_url, category, quantity, agg, chart_type, id); } +} diff --git a/haitidata/static/js/pie.js b/haitidata/static/js/pie.js index ea9478b..1a75114 100644 --- a/haitidata/static/js/pie.js +++ b/haitidata/static/js/pie.js @@ -86,7 +86,11 @@ function pieChart(cat, qnt, title, id){ .selectAll('polyline') .data(pie) .enter().append('polyline') - .attr('points', calculatePoints); + .attr('points', calculatePoints) + .style('opacity', .3) + .style('stroke', 'black') + .style('width', '2px') + .style('fill', 'none'); // =========================================================================================== // =========================================================================================== @@ -412,4 +416,4 @@ function pieChart(cat, qnt, title, id){ }; return chart; -} \ No newline at end of file +} diff --git a/haitidata/templates/charts_app/chart_detail.html b/haitidata/templates/charts_app/chart_detail.html index 4749dd6..b7a824f 100644 --- a/haitidata/templates/charts_app/chart_detail.html +++ b/haitidata/templates/charts_app/chart_detail.html @@ -92,60 +92,9 @@
{% trans "Change type of the chart or type of aggregation." %}
- - - -