plottable 3.9.0-dev-56-geb1f7fd → 3.9.0-dev-57-g2333f4e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/axes/axis.d.ts +15 -0
- package/build/src/axes/axis.js +31 -3
- package/build/src/axes/categoryAxis.d.ts +3 -0
- package/build/src/axes/categoryAxis.js +11 -1
- package/build/src/axes/timeAxis.d.ts +3 -0
- package/build/src/axes/timeAxis.js +24 -2
- package/build/src/components/label.d.ts +4 -0
- package/build/src/components/label.js +3 -0
- package/build/src/core/version.js +1 -1
- package/build/src/plots/barPlot.d.ts +10 -0
- package/build/src/plots/barPlot.js +29 -2
- package/build/src/plots/scatterPlot.d.ts +11 -0
- package/build/src/plots/scatterPlot.js +32 -1
- package/build/src/plots/stackedBarPlot.d.ts +3 -0
- package/build/src/plots/stackedBarPlot.js +22 -2
- package/package.json +1 -1
- package/plottable.css +75 -2
- package/plottable.js +422 -281
- package/plottable.js.map +1 -1
package/build/src/axes/axis.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component } from "../components/component";
|
|
2
|
+
import { LabelFontSizePx } from "../components/label";
|
|
2
3
|
import { Formatter } from "../core/formatters";
|
|
3
4
|
import { Point, SimpleSelection, SpaceRequest } from "../core/interfaces";
|
|
4
5
|
import { Scale } from "../scales/scale";
|
|
@@ -41,6 +42,11 @@ export declare class Axis<D> extends Component {
|
|
|
41
42
|
private static _ANNOTATION_LABEL_PADDING;
|
|
42
43
|
protected _tickMarkContainer: SimpleSelection<void>;
|
|
43
44
|
protected _tickLabelContainer: SimpleSelection<void>;
|
|
45
|
+
/**
|
|
46
|
+
* `protected` instead of `private` to accommodate time axes which draw their own label containers
|
|
47
|
+
* and need access to this value.
|
|
48
|
+
*/
|
|
49
|
+
protected _tickLabelFontSize: LabelFontSizePx;
|
|
44
50
|
protected _baseline: SimpleSelection<void>;
|
|
45
51
|
protected _scale: Scale<D, number>;
|
|
46
52
|
private _formatter;
|
|
@@ -74,6 +80,14 @@ export declare class Axis<D> extends Component {
|
|
|
74
80
|
* @param {Element} element
|
|
75
81
|
*/
|
|
76
82
|
tickLabelDataOnElement(element: Element): {};
|
|
83
|
+
/**
|
|
84
|
+
* Get the label font size in px.
|
|
85
|
+
*/
|
|
86
|
+
tickLabelFontSize(): LabelFontSizePx;
|
|
87
|
+
/**
|
|
88
|
+
* Set the label font size.
|
|
89
|
+
*/
|
|
90
|
+
tickLabelFontSize(fontSize: LabelFontSizePx): this;
|
|
77
91
|
protected _computeWidth(): number;
|
|
78
92
|
protected _computeHeight(): number;
|
|
79
93
|
requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest;
|
|
@@ -86,6 +100,7 @@ export declare class Axis<D> extends Component {
|
|
|
86
100
|
height: number;
|
|
87
101
|
};
|
|
88
102
|
protected _setup(): void;
|
|
103
|
+
private _configureTickLabelContainer();
|
|
89
104
|
protected _getTickValues(): D[];
|
|
90
105
|
/**
|
|
91
106
|
* Render tick marks, baseline, and annotations. Should be super called by subclasses and then overridden to draw
|
package/build/src/axes/axis.js
CHANGED
|
@@ -8,6 +8,7 @@ var tslib_1 = require("tslib");
|
|
|
8
8
|
var d3 = require("d3");
|
|
9
9
|
var Typesettable = require("typesettable");
|
|
10
10
|
var component_1 = require("../components/component");
|
|
11
|
+
var label_1 = require("../components/label");
|
|
11
12
|
var Formatters = require("../core/formatters");
|
|
12
13
|
var Utils = require("../utils");
|
|
13
14
|
var makeEnum_1 = require("../utils/makeEnum");
|
|
@@ -24,6 +25,11 @@ var Axis = /** @class */ (function (_super) {
|
|
|
24
25
|
*/
|
|
25
26
|
function Axis(scale, orientation) {
|
|
26
27
|
var _this = _super.call(this) || this;
|
|
28
|
+
/**
|
|
29
|
+
* `protected` instead of `private` to accommodate time axes which draw their own label containers
|
|
30
|
+
* and need access to this value.
|
|
31
|
+
*/
|
|
32
|
+
_this._tickLabelFontSize = label_1.Label._DEFAULT_FONT_SIZE_PX;
|
|
27
33
|
_this._endTickLength = 5;
|
|
28
34
|
_this._innerTickLength = 5;
|
|
29
35
|
_this._tickLabelPadding = 10;
|
|
@@ -76,6 +82,18 @@ var Axis = /** @class */ (function (_super) {
|
|
|
76
82
|
}
|
|
77
83
|
return element === undefined ? undefined : d3.select(element).datum();
|
|
78
84
|
};
|
|
85
|
+
Axis.prototype.tickLabelFontSize = function (fontSize) {
|
|
86
|
+
if (fontSize == null) {
|
|
87
|
+
return this._tickLabelFontSize;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this._tickLabelFontSize = fontSize;
|
|
91
|
+
if (this._tickLabelContainer != null) {
|
|
92
|
+
this._configureTickLabelContainer();
|
|
93
|
+
}
|
|
94
|
+
return this.render();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
79
97
|
Axis.prototype._computeWidth = function () {
|
|
80
98
|
// to be overridden by subclass logic
|
|
81
99
|
return this._maxLabelTickLength();
|
|
@@ -147,8 +165,7 @@ var Axis = /** @class */ (function (_super) {
|
|
|
147
165
|
_super.prototype._setup.call(this);
|
|
148
166
|
this._tickMarkContainer = this.content().append("g")
|
|
149
167
|
.classed(Axis.TICK_MARK_CLASS + "-container", true);
|
|
150
|
-
this.
|
|
151
|
-
.classed(Axis.TICK_LABEL_CLASS + "-container", true);
|
|
168
|
+
this._configureTickLabelContainer();
|
|
152
169
|
this._baseline = this.content().append("line").classed("baseline", true);
|
|
153
170
|
this._annotationContainer = this.content().append("g")
|
|
154
171
|
.classed("annotation-container", true);
|
|
@@ -160,6 +177,15 @@ var Axis = /** @class */ (function (_super) {
|
|
|
160
177
|
this._annotationMeasurer = new Typesettable.CacheMeasurer(typesetterContext);
|
|
161
178
|
this._annotationWriter = new Typesettable.Writer(this._annotationMeasurer, typesetterContext);
|
|
162
179
|
};
|
|
180
|
+
Axis.prototype._configureTickLabelContainer = function () {
|
|
181
|
+
if (this._tickLabelContainer == null) {
|
|
182
|
+
this._tickLabelContainer = this.content().append("g");
|
|
183
|
+
}
|
|
184
|
+
// clearing to remove outdated font-size classes
|
|
185
|
+
this._tickLabelContainer.attr("class", null)
|
|
186
|
+
.classed(Axis.TICK_LABEL_CLASS + "-container", true)
|
|
187
|
+
.classed("label-" + this._tickLabelFontSize, true);
|
|
188
|
+
};
|
|
163
189
|
/*
|
|
164
190
|
* Function for generating tick values in data-space (as opposed to pixel values).
|
|
165
191
|
* To be implemented by subclasses.
|
|
@@ -639,7 +665,9 @@ var Axis = /** @class */ (function (_super) {
|
|
|
639
665
|
};
|
|
640
666
|
Axis.prototype.invalidateCache = function () {
|
|
641
667
|
_super.prototype.invalidateCache.call(this);
|
|
642
|
-
this._annotationMeasurer
|
|
668
|
+
if (this._annotationMeasurer != null) {
|
|
669
|
+
this._annotationMeasurer.reset();
|
|
670
|
+
}
|
|
643
671
|
};
|
|
644
672
|
/**
|
|
645
673
|
* The css class applied to each end tick mark (the line on the end tick).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LabelFontSizePx } from "../components/label";
|
|
1
2
|
import { Point, SpaceRequest } from "../core/interfaces";
|
|
2
3
|
import * as Scales from "../scales";
|
|
3
4
|
import { Axis, AxisOrientation } from "./axis";
|
|
@@ -133,6 +134,8 @@ export declare class Category extends Axis<string> {
|
|
|
133
134
|
* @param {d3.Selection} ticks The tick elements to write.
|
|
134
135
|
*/
|
|
135
136
|
private _drawTicks(stepWidth, ticks);
|
|
137
|
+
tickLabelFontSize(): LabelFontSizePx;
|
|
138
|
+
tickLabelFontSize(fontSize: LabelFontSizePx): this;
|
|
136
139
|
/**
|
|
137
140
|
* Measures the size of the tick labels without making any (permanent) DOM changes.
|
|
138
141
|
*
|
|
@@ -233,6 +233,14 @@ var Category = /** @class */ (function (_super) {
|
|
|
233
233
|
self._writer.write(self.formatter()(d), width, height, writeOptions, container.node());
|
|
234
234
|
});
|
|
235
235
|
};
|
|
236
|
+
Category.prototype.tickLabelFontSize = function (fontSize) {
|
|
237
|
+
if (fontSize == null) {
|
|
238
|
+
return _super.prototype.tickLabelFontSize.call(this);
|
|
239
|
+
}
|
|
240
|
+
// Resets the measurer to measure distances using the latest font size
|
|
241
|
+
this.invalidateCache();
|
|
242
|
+
return _super.prototype.tickLabelFontSize.call(this, fontSize);
|
|
243
|
+
};
|
|
236
244
|
/**
|
|
237
245
|
* Measures the size of the tick labels without making any (permanent) DOM changes.
|
|
238
246
|
*
|
|
@@ -339,7 +347,9 @@ var Category = /** @class */ (function (_super) {
|
|
|
339
347
|
};
|
|
340
348
|
Category.prototype.invalidateCache = function () {
|
|
341
349
|
_super.prototype.invalidateCache.call(this);
|
|
342
|
-
this._measurer
|
|
350
|
+
if (this._measurer != null) {
|
|
351
|
+
this._measurer.reset();
|
|
352
|
+
}
|
|
343
353
|
};
|
|
344
354
|
/**
|
|
345
355
|
* How many pixels to give labels at minimum before downsampling takes effect.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Formatter } from "../core/formatters";
|
|
2
2
|
import * as Scales from "../scales";
|
|
3
|
+
import { LabelFontSizePx } from "../components/label";
|
|
3
4
|
import { Axis } from "./axis";
|
|
4
5
|
export declare const TimeInterval: {
|
|
5
6
|
second: "second";
|
|
@@ -80,6 +81,8 @@ export declare class Time extends Axis<Date> {
|
|
|
80
81
|
* orientations.
|
|
81
82
|
*/
|
|
82
83
|
constructor(scale: Scales.Time, orientation: TimeAxisOrientation, useUTC?: boolean);
|
|
84
|
+
tickLabelFontSize(): LabelFontSizePx;
|
|
85
|
+
tickLabelFontSize(fontSize: LabelFontSizePx): this;
|
|
83
86
|
/**
|
|
84
87
|
* Gets the label positions for each tier.
|
|
85
88
|
*/
|
|
@@ -50,6 +50,23 @@ var Time = /** @class */ (function (_super) {
|
|
|
50
50
|
_this.annotationFormatter(Formatters.time("%a %b %d, %Y", _this._useUTC));
|
|
51
51
|
return _this;
|
|
52
52
|
}
|
|
53
|
+
Time.prototype.tickLabelFontSize = function (fontSize) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
if (fontSize == null) {
|
|
56
|
+
return _super.prototype.tickLabelFontSize.call(this);
|
|
57
|
+
}
|
|
58
|
+
if (this._tierLabelContainers != null) {
|
|
59
|
+
this.invalidateCache();
|
|
60
|
+
this._computeHeight();
|
|
61
|
+
this._tierLabelContainers.forEach(function (container) {
|
|
62
|
+
// clearing to remove outdated font-size classes
|
|
63
|
+
container.attr("class", null)
|
|
64
|
+
.classed(axis_1.Axis.TICK_LABEL_CLASS + "-container", true)
|
|
65
|
+
.classed("label-" + _this._tickLabelFontSize, true);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return _super.prototype.tickLabelFontSize.call(this, fontSize);
|
|
69
|
+
};
|
|
53
70
|
Time.prototype.tierLabelPositions = function (newPositions) {
|
|
54
71
|
if (newPositions == null) {
|
|
55
72
|
return this._tierLabelPositions;
|
|
@@ -194,7 +211,9 @@ var Time = /** @class */ (function (_super) {
|
|
|
194
211
|
this._baseline.remove();
|
|
195
212
|
for (var i = 0; i < this._numTiers; ++i) {
|
|
196
213
|
var tierContainer = this.content().append("g").classed(Time.TIME_AXIS_TIER_CLASS, true);
|
|
197
|
-
this._tierLabelContainers.push(tierContainer.append("g")
|
|
214
|
+
this._tierLabelContainers.push(tierContainer.append("g")
|
|
215
|
+
.classed(axis_1.Axis.TICK_LABEL_CLASS + "-container", true)
|
|
216
|
+
.classed("label-" + this._tickLabelFontSize, true));
|
|
198
217
|
this._tierMarkContainers.push(tierContainer.append("g").classed(axis_1.Axis.TICK_MARK_CLASS + "-container", true));
|
|
199
218
|
this._tierBaselines.push(tierContainer.append("line").classed("baseline", true));
|
|
200
219
|
}
|
|
@@ -243,6 +262,7 @@ var Time = /** @class */ (function (_super) {
|
|
|
243
262
|
labelPos = tickPos;
|
|
244
263
|
}
|
|
245
264
|
var tickLabelsUpdate = container.selectAll("." + axis_1.Axis.TICK_LABEL_CLASS).data(labelPos, function (d) { return String(d.valueOf()); });
|
|
265
|
+
tickLabelsUpdate.remove();
|
|
246
266
|
var tickLabelsEnter = tickLabelsUpdate
|
|
247
267
|
.enter()
|
|
248
268
|
.append("g")
|
|
@@ -417,7 +437,9 @@ var Time = /** @class */ (function (_super) {
|
|
|
417
437
|
};
|
|
418
438
|
Time.prototype.invalidateCache = function () {
|
|
419
439
|
_super.prototype.invalidateCache.call(this);
|
|
420
|
-
this._measurer
|
|
440
|
+
if (this._measurer != null) {
|
|
441
|
+
this._measurer.reset();
|
|
442
|
+
}
|
|
421
443
|
};
|
|
422
444
|
/**
|
|
423
445
|
* The CSS class applied to each Time Axis tier
|
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
import * as Typesettable from "typesettable";
|
|
6
6
|
import { SimpleSelection, SpaceRequest } from "../core/interfaces";
|
|
7
7
|
import { Component } from "./component";
|
|
8
|
+
export declare type LabelFontSizePx = 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
|
|
8
9
|
export declare class Label extends Component {
|
|
10
|
+
static _MIN_FONT_SIZE_PX: LabelFontSizePx;
|
|
11
|
+
static _MAX_FONT_SIZE_PX: LabelFontSizePx;
|
|
12
|
+
static _DEFAULT_FONT_SIZE_PX: LabelFontSizePx;
|
|
9
13
|
protected _textContainer: SimpleSelection<void>;
|
|
10
14
|
protected _text: string;
|
|
11
15
|
protected _angle: number;
|
|
@@ -122,6 +122,9 @@ var Label = /** @class */ (function (_super) {
|
|
|
122
122
|
_super.prototype.invalidateCache.call(this);
|
|
123
123
|
this._measurer.reset();
|
|
124
124
|
};
|
|
125
|
+
Label._MIN_FONT_SIZE_PX = 12;
|
|
126
|
+
Label._MAX_FONT_SIZE_PX = 24;
|
|
127
|
+
Label._DEFAULT_FONT_SIZE_PX = 12;
|
|
125
128
|
return Label;
|
|
126
129
|
}(component_1.Component));
|
|
127
130
|
exports.Label = Label;
|
|
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
* real version number during the dist phase for for npm module publishing. Modifying this line should
|
|
10
10
|
* be accompanied by modifying the "sed-version" task in package.json accordingly.
|
|
11
11
|
*/
|
|
12
|
-
exports.version = "3.9.0-dev-
|
|
12
|
+
exports.version = "3.9.0-dev-57-g2333f4e";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LabelFontSizePx } from "../components/label";
|
|
1
2
|
import { Dataset } from "../core/dataset";
|
|
2
3
|
import { DatumFormatter } from "../core/formatters";
|
|
3
4
|
import { AttributeToProjector, IAccessor, IEntityBounds, Point } from "../core/interfaces";
|
|
@@ -45,6 +46,7 @@ export declare class Bar<X, Y> extends XYPlot<X, Y> {
|
|
|
45
46
|
private _labelFormatter;
|
|
46
47
|
private _labelsEnabled;
|
|
47
48
|
private _labelsPosition;
|
|
49
|
+
protected _labelFontSize: LabelFontSizePx;
|
|
48
50
|
private _hideBarsIfAnyAreTooWide;
|
|
49
51
|
private _labelConfig;
|
|
50
52
|
private _baselineValueProvider;
|
|
@@ -178,6 +180,14 @@ export declare class Bar<X, Y> extends XYPlot<X, Y> {
|
|
|
178
180
|
* @returns {Bar} The calling Bar Plot.
|
|
179
181
|
*/
|
|
180
182
|
labelFormatter(formatter: DatumFormatter): this;
|
|
183
|
+
/**
|
|
184
|
+
* Get the label font size in px.
|
|
185
|
+
*/
|
|
186
|
+
labelFontSize(): LabelFontSizePx;
|
|
187
|
+
/**
|
|
188
|
+
* Set the label font size.
|
|
189
|
+
*/
|
|
190
|
+
labelFontSize(fontSize: LabelFontSizePx): this;
|
|
181
191
|
protected _createNodesForDataset(dataset: Dataset): ProxyDrawer;
|
|
182
192
|
protected _removeDatasetNodes(dataset: Dataset): void;
|
|
183
193
|
/**
|
|
@@ -8,6 +8,7 @@ var tslib_1 = require("tslib");
|
|
|
8
8
|
var d3 = require("d3");
|
|
9
9
|
var Typesettable = require("typesettable");
|
|
10
10
|
var Animators = require("../animators");
|
|
11
|
+
var label_1 = require("../components/label");
|
|
11
12
|
var Formatters = require("../core/formatters");
|
|
12
13
|
var Drawers = require("../drawers");
|
|
13
14
|
var drawer_1 = require("../drawers/drawer");
|
|
@@ -37,6 +38,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
37
38
|
_this._labelFormatter = Formatters.identity();
|
|
38
39
|
_this._labelsEnabled = false;
|
|
39
40
|
_this._labelsPosition = exports.LabelsPosition.end;
|
|
41
|
+
_this._labelFontSize = label_1.Label._DEFAULT_FONT_SIZE_PX;
|
|
40
42
|
_this._hideBarsIfAnyAreTooWide = true;
|
|
41
43
|
_this._barAlignment = "middle";
|
|
42
44
|
_this._computeBarPixelThickness = memoize_1.memoize(computeBarPixelThickness);
|
|
@@ -210,9 +212,29 @@ var Bar = /** @class */ (function (_super) {
|
|
|
210
212
|
return this;
|
|
211
213
|
}
|
|
212
214
|
};
|
|
215
|
+
Bar.prototype.labelFontSize = function (fontSize) {
|
|
216
|
+
var _this = this;
|
|
217
|
+
if (fontSize == null) {
|
|
218
|
+
return this._labelFontSize;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this.invalidateCache();
|
|
222
|
+
this._labelFontSize = fontSize;
|
|
223
|
+
this._labelConfig.forEach(function (_a) {
|
|
224
|
+
var labelArea = _a.labelArea;
|
|
225
|
+
// clearing to remove outdated font-size classes
|
|
226
|
+
labelArea.attr("class", null)
|
|
227
|
+
.classed(Bar._LABEL_AREA_CLASS, true)
|
|
228
|
+
.classed("label-" + _this._labelFontSize, true);
|
|
229
|
+
});
|
|
230
|
+
return this.render();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
213
233
|
Bar.prototype._createNodesForDataset = function (dataset) {
|
|
214
234
|
var drawer = _super.prototype._createNodesForDataset.call(this, dataset);
|
|
215
|
-
var labelArea = this._renderArea.append("g")
|
|
235
|
+
var labelArea = this._renderArea.append("g")
|
|
236
|
+
.classed(Bar._LABEL_AREA_CLASS, true)
|
|
237
|
+
.classed("label-" + this._labelFontSize, true);
|
|
216
238
|
var context = new Typesettable.SvgContext(labelArea.node());
|
|
217
239
|
var measurer = new Typesettable.CacheMeasurer(context);
|
|
218
240
|
var writer = new Typesettable.Writer(measurer, context);
|
|
@@ -686,7 +708,12 @@ var Bar = /** @class */ (function (_super) {
|
|
|
686
708
|
Bar.prototype.invalidateCache = function () {
|
|
687
709
|
var _this = this;
|
|
688
710
|
_super.prototype.invalidateCache.call(this);
|
|
689
|
-
this.datasets().forEach(function (dataset) {
|
|
711
|
+
this.datasets().forEach(function (dataset) {
|
|
712
|
+
var labelConfig = _this._labelConfig.get(dataset);
|
|
713
|
+
if (labelConfig != null) {
|
|
714
|
+
labelConfig.measurer.reset();
|
|
715
|
+
}
|
|
716
|
+
});
|
|
690
717
|
};
|
|
691
718
|
Bar._BAR_THICKNESS_RATIO = 0.95;
|
|
692
719
|
Bar._BAR_GAPLESS_THRESHOLD_PX = 3;
|
|
@@ -3,6 +3,7 @@ import { AttributeToProjector, Bounds, IAccessor, Point } from "../core/interfac
|
|
|
3
3
|
import { SymbolFactory } from "../core/symbolFactories";
|
|
4
4
|
import { ProxyDrawer } from "../drawers/drawer";
|
|
5
5
|
import { Scale } from "../scales/scale";
|
|
6
|
+
import { LabelFontSizePx } from "../components/label";
|
|
6
7
|
import * as Drawers from "../drawers";
|
|
7
8
|
import * as Plots from "./";
|
|
8
9
|
import { IAccessorScaleBinding, ILightweightPlotEntity, IPlotEntity, ITransformableAccessorScaleBinding } from "./";
|
|
@@ -16,6 +17,7 @@ export declare class Scatter<X, Y> extends XYPlot<X, Y> {
|
|
|
16
17
|
protected static _LABEL_AREA_CLASS: string;
|
|
17
18
|
private _labelConfig;
|
|
18
19
|
private _labelFormatter;
|
|
20
|
+
private _labelFontSize;
|
|
19
21
|
protected static _LABEL_MARGIN_FROM_BUBBLE: number;
|
|
20
22
|
private _labelsEnabled;
|
|
21
23
|
/**
|
|
@@ -89,6 +91,15 @@ export declare class Scatter<X, Y> extends XYPlot<X, Y> {
|
|
|
89
91
|
* @returns {Scatter} The calling SCATTER Plot.
|
|
90
92
|
*/
|
|
91
93
|
labelsEnabled(enabled: boolean): this;
|
|
94
|
+
/**
|
|
95
|
+
* Get the label font size in px.
|
|
96
|
+
*/
|
|
97
|
+
labelFontSize(): LabelFontSizePx;
|
|
98
|
+
/**
|
|
99
|
+
* Set the label font size.
|
|
100
|
+
*/
|
|
101
|
+
labelFontSize(fontSize: LabelFontSizePx): this;
|
|
102
|
+
invalidateCache(): void;
|
|
92
103
|
protected _createNodesForDataset(dataset: Dataset): ProxyDrawer;
|
|
93
104
|
protected _removeDatasetNodes(dataset: Dataset): void;
|
|
94
105
|
protected _additionalPaint(time: number): void;
|
|
@@ -11,6 +11,7 @@ var SymbolFactories = require("../core/symbolFactories");
|
|
|
11
11
|
var drawer_1 = require("../drawers/drawer");
|
|
12
12
|
var symbolDrawer_1 = require("../drawers/symbolDrawer");
|
|
13
13
|
var Animators = require("../animators");
|
|
14
|
+
var label_1 = require("../components/label");
|
|
14
15
|
var Drawers = require("../drawers");
|
|
15
16
|
var Scales = require("../scales");
|
|
16
17
|
var Utils = require("../utils");
|
|
@@ -27,6 +28,7 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
27
28
|
function Scatter() {
|
|
28
29
|
var _this = _super.call(this) || this;
|
|
29
30
|
_this._labelFormatter = Formatters.identity();
|
|
31
|
+
_this._labelFontSize = label_1.Label._DEFAULT_FONT_SIZE_PX;
|
|
30
32
|
_this._labelsEnabled = false;
|
|
31
33
|
_this.addClass("scatter-plot");
|
|
32
34
|
var animator = new Animators.Easing();
|
|
@@ -151,9 +153,38 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
151
153
|
return this;
|
|
152
154
|
}
|
|
153
155
|
};
|
|
156
|
+
Scatter.prototype.labelFontSize = function (fontSize) {
|
|
157
|
+
var _this = this;
|
|
158
|
+
if (fontSize == null) {
|
|
159
|
+
return this._labelFontSize;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.invalidateCache();
|
|
163
|
+
this._labelFontSize = fontSize;
|
|
164
|
+
this._labelConfig.forEach(function (_a) {
|
|
165
|
+
var labelArea = _a.labelArea;
|
|
166
|
+
labelArea.attr("class", null)
|
|
167
|
+
.classed(Scatter._LABEL_AREA_CLASS, true)
|
|
168
|
+
.classed("label-" + _this._labelFontSize, true);
|
|
169
|
+
});
|
|
170
|
+
return this.render();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
Scatter.prototype.invalidateCache = function () {
|
|
174
|
+
var _this = this;
|
|
175
|
+
_super.prototype.invalidateCache.call(this);
|
|
176
|
+
this.datasets().forEach(function (dataset) {
|
|
177
|
+
var labelConfig = _this._labelConfig.get(dataset);
|
|
178
|
+
if (labelConfig != null) {
|
|
179
|
+
labelConfig.measurer.reset();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
154
183
|
Scatter.prototype._createNodesForDataset = function (dataset) {
|
|
155
184
|
var drawer = _super.prototype._createNodesForDataset.call(this, dataset);
|
|
156
|
-
var labelArea = this._renderArea.append("g")
|
|
185
|
+
var labelArea = this._renderArea.append("g")
|
|
186
|
+
.classed(Scatter._LABEL_AREA_CLASS, true)
|
|
187
|
+
.classed("label-" + this._labelFontSize, true);
|
|
157
188
|
var context = new Typesettable.SvgContext(labelArea.node());
|
|
158
189
|
var measurer = new Typesettable.CacheMeasurer(context);
|
|
159
190
|
var writer = new Typesettable.Writer(measurer, context);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dataset } from "../core/dataset";
|
|
2
2
|
import { Formatter } from "../core/formatters";
|
|
3
3
|
import * as Utils from "../utils";
|
|
4
|
+
import { LabelFontSizePx } from "../components/label";
|
|
4
5
|
import { Bar, BarOrientation } from "./barPlot";
|
|
5
6
|
export declare class StackedBar<X, Y> extends Bar<X, Y> {
|
|
6
7
|
protected static _EXTREMA_LABEL_MARGIN_FROM_BAR: number;
|
|
@@ -51,6 +52,8 @@ export declare class StackedBar<X, Y> extends Bar<X, Y> {
|
|
|
51
52
|
* @returns {this}
|
|
52
53
|
*/
|
|
53
54
|
extremaFormatter(formatter: Formatter): this;
|
|
55
|
+
labelFontSize(): LabelFontSizePx;
|
|
56
|
+
labelFontSize(fontSize: LabelFontSizePx): this;
|
|
54
57
|
protected _setup(): void;
|
|
55
58
|
protected _drawLabels(): void;
|
|
56
59
|
protected _generateAttrToProjector(): {
|
|
@@ -55,9 +55,27 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
55
55
|
return this;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
StackedBar.prototype.labelFontSize = function (fontSize) {
|
|
59
|
+
if (fontSize == null) {
|
|
60
|
+
return _super.prototype.labelFontSize.call(this);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (this._labelArea != null) {
|
|
64
|
+
// clearing to remove outdated font-size classes
|
|
65
|
+
this._labelArea.attr("class", null)
|
|
66
|
+
.classed(barPlot_1.Bar._LABEL_AREA_CLASS, true)
|
|
67
|
+
.classed("label-" + this._labelFontSize, true);
|
|
68
|
+
}
|
|
69
|
+
_super.prototype.labelFontSize.call(this, fontSize);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
58
73
|
StackedBar.prototype._setup = function () {
|
|
59
74
|
_super.prototype._setup.call(this);
|
|
60
|
-
this._labelArea = this._renderArea
|
|
75
|
+
this._labelArea = this._renderArea
|
|
76
|
+
.append("g")
|
|
77
|
+
.classed(barPlot_1.Bar._LABEL_AREA_CLASS, true)
|
|
78
|
+
.classed("label-" + this._labelFontSize, true);
|
|
61
79
|
var context = new Typesettable.SvgContext(this._labelArea.node());
|
|
62
80
|
this._measurer = new Typesettable.CacheMeasurer(context);
|
|
63
81
|
this._writer = new Typesettable.Writer(this._measurer, context);
|
|
@@ -210,7 +228,9 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
210
228
|
};
|
|
211
229
|
StackedBar.prototype.invalidateCache = function () {
|
|
212
230
|
_super.prototype.invalidateCache.call(this);
|
|
213
|
-
this._measurer
|
|
231
|
+
if (this._measurer != null) {
|
|
232
|
+
this._measurer.reset();
|
|
233
|
+
}
|
|
214
234
|
};
|
|
215
235
|
StackedBar._EXTREMA_LABEL_MARGIN_FROM_BAR = 5;
|
|
216
236
|
return StackedBar;
|
package/package.json
CHANGED
package/plottable.css
CHANGED
|
@@ -112,11 +112,84 @@
|
|
|
112
112
|
fill: #32313F;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
.plottable .
|
|
116
|
-
.plottable .
|
|
115
|
+
.plottable .tick-label-container.label-12 text,
|
|
116
|
+
.plottable .bar-label-text-area.label-12 text,
|
|
117
|
+
.plottable .scatter-label-text-area.label-12 text {
|
|
117
118
|
font-size: 12px;
|
|
118
119
|
}
|
|
119
120
|
|
|
121
|
+
.plottable .tick-label-container.label-13 text,
|
|
122
|
+
.plottable .bar-label-text-area.label-13 text,
|
|
123
|
+
.plottable .scatter-label-text-area.label-13 text {
|
|
124
|
+
font-size: 13px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.plottable .tick-label-container.label-14 text,
|
|
128
|
+
.plottable .bar-label-text-area.label-14 text,
|
|
129
|
+
.plottable .scatter-label-text-area.label-14 text {
|
|
130
|
+
font-size: 14px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.plottable .tick-label-container.label-15 text,
|
|
134
|
+
.plottable .bar-label-text-area.label-15 text,
|
|
135
|
+
.plottable .scatter-label-text-area.label-15 text {
|
|
136
|
+
font-size: 15px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.plottable .tick-label-container.label-16 text,
|
|
140
|
+
.plottable .bar-label-text-area.label-16 text,
|
|
141
|
+
.plottable .scatter-label-text-area.label-16 text {
|
|
142
|
+
font-size: 16px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.plottable .tick-label-container.label-17 text,
|
|
146
|
+
.plottable .bar-label-text-area.label-17 text,
|
|
147
|
+
.plottable .scatter-label-text-area.label-17 text {
|
|
148
|
+
font-size: 17px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.plottable .tick-label-container.label-18 text,
|
|
152
|
+
.plottable .bar-label-text-area.label-18 text,
|
|
153
|
+
.plottable .scatter-label-text-area.label-18 text {
|
|
154
|
+
font-size: 18px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.plottable .tick-label-container.label-19 text,
|
|
158
|
+
.plottable .bar-label-text-area.label-19 text,
|
|
159
|
+
.plottable .scatter-label-text-area.label-19 text {
|
|
160
|
+
font-size: 19px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.plottable .tick-label-container.label-20 text,
|
|
164
|
+
.plottable .bar-label-text-area.label-20 text,
|
|
165
|
+
.plottable .scatter-label-text-area.label-20 text {
|
|
166
|
+
font-size: 20px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.plottable .tick-label-container.label-21 text,
|
|
170
|
+
.plottable .bar-label-text-area.label-21 text,
|
|
171
|
+
.plottable .scatter-label-text-area.label-21 text {
|
|
172
|
+
font-size: 21px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.plottable .tick-label-container.label-22 text,
|
|
176
|
+
.plottable .bar-label-text-area.label-22 text,
|
|
177
|
+
.plottable .scatter-label-text-area.label-22 text {
|
|
178
|
+
font-size: 22px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.plottable .tick-label-container.label-23 text,
|
|
182
|
+
.plottable .bar-label-text-area.label-23 text,
|
|
183
|
+
.plottable .scatter-label-text-area.label-23 text {
|
|
184
|
+
font-size: 23px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.plottable .tick-label-container.label-24 text,
|
|
188
|
+
.plottable .bar-label-text-area.label-24 text,
|
|
189
|
+
.plottable .scatter-label-text-area.label-24 text {
|
|
190
|
+
font-size: 24px;
|
|
191
|
+
}
|
|
192
|
+
|
|
120
193
|
.plottable .label-area text {
|
|
121
194
|
fill: #32313F;
|
|
122
195
|
font-size: 14px;
|