Skip to content
Browse files

mod_admin_stats: move texts above of charts + added value formating.

  • Loading branch information...
1 parent 273f25d commit 6369d82b2f796c7008aef5c2a439b721ed6d1931 @kaos kaos committed Mar 18, 2013
View
1 modules/mod_admin_stats/lib/css/charts.css
@@ -71,4 +71,5 @@ path.line:hover {
.chart-text {
border-radius: 5px;
padding: 0px 5px;
+ margin-right: 5px;
}
View
8 modules/mod_admin_stats/lib/js/charts/histogram-duration.js
@@ -92,13 +92,13 @@ function histogram_duration_chart() {
.attr("x", 1)
.attr("height", function(d) {
return client_height - top(d); })
- //.style("fill-opacity", 1e-6)
+ .style("fill-opacity", 1e-6)
.transition()
.duration(props.animation_speed)
- //.style("fill-opacity", 1)
+ .style("fill-opacity", 1)
.attr("width", function(d, i) { return width(d, i) })
- //.each("end", function(){
- //d3.select(this).style("fill-opacity", null) });
+ .each("end", function(){
+ d3.select(this).style("fill-opacity", null) });
;
// exit dropped bars
View
25 modules/mod_admin_stats/lib/js/charts/metric-histogram.js
@@ -25,25 +25,16 @@ function metric_histogram() {
function factory_data(d) {
return [
- { factory: "wrap",
+ { factory: "text",
datum: {
- class: "pull-left",
+ format: d3.format(".2s"),
data: [
- { factory: "text",
- datum: { data: [
- { label: "Min", value: d.min },
- { label: "Max", value: d.max }]}
- },
- { factory: "text",
- datum: {
- label: "Mean (geometric)",
- value: d.mean.geometric }
- },
- { factory: "text",
- datum: {
- label: "Sample count",
- value: d.count }
- }]}
+ { label: "Min", value: d.min },
+ { label: "Max", value: d.max },
+ { label: "Mean (geometric)",
+ value: d.mean.geometric },
+ { label: "Sample count", value: d.count }
+ ]}
},
{ factory: histogram, datum: d.histogram }
];
View
16 modules/mod_admin_stats/lib/js/charts/metric-meter.js
@@ -21,23 +21,19 @@ function metric_meter() {
// return our updated values
return [
- { factory: "wrap",
+ { factory: "text",
datum: {
- class: "pull-left",
+ format: d3.format(".2s"),
data: series.map(
function(serie, i) {
return {
- factory: "text",
- datum: {
- class: "serie-" + i,
- label: serie,
- value: d[serie] }
+ class: "serie-" + i,
+ label: serie,
+ value: d[serie]
};
})
.concat([
- { factory: "text",
- datum: { label: "Total count", value: d.count }
- }
+ { label: "Total count", value: d.count }
])}
},
// the index of this line chart is used above
View
15 modules/mod_admin_stats/lib/js/charts/z_charts.js
@@ -97,10 +97,17 @@ var z_charts = {};
};
function text_update(d) {
+ function format_value(v) {
+ return d.format ? d.format(v.value) : v.value;
+ }
+
var texts = d3.select(this).selectAll("span.chart-text")
.data(d.data || [d]);
- texts.selectAll(".chart-value")
- .text(function(v) { return v.value });
+
+ // update
+ texts.select(".chart-value").text(format_value);
+
+ // add
texts.enter()
.append("span")
.attr("class", function(d) {
@@ -111,8 +118,10 @@ var z_charts = {};
.text(function(v) { return v.label });
this.append("span")
.attr("class", "chart-value")
- .text(function(v) { return v.value });
+ .text(format_value);
});
+
+ // delete
texts.exit()
.remove();
}

0 comments on commit 6369d82

Please sign in to comment.
Something went wrong with that request. Please try again.