Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/__demo__/data/event/boolean.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@
"name": "Yes"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/date.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@
"name": "1993-12-02"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/datetime.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@
"name": "E2E - Date & Time"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/email.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@
"name": "test@pmail.com"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/integer.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@
"name": "10"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/legendset.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@
"name": "Last 3 months"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/optionset.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@
"name": "Last 3 months"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/time.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@
"name": "Period"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
8 changes: 7 additions & 1 deletion src/__demo__/data/event/yesonly.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@
"name": "Yes"
},
"": {
"name": "No value"
"name": "No value",
"style": {
"fontStyle": "italic",
"color": "#6C7787",
"fontFamily": "monospace",
"letterSpacing": "-0.3px"
}
}
},
"dimensions": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/PivotTable/PivotTableColumnHeaderCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const PivotTableColumnHeaderCell = ({
header.label !== 'Subtotal' // TODO: Actually look up the column type!
? 'column-header'
: 'empty-header',
header.isNaData && 'nadata-header',
{
'fixed-header': engine.options.fixColumnHeaders,
},
Expand All @@ -78,6 +77,7 @@ export const PivotTableColumnHeaderCell = ({
<span
className="column-header-label"
data-test="visualization-column-header"
style={{ ...header.style }}
>
{header.label}
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/PivotTable/PivotTableRowHeaderCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const PivotTableRowHeaderCell = ({
header.label !== 'Subtotal'
? 'row-header'
: 'empty-header',
header.isNaData && 'nadata-header',
header.includesHierarchy && 'row-header-hierarchy',
{
'fixed-header': engine.options.fixRowHeaders,
Expand All @@ -50,6 +49,7 @@ export const PivotTableRowHeaderCell = ({
.slice(0, rowLevel)
.reduce((width, acc) => (acc += width), 0)
: 0,
...header.style,
}}
dataTest="visualization-row-header"
>
Expand Down
3 changes: 0 additions & 3 deletions src/components/PivotTable/styles/PivotTable.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ export const cell = css`
.empty-header {
background-color: #cddaed;
}
.nadata-header {
color: ${colors.grey600};
}
.total-header {
background-color: #bac6d8;
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/pivotTable/AdaptiveClippingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class AdaptiveClippingController {
axis.sizes[index]?.size || 0
)
: 0,
...header.style,
})
this.addSize(
{ row: -headerStack.length + level, column: index },
Expand Down
18 changes: 4 additions & 14 deletions src/modules/pivotTable/PivotTableEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,8 @@ const buildDimensionLookup = (visualization, metadata, headers) => {
meta: metadata.items[row.dimension],
count: metadata.dimensions[row.dimension].length,
itemIds: metadata.dimensions[row.dimension],
items: metadata.dimensions[row.dimension].map((item) =>
item === ''
? {
...metadata.items[item],
isNaData: true,
}
: metadata.items[item]
items: metadata.dimensions[row.dimension].map(
(item) => metadata.items[item]
),
isDxDimension: isDxDimension(metadata.items[row.dimension]),
position: 'row',
Expand All @@ -131,13 +126,8 @@ const buildDimensionLookup = (visualization, metadata, headers) => {
meta: metadata.items[column.dimension],
count: metadata.dimensions[column.dimension].length,
itemIds: metadata.dimensions[column.dimension],
items: metadata.dimensions[column.dimension].map((item) =>
item === ''
? {
...metadata.items[item],
isNaData: true,
}
: metadata.items[item]
items: metadata.dimensions[column.dimension].map(
(item) => metadata.items[item]
),
isDxDimension: isDxDimension(metadata.items[column.dimension]),
position: 'column',
Expand Down
4 changes: 1 addition & 3 deletions src/modules/pivotTable/getHeaderForDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ export const getHeaderForDisplay = ({
? currentHeader.hierarchy.join(' / ')
: currentHeader?.name

const isNaData = currentHeader.isNaData

return {
span,
label,
includesHierarchy,
isNaData,
...(currentHeader.style ? { style: currentHeader.style } : {}),
}
}
14 changes: 9 additions & 5 deletions src/modules/pivotTable/measureText.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import {

let canvas

const getContext = (fontSize) => {
const getContext = (
fontSize = 11,
fontFamily = 'Roboto, Arial, sans-serif'
) => {
if (!canvas) {
canvas = document.createElement('canvas')
}

const ctx = canvas.getContext('2d')
ctx.font = `${fontSize}px Roboto, Arial, sans-serif`
ctx.font = `${fontSize}px ${fontFamily}`

return ctx
}

const measureText = (text, fontSize = 11) => {
const ctx = getContext(fontSize)
const measureText = (text, fontSize, fontFamily) => {
const ctx = getContext(fontSize, fontFamily)

const textMetrics = ctx.measureText(text)
return textMetrics.width
Expand All @@ -31,6 +34,7 @@ export const measureTextWithWrapping = (
maxWidth = CLIPPED_CELL_MAX_SIZE,
justifyBuffer = WRAPPED_TEXT_JUSTIFY_BUFFER,
lineHeight = WRAPPED_TEXT_LINE_HEIGHT,
fontFamily,
}
) => {
if (!text) {
Expand All @@ -48,7 +52,7 @@ export const measureTextWithWrapping = (
const words = paragraphs.shift().split(/\s+/)
while (words.length) {
const nextWord = (currentLineWidth === 0 ? '' : ' ') + words.shift()
const nextWordWidth = measureText(nextWord, fontSize)
const nextWordWidth = measureText(nextWord, fontSize, fontFamily)
if (maxWidth && currentLineWidth + nextWordWidth > maxWidth) {
if (currentLineWidth <= maxWidth - justifyBuffer) {
// Wrapping this word would cause an unnaturally short line
Expand Down
17 changes: 12 additions & 5 deletions src/modules/response/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ import { applyBooleanHandler } from './boolean.js'
import { applyDefaultHandler } from './default.js'
import { applyOptionSetHandler } from './optionSet.js'

export const NA_VALUE = ''
export const NA_VALUE_DISPLAY_NAME = i18n.t('No value')
export const PREFIX_SEPARATOR = '_'
export const NA_VALUE = ''
export const NA_VALUE_ITEM = {
name: i18n.t('No value'),
style: {
fontStyle: 'italic',
color: '#6C7787',
fontFamily: 'monospace',
letterSpacing: '-0.3px',
},
}

export const UNSUPPORTED_VALUE_TYPES = [
VALUE_TYPE_COORDINATE,
VALUE_TYPE_GEOJSON,
Expand Down Expand Up @@ -117,9 +126,7 @@ export const transformResponse = (response, { hideNaData = false } = {}) => {
NA_VALUE,
]

transformedResponse.metaData.items[NA_VALUE] = {
name: i18n.t('No value'),
}
transformedResponse.metaData.items[NA_VALUE] = NA_VALUE_ITEM
}
})
}
Expand Down
Loading