Skip to content

Commit

Permalink
fix(data): Fix empty label text flickering
Browse files Browse the repository at this point in the history
- Correct empty label text displaying css prop from 'opacity' to 'display'
- Removed applying .transition() which makes flickering.

Fix #901
  • Loading branch information
netil authored May 27, 2019
1 parent 2e9dbfe commit 173990b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
24 changes: 22 additions & 2 deletions spec/internals/data-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,10 @@ describe("DATA", () => {
before(() => {
args = {
data: {
columns: [],
columns: [
["data", 50, 20, 10, 40, 15]
],
hide: ["data"],
empty: {
label: {
text: "No Data"
Expand All @@ -1765,7 +1768,24 @@ describe("DATA", () => {
it("check for empty label text", () => {
const emptyLabelText = chart.$.main.select(`.${CLASS.text}.${CLASS.empty}`);

expect(+emptyLabelText.style("opacity")).to.be.equal(1);
expect(emptyLabelText.style("display")).to.be.equal("block");
});

it("check the visiblity on data toggles", done => {
const emptyLabelText = chart.$.main.select(`.${CLASS.text}.${CLASS.empty}`);

// display data
chart.toggle();

expect(emptyLabelText.style("display")).to.be.equal("none");

// hide data
chart.toggle();

setTimeout(() => {
expect(emptyLabelText.style("display")).to.be.equal("block");
done();
}, 300)
});

it("set options empty.label.text=''", () => {
Expand Down
16 changes: 2 additions & 14 deletions src/config/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,6 @@ export default class Options {
*/
data_xSort: true,

/**
* Specify the key of epochs values in the data.
* @name data․epochs
* @memberof Options
* @type {String}
* @default epochs
* @example
* data: {
* epochs: "count"
* }
*/
data_epochs: "epochs",

/**
* Converts data id value
* @name data․idConverter
Expand Down Expand Up @@ -1146,7 +1133,8 @@ export default class Options {
data_keys: undefined,

/**
* Set text displayed when empty data.
* Set text label to be displayed when there's no data to show.
* - ex. Toggling all visible data to not be shown, unloading all current data, etc.
* @name data․empty․label․text
* @memberof Options
* @type {String}
Expand Down
3 changes: 1 addition & 2 deletions src/internals/ChartInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,7 @@ export default class ChartInternal {
.attr("x", $$.width / 2)
.attr("y", $$.height / 2)
.text(config.data_empty_label_text)
.transition()
.style("opacity", targetsToShow.length ? 0 : 1);
.style("display", targetsToShow.length ? "none" : null);

// grid
$$.updateGrid(duration);
Expand Down
3 changes: 2 additions & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,8 @@ export interface Data {
};

/**
* Set text displayed when empty data.
* Set text label to be displayed when there's no data to show.
* - ex. Toggling all visible data to not be shown, unloading all current data, etc.
*/
empty?: { label: { text: string } };

Expand Down

0 comments on commit 173990b

Please sign in to comment.