Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 39c7bc8

Browse files
committed
import just that is needed
1 parent 973c2e8 commit 39c7bc8

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/plugin/hierarchical.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22

3-
import * as Chart from 'chart.js';
3+
import {helpers, defaults, pluginService} from 'chart.js';
44
import {toNodes, countExpanded, resolve, parentsOf, preOrderTraversal, lastOfLevel, spanLogic} from '../utils';
55

66

77
function parseFontOptions(options) {
8-
const valueOrDefault = Chart.helpers.valueOrDefault;
9-
const globalDefaults = Chart.defaults.global;
8+
const valueOrDefault = helpers.valueOrDefault;
9+
const globalDefaults = defaults.global;
1010
const size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
1111
const style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
1212
const family = valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily);
@@ -15,7 +15,7 @@ function parseFontOptions(options) {
1515
size: size,
1616
style: style,
1717
family: family,
18-
font: Chart.helpers.fontString(size, style, family)
18+
font: helpers.fontString(size, style, family)
1919
};
2020
}
2121

@@ -156,7 +156,7 @@ const HierarchicalPlugin = {
156156
const renderLabel = scale.options.hierarchyLabelPosition;
157157

158158
const scaleLabel = scale.options.scaleLabel;
159-
const scaleLabelFontColor = Chart.helpers.valueOrDefault(scaleLabel.fontColor, Chart.defaults.global.defaultFontColor);
159+
const scaleLabelFontColor = helpers.valueOrDefault(scaleLabel.fontColor, defaults.global.defaultFontColor);
160160
const scaleLabelFont = parseFontOptions(scaleLabel);
161161

162162
ctx.save();
@@ -488,6 +488,6 @@ const HierarchicalPlugin = {
488488
}
489489
};
490490

491-
Chart.pluginService.register(HierarchicalPlugin);
491+
pluginService.register(HierarchicalPlugin);
492492

493493
export default HierarchicalPlugin;

src/scale/hierarchical.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
import * as Chart from 'chart.js';
3+
import {scaleService, Scale} from 'chart.js';
44
import {parentsOf} from '../utils';
55

6-
const defaultConfig = Object.assign({}, Chart.scaleService.getScaleDefaults('category'), {
6+
const defaultConfig = Object.assign({}, scaleService.getScaleDefaults('category'), {
77
/**
88
* reduce the space between items at level X by this factor
99
*/
@@ -50,7 +50,7 @@ const defaultConfig = Object.assign({}, Chart.scaleService.getScaleDefaults('cat
5050
});
5151

5252

53-
const HierarchicalScale = Chart.Scale.extend({
53+
const HierarchicalScale = Scale.extend({
5454
determineDataLimits() {
5555
const data = this.chart.data;
5656
const labels = this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
@@ -186,6 +186,6 @@ const HierarchicalScale = Chart.Scale.extend({
186186
}
187187
});
188188

189-
Chart.scaleService.registerScaleType('hierarchical', HierarchicalScale, defaultConfig);
189+
scaleService.registerScaleType('hierarchical', HierarchicalScale, defaultConfig);
190190

191191
export default HierarchicalScale;

src/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export function parentsOf(node, flat) {
6969
}
7070

7171

72+
/**
73+
* computes the right most grand child of expanded nodes
74+
* @param {ILabelNode} node
75+
*/
7276
function rightMost(node) {
7377
if (!node.expand || node.children.length === 0) {
7478
return node;

0 commit comments

Comments
 (0)