From b8a466dbaefab91e1e7bbaf13d10da134c9b64ff Mon Sep 17 00:00:00 2001 From: Brandon Bernal Date: Wed, 28 May 2014 10:44:50 -0400 Subject: [PATCH] Suggested changes made Good catch. init() is now only defining the text tag in the main chart. I've moved the setting of the x and y into redraw() along with the label text. x and y are using width and height instead of calculating (getCurrentWidth() - margin.left - margin.right) as before. Indentation corrected as well, so Travis CI shouldn't error out on that either. --- c3.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/c3.js b/c3.js index 8ed96f4..6508a94 100644 --- a/c3.js +++ b/c3.js @@ -2808,15 +2808,10 @@ updateLegend(mapToIds(c3.data.targets), {withTransform: false, withTransitionForTransform: false}); /*-- Main Region --*/ - if (c3.data.targets.length === 0) { - main.append("text") + main.append("text") .attr("class", CLASS.text + ' ' + CLASS.empty) - .attr("x", (getCurrentWidth() - margin.left - margin.right) / 2) - .attr("y", (getCurrentHeight() - margin.top - margin.bottom) / 2) .attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers. - .attr("dominant-baseline", "middle") // vertical centering of text at y position in all browsers, except IE. - .text(__data_empty_label_text); - } + .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE. // Grids grid = main.append('g') @@ -3477,6 +3472,14 @@ // xgrid focus updateXgridFocus(); + // Data empty label positioning and text. + if (c3.data.targets.length === 0) { + main.select("text." + CLASS.text + '.' + CLASS.empty) + .attr("x", width / 2) + .attr("y", height / 2) + .text(__data_empty_label_text); + } + // grid main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); if (__grid_x_show) {