Skip to content
This repository was archived by the owner on May 2, 2022. It is now read-only.

Commit ed92245

Browse files
committed
Merge branch 'release/v1.0.3'
2 parents 52f284a + b7959ef commit ed92245

File tree

24 files changed

+787
-997
lines changed

24 files changed

+787
-997
lines changed

dist/muze.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/muze.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/muze.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
.dotted-line {
121121
stroke-dasharray: 2,4;
122122
}
123-
123+
124124
/* .muze-tooltip-content-container {
125125
padding-left: 0px;
126126
padding-right: 0px;

examples/js/sample.js

Lines changed: 223 additions & 162 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 482 additions & 684 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/layout/src/grid-layout/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function renderTable (mount, className, rowData) {
1717
const table = makeElement(mount, 'table', ['layout'], `${className}-table`);
1818
const body = makeElement(table, 'tbody', ['layout'], `${className}-body`);
1919
const rows = makeElement(body, 'tr', rowData, `${className}-tr`);
20-
const cells = makeElement(rows, 'td', (d, i) => d.filter(e => e !== null).map(e =>
20+
const cells = makeElement(rows, 'td', (d, i) => d.filter(e => e !== null && e.config().show).map(e =>
2121
({ placeholder: e, rowIndex: i })), `${className}-td`, {}, key => key.placeholder.id);
2222

2323
return { table, body, rows, cells };

packages/muze-legend/src/legend/defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const LEGEND_TITLE = {
3131

3232
export const DEFAULT_CONFIG = {
3333
classPrefix: 'muze',
34-
34+
borderStyle: 'solid',
35+
borderColor: 'rgba(0,0,0,0)',
3536
formatter: {
3637
bounds: {
3738
lower: 'less than',

packages/muze-legend/src/legend/legend-helper.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,22 @@ export const getInterpolatedData = (domain, steps) => {
5050
* @param {*} measurement
5151
* @param {*} classPrefix
5252
*/
53-
export const titleCreator = (container, title, measurement, config) =>
54-
makeElement(container, 'div', [1], `${config.classPrefix}-legend-title`)
55-
.style(WIDTH, '100%')
56-
.style(HEIGHT, `${measurement.height}px`)
57-
.style('padding-left', `${measurement.padding}px`)
58-
.style('padding-right', `${measurement.padding}px`)
59-
.style('border-bottom-width', `${measurement.border}px`)
60-
.style('text-align', title.orientation instanceof Function ?
61-
title.orientation(config.position) : title.orientation)
62-
.text(title.text)
63-
.node();
53+
export const titleCreator = (container, title, measurement, config) => {
54+
const titleContainer = makeElement(container, 'table', [1], `${config.classPrefix}-legend-title`)
55+
.style(WIDTH, `${measurement.width}px`)
56+
.style(HEIGHT, `${measurement.height}px`)
57+
.style('border-bottom', `${measurement.border}px ${config.borderStyle} ${config.borderColor}`)
58+
.style('text-align', title.orientation instanceof Function ?
59+
title.orientation(config.position) : title.orientation);
60+
return makeElement(titleContainer, 'td', [1], `${config.classPrefix}-legend-title-text`)
61+
.style(WIDTH, `${measurement.width}px`)
62+
.style(HEIGHT, '100%')
63+
.style('padding', `${measurement.padding}px`)
64+
.text(title.text)
65+
.node();
66+
};
6467

65-
/**
68+
/**
6669
*
6770
*
6871
* @param {*} data
@@ -180,7 +183,6 @@ export const computeItemSpaces = (config, measures, data) => {
180183
itemSpaces.push(itemSpace);
181184
iconSpaces.push(iconSpace);
182185
});
183-
184186
itemSpaces.forEach((itemSpace, i) => {
185187
if (align === 'horizontal') {
186188
itemSpace.height = totalHeight;
@@ -194,7 +196,7 @@ export const computeItemSpaces = (config, measures, data) => {
194196
itemSpaces[i].width = maxIconWidth;
195197
labelSpaces[i].width = maxIconWidth;
196198
}
197-
totalWidth = Math.max(totalWidth + itemSpaces[i].width, titleWidth);
199+
totalWidth = Math.max(totalWidth + itemSpaces[i].width);
198200
} else {
199201
itemSpace.width = Math.max(totalWidth, maxWidth);
200202
if (textOrientation === TOP || textOrientation === BOTTOM) {
@@ -205,10 +207,11 @@ export const computeItemSpaces = (config, measures, data) => {
205207
iconSpaces[i].width = maxIconWidth;
206208
itemSpaces[i].width = labelSpaces[i].width + maxIconWidth;
207209
labelSpaces[i].width = maxItemSpaces.width - maxIconWidth;
208-
totalWidth = Math.max(totalWidth, itemSpace.width, titleWidth) + effPadding;
210+
totalWidth = Math.max(totalWidth, itemSpace.width) + effPadding;
209211
}
210212
}
211213
});
214+
totalWidth = Math.max(totalWidth, titleWidth);
212215
totalHeight += titleHeight + effPadding;
213216

214217
return { totalHeight, totalWidth, itemSpaces, iconSpaces, maxItemSpaces, maxIconWidth };

packages/muze-legend/src/legend/simple-legend.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ export default class SimpleLegend {
186186
this.data(this.dataFromScale(this.scale()));
187187
// Get space occupied by title
188188
const titleSpace = this.getTitleSpace();
189-
const titleHeight = titleSpace.height > 0 ? titleSpace.height * 1.25 : 0;
190-
const titleWidth = titleSpace.width;
189+
const titleHeight = titleSpace.height > 0 ? titleSpace.height + effPadding : 0;
190+
const titleWidth = titleSpace.width + effPadding;
191191

192192
// Get space occupied by labels
193193
const labelSpaces = this.getLabelSpaces(effPadding, align);
@@ -233,11 +233,15 @@ export default class SimpleLegend {
233233
* @memberof Legend
234234
*/
235235
renderTitle (container) {
236-
const { titleSpaces, border, padding } = this.measurement();
236+
const { titleSpaces, border, padding, width } = this.measurement();
237+
const { borderStyle, borderColor } = this.config();
237238
return titleCreator(container, this.title(), {
238239
height: titleSpaces.height,
240+
width,
239241
border,
240-
padding
242+
padding,
243+
borderStyle,
244+
borderColor
241245
}, this.config());
242246
}
243247

@@ -251,7 +255,9 @@ export default class SimpleLegend {
251255
render () {
252256
const firebolt = this.firebolt();
253257
const {
254-
classPrefix
258+
classPrefix,
259+
borderStyle,
260+
borderColor
255261
} = this.config();
256262
const {
257263
maxWidth,
@@ -269,7 +275,7 @@ export default class SimpleLegend {
269275
legendContainer.style('width', `${Math.min(maxWidth, width) - margin * 2}px`)
270276
.style('height', `${Math.min(maxHeight, height) - margin * 2}px`)
271277
.style('margin', `${margin}px`)
272-
.style('border-width', `${border}px`);
278+
.style('border', `${border}px ${borderStyle} ${borderColor}`);
273279
this.legendContainer(legendContainer.node());
274280

275281
// create title

0 commit comments

Comments
 (0)