Skip to content
Open
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
16 changes: 9 additions & 7 deletions packages/graphing/src/axis/axes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ const StyledArrow = styled(Arrow)(() => ({
fill: color.defaults.PRIMARY,
}));

const StyledLabel = styled('div')(({ theme }) => ({
fontSize: theme.typography.fontSize,
}));

const StyledAxisLabelHolder = styled('div')(({ theme }) => ({
const StyledAxisLabelHolder = styled('div')(({ theme, centered }) => ({
padding: 0,
margin: 0,
textAlign: 'center',
'* > *': {
margin: 0,
padding: 0,
},
'& p': {
margin: 0,
},
fontSize: theme.typography.fontSize,
...(centered && { textAlign: 'center' }),
}));

const StyledAxesGroup = styled('g')(() => ({
Expand Down Expand Up @@ -129,7 +129,9 @@ export class RawXAxis extends React.Component {
{includeArrows && includeArrows.right && <StyledArrow direction="right" x={domain.max} y={0} scale={scale} />}
{domain.axisLabel && (
<foreignObject x={size.width + 17} y={scale.y(0) - 9} width={necessaryWidth} height={20 * necessaryRows}>
<StyledLabel dangerouslySetInnerHTML={{ __html: domain.axisLabel }} />
<Readable false>
<StyledAxisLabelHolder dangerouslySetInnerHTML={{ __html: domain.axisLabel }} />
</Readable>
</foreignObject>
)}
</StyledAxesGroup>
Expand Down Expand Up @@ -186,7 +188,7 @@ export class RawYAxis extends React.Component {
{range.axisLabel && (
<foreignObject x={scale.x(0) - necessaryWidth / 2} y={-33} width={necessaryWidth} height="20">
<Readable false>
<StyledAxisLabelHolder dangerouslySetInnerHTML={{ __html: range.axisLabel }} />
<StyledAxisLabelHolder centered dangerouslySetInnerHTML={{ __html: range.axisLabel }} />
</Readable>
</foreignObject>
)}
Expand Down
10 changes: 10 additions & 0 deletions packages/graphing/src/grid-setup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ const AxisConfig = (props) => {
const { axisLabel = {}, min = {}, max = {} } = displayedFields;
const activePlugins = ['bold', 'italic', 'underline', 'strikethrough'];

const onKeyDown = (event) => {
if (event.key === 'Enter') {
// prevent adding new lines - cancelling event
return true;
}

return false;
};

return (
<ColumnView>
{displayHeader && (
Expand Down Expand Up @@ -159,6 +168,7 @@ const AxisConfig = (props) => {
onChange={(value) => onChange('axisLabel', value)}
markup={label || ''}
charactersLimit={5}
onKeyDown={onKeyDown}
activePlugins={activePlugins}
/>
</AxisLabel>
Expand Down
Loading