Browse Source

MAP-5822: 'No Data' text made more configurable.

pull/254/head
Brandon Bernal 11 years ago
parent
commit
d17e62914e
  1. 21
      c3.js
  2. 2
      c3.min.js

21
c3.js

@ -143,6 +143,12 @@
__data_ondragstart = getConfig(['data', 'ondragstart'], function () {}), __data_ondragstart = getConfig(['data', 'ondragstart'], function () {}),
__data_ondragend = getConfig(['data', 'ondragend'], function () {}); __data_ondragend = getConfig(['data', 'ondragend'], function () {});
// configuration for no plot-able data supplied.
var __data_empty_abort = getConfig(['data', 'empty', 'abort'], true);
var __data_empty_label_text = getConfig(['data', 'empty', 'label', 'text'], "");
var __data_empty_label_size = getConfig(['data', 'empty', 'label', 'size'], false);
var __data_empty_label_fill = getConfig(['data', 'empty', 'label', 'fill'], false);
// subchart // subchart
var __subchart_show = getConfig(['subchart', 'show'], false), var __subchart_show = getConfig(['subchart', 'show'], false),
__subchart_size_height = __subchart_show ? getConfig(['subchart', 'size', 'height'], 60) : 0; __subchart_size_height = __subchart_show ? getConfig(['subchart', 'size', 'height'], 60) : 0;
@ -1213,8 +1219,8 @@
var xDomain = [getXDomainMin(targets), getXDomainMax(targets)], var xDomain = [getXDomainMin(targets), getXDomainMax(targets)],
firstX = xDomain[0], lastX = xDomain[1], firstX = xDomain[0], lastX = xDomain[1],
padding = getXDomainPadding(targets, xDomain), padding = getXDomainPadding(targets, xDomain),
min = isTimeSeries ? new Date(firstX.getTime() - padding) : firstX - padding, min = firstX == undefined ? padding : (isTimeSeries ? new Date(firstX.getTime() - padding) : firstX - padding),
max = isTimeSeries ? new Date(lastX.getTime() + padding) : lastX + padding; max = lastX == undefined ? padding : (isTimeSeries ? new Date(lastX.getTime() + padding) : lastX + padding);
return [min, max]; return [min, max];
} }
function diffDomain(d) { function diffDomain(d) {
@ -2595,6 +2601,15 @@
.style("display", "none"); .style("display", "none");
/*-- Main Region --*/ /*-- Main Region --*/
if (c3.data.targets.length == 0) {
main.append("text")
.attr("class", CLASS.text)
.attr("x", (main[0][0].parentNode.width.baseVal.value / 2) - margin.left)
.attr("y", (main[0][0].parentNode.height.baseVal.value / 2) - margin.top)
.attr("text-anchor", "middle")
.attr("style", (__data_empty_label_fill ? "fill:"+ __data_empty_label_fill +"; " : "") + (__data_empty_label_size ? "font-size:"+ __data_empty_label_size +"; " : "") )
.text(__data_empty_label_text);
}
// Add Axis // Add Axis
main.append("g") main.append("g")
@ -3084,7 +3099,7 @@
var targetsToShow = filterTargetsToShow(c3.data.targets), tickValues, i, intervalForCulling; var targetsToShow = filterTargetsToShow(c3.data.targets), tickValues, i, intervalForCulling;
// abort if no targets to show // abort if no targets to show
if (targetsToShow.length === 0) { if (targetsToShow.length === 0 && __data_empty_abort) {
return; return;
} }

2
c3.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save