Skip to content

Commit

Permalink
fix(radar): fix labels showing on esm usage
Browse files Browse the repository at this point in the history
Make config's 'data_x' field to be appended on data's option,
to be available for all chart types.

Ref naver#1765
  • Loading branch information
netil committed Nov 6, 2020
1 parent 74320cf commit 8682317
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/config/Options/data/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@
* Axis based chart data config options
*/
export default {
/**
* Specify the key of x values in the data.<br><br>
* We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.
* @name data․x
* @memberof Options
* @type {string}
* @default undefined
* @example
* data: {
* x: "date"
* }
*/
data_x: <string|undefined> undefined,

/**
* Specify the keys of the x values for each data.<br><br>
* This option can be used if we want to show the data that has different x values.
Expand Down
14 changes: 14 additions & 0 deletions src/config/Options/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ import {ChartTypes} from "../../../../types/types";
* data config options
*/
export default {
/**
* Specify the key of x values in the data.<br><br>
* We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.
* @name data․x
* @memberof Options
* @type {string}
* @default undefined
* @example
* data: {
* x: "date"
* }
*/
data_x: <string|undefined> undefined,

/**
* Converts data id value
* @name data․idConverter
Expand Down
52 changes: 52 additions & 0 deletions test/esm/radar-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
/* eslint-disable */
/* global describe, beforeEach, it, expect */
import {expect} from "chai";
import bb, {radar} from "../../src/index.esm";
import CLASS from "../../src/config/classes";

describe("ESM radar", function() {
let chart;

const args: any = {
data: {
x: "x",
columns: [
["x", "Data A", "Data B", "Data C", "Data D", "Data E"],
["data1", 330, 350, 200, 380, 150],
["data2", 130, 100, 30, 200, 80],
["data3", 230, 153, 85, 300, 250]
],
type: radar(),
labels: true
},
radar: {
axis: {
max: 400
},
level: {
depth: 4
},
direction: {
clockwise: true
}
}
};

beforeEach(() => {
chart = bb.generate(args);
});

it("should correctly render radar chart", () => {
const categories = chart.internal.config.axis_x_categories;

expect(categories.length === args.data.columns[0].length - 1).to.be.true;

chart.$.main.selectAll(`.${CLASS.axis} text`).each(function(d, i) {
expect(this.textContent).to.be.equal(categories[i]);
});
});
});

0 comments on commit 8682317

Please sign in to comment.