diff --git a/ckanext/budgetviz/timeseries_rbi/theme/public/timeseries_rbi-main.js b/ckanext/budgetviz/timeseries_rbi/theme/public/timeseries_rbi-main.js
index 15379f3..bccba1c 100644
--- a/ckanext/budgetviz/timeseries_rbi/theme/public/timeseries_rbi-main.js
+++ b/ckanext/budgetviz/timeseries_rbi/theme/public/timeseries_rbi-main.js
@@ -12,10 +12,10 @@ ckan.module('groupbarchart-view', function($, _) {
key.shift();
var state = new Object();
state.key = data[i].States
- state.disabled = data[i].States == "All States" ? false : true
+ state.disabled = data[i].States == "All-States" ? false : true
var values_arr = []
for (var j = 0; j < key.length; j++) {
- if (data[i][key[j]] == "...") {
+ if (data[i][key[j]] == "..." || data[i][key[j]] == "-") {
continue;
} else {
var temp = new Object();
@@ -35,33 +35,89 @@ ckan.module('groupbarchart-view', function($, _) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
-
+
var addMiscElements = function() {
d3.select("#viz-header").text(toTitleCase(resource.name));
}
+ function remove_record_notes(data) {
+ var regex = /[a-zA-Z]/i;
+ var data_length = data.length
+ for (var i = 0, j = 0; j < data_length; j++) {
+ if (!(regex.test(data[i]["States"][0]))) {
+ data.splice(i, 1)
+ } else {
+ i++;
+ }
+ }
+ for (var i = 0; i < data.length; i++) {
+ }
+ return data
+ }
+
+ function add_notes() {
+ try {
+ var extra_fields = package_details.extras
+ var unit, note;
+ for (var i in extra_fields) {
+ if (extra_fields[i].key.substr(0, 4).toLowerCase() == "unit" ) {
+ unit = extra_fields[i].value;
+ }
+ if (extra_fields[i].key.substr(0, 4).toLowerCase() == "note") {
+ note = extra_fields[i].value;
+ }
+ }
+ if (unit) {
+ d3.select(".notes-content")
+ .text(function(d) {
+ return unit;
+ })
+ d3.select(".notes-heading")
+ .text(function(d) {
+ return "Unit :";
+ })
+ }
+ if (note) {
+ d3.select(".unit-note-content")
+ .text(function(d) {
+ return note;
+ })
+ d3.select(".unit-note-heading")
+ .text(function(d) {
+ return "Note :";
+ })
+ }
+ } catch (err) {}
+ }
+
+ function prepareData(data) {
+ return mungeData(remove_record_notes(data))
+ }
+
function drawChart(data) {
nv.addGraph(function() {
var chart = nv.models.lineWithFocusChart();
-
var xScale = d3.time.scale();
var mini, max;
var minmax;
chart.xScale;
chart.x(function(d) {
- return d.x})
- .y(function(d) {
- return parseFloat(d.y) })
- .margin({ "left": 90, "right": 40, "top": 0, "bottom": 50 })
- .focusHeight(120)
- .focusMargin({ "top": 30 })
- .pointSize(10)
- .showLegend(true)
- .legendPosition("top")
- .focusMargin({ "top": 20 })
- .clipEdge(false);
-
+ return d.x
+ })
+ .y(function(d) {
+ var value = parseFloat(d.y)
+ return parseFloat(value.toFixed(2))
+ })
+ .margin({ "left": 90, "right": 40, "top": 0, "bottom": 50 })
+ .focusHeight(120)
+ .focusMargin({ "top": 30 })
+ .pointSize(10)
+ .showLegend(true)
+ .legendPosition("top")
+ .focusMargin({ "top": 20 })
+ .clipEdge(false);
+
chart.xAxis
.tickFormat(function(d) {
var c = parseInt(d) + 1;
@@ -75,18 +131,18 @@ ckan.module('groupbarchart-view', function($, _) {
});
chart.legend.margin({ top: 10, right: 0, left: -20, bottom: 40 })
- .align("center");
+ .align("center");
chart.yAxis.axisLabel(resource.name + "(Rs. Crore)")
- .axisLabelDistance(20);
+ .axisLabelDistance(20);
chart.tooltip.valueFormatter(function(d) {
- return d3.format(",.f")(d) ;
- })
- .headerFormatter(function(d) {
- var c = parseInt(d) + 1;
- return String(d) + " - " + String(c)
- })
+ return d3.format(",.f")(d);
+ })
+ .headerFormatter(function(d) {
+ var c = parseInt(d) + 1;
+ return String(d) + " - " + String(c)
+ })
var chartdata = d3.select('#chart svg')
.datum(data)
@@ -98,11 +154,11 @@ ckan.module('groupbarchart-view', function($, _) {
return chart;
});
}
-
d3.csv(resource_url, function(error, data) {
addMiscElements();
- drawChart(mungeData(data));
+ drawChart(prepareData(data));
+ add_notes()
});
}()
};
-});
+});
\ No newline at end of file
diff --git a/ckanext/budgetviz/timeseries_rbi/theme/templates/timeseries_rbi_view.html b/ckanext/budgetviz/timeseries_rbi/theme/templates/timeseries_rbi_view.html
index bb19d44..61fbe6a 100644
--- a/ckanext/budgetviz/timeseries_rbi/theme/templates/timeseries_rbi_view.html
+++ b/ckanext/budgetviz/timeseries_rbi/theme/templates/timeseries_rbi_view.html
@@ -33,6 +33,7 @@