Skip to content

Commit

Permalink
Merge pull request #4690 from wri/develop
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
willian-viana authored Sep 12, 2023
2 parents a36a118 + b985a8c commit 25d973c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
12 changes: 10 additions & 2 deletions components/charts/composed-chart/axis-label.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

const AxisLabel = ({ label, direction }) => (
const AxisLabel = ({ label, direction, isSimple = false }) => (
<>
<foreignObject
width="100%"
height="100%"
className={`${direction}-label-container`}
>
<div className={`${direction}-label`}>
<span>{label}</span>
<span
className={cx({
'simple-mode-label': isSimple,
})}
>
{label}
</span>
</div>
</foreignObject>
</>
Expand All @@ -18,6 +25,7 @@ const AxisLabel = ({ label, direction }) => (
AxisLabel.propTypes = {
label: PropTypes.string,
direction: PropTypes.string,
isSimple: PropTypes.bool,
};

export default AxisLabel;
9 changes: 8 additions & 1 deletion components/charts/composed-chart/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class CustomComposedChart extends PureComponent {
<div
className={cx('c-composed-chart', className, {
'overflow-x-visible': hasLabels,
'no-padding': simple,
})}
style={{
height: simple ? 110 : height || 250,
Expand Down Expand Up @@ -237,7 +238,13 @@ class CustomComposedChart extends PureComponent {
interval="preserveStartEnd"
{...xAxis}
{...(config?.xAxis?.label && {
label: <AxisLabel label={config?.xAxis?.label} direction="x" />,
label: (
<AxisLabel
label={config?.xAxis?.label}
direction="x"
isSimple={simple}
/>
),
})}
/>
{(!simple || simpleNeedsAxis) && (
Expand Down
8 changes: 8 additions & 0 deletions components/charts/composed-chart/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ $layout-breakpoint-3xl: 1536px;
overflow-x: visible !important;
}

.no-padding {
padding: 0 !important;
}

.x-label-container,
.y-label-container {
position: relative;
Expand All @@ -58,6 +62,10 @@ $layout-breakpoint-3xl: 1536px;

span {
font-size: 0.8125rem;

&.simple-mode-label {
font-size: 0.625rem !important;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions components/widget/components/widget-footer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}

&.simple {
margin-top: 1.25rem;
font-size: rem(10px);

p {
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/land-cover/tree-cover-density/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
types: ['country', 'wdpa', 'aoi'],
admins: ['adm0', 'adm1', 'adm2'],
large: true,
visible: ['dashboard'],
visible: ['dashboard', 'analysis'],
chartType: 'composedChart',
colors: 'density',
settingsConfig: [
Expand Down

0 comments on commit 25d973c

Please sign in to comment.