Added back support for popovers and minor fixes
This commit is contained in:
@ -1 +1 @@
|
|||||||
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '9fe03dfe50c4ea8c8985');
|
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '80544ff4a7959491b7f6');
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -208,7 +208,22 @@ const BarGraph = ({
|
|||||||
if (enableBarPopovers && d.popoverHtml) return 'pointer';
|
if (enableBarPopovers && d.popoverHtml) return 'pointer';
|
||||||
return (d.hasChildren && enableHierarchicalView) ? 'pointer' : 'default';
|
return (d.hasChildren && enableHierarchicalView) ? 'pointer' : 'default';
|
||||||
})
|
})
|
||||||
.on('click', (event, d) => {
|
.on('mouseenter', function(event, d) {
|
||||||
|
if (enableBarPopovers && d.popoverHtml) {
|
||||||
|
const rect = this.getBoundingClientRect();
|
||||||
|
setHoveredBar({
|
||||||
|
data: d,
|
||||||
|
position: {
|
||||||
|
x: rect.x + rect.width / 2,
|
||||||
|
y: rect.y
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('mouseleave', () => {
|
||||||
|
setHoveredBar(null);
|
||||||
|
})
|
||||||
|
.on('click', function(event, d) {
|
||||||
if (d.hasChildren && enableHierarchicalView) {
|
if (d.hasChildren && enableHierarchicalView) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
setAttributes({ selectedParentId: d.id });
|
setAttributes({ selectedParentId: d.id });
|
||||||
@ -412,7 +427,8 @@ const BarGraph = ({
|
|||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
boxShadow: '0 2px 4px rgba(0,0,0,0.2)',
|
boxShadow: '0 2px 4px rgba(0,0,0,0.2)',
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
pointerEvents: 'none'
|
pointerEvents: 'none',
|
||||||
|
marginTop: '-8px'
|
||||||
}}
|
}}
|
||||||
dangerouslySetInnerHTML={{ __html: hoveredBar.data.popoverHtml }}
|
dangerouslySetInnerHTML={{ __html: hoveredBar.data.popoverHtml }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -496,30 +496,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||||||
|
|
||||||
{chartData && Object.keys(chartData).length > 0 ? (
|
{chartData && Object.keys(chartData).length > 0 ? (
|
||||||
<>
|
<>
|
||||||
{selectedParentId && enableHierarchicalView && (
|
|
||||||
<button
|
|
||||||
onClick={() => setAttributes({ selectedParentId: null })}
|
|
||||||
style={{
|
|
||||||
marginBottom: '10px',
|
|
||||||
padding: '8px 16px',
|
|
||||||
backgroundColor: '#007cba',
|
|
||||||
color: 'white',
|
|
||||||
border: 'none',
|
|
||||||
borderRadius: '4px',
|
|
||||||
cursor: 'pointer',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: '4px',
|
|
||||||
fontSize: '14px',
|
|
||||||
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
|
|
||||||
}}
|
|
||||||
onMouseEnter={e => e.target.style.backgroundColor = '#006ba1'}
|
|
||||||
onMouseLeave={e => e.target.style.backgroundColor = '#007cba'}
|
|
||||||
>
|
|
||||||
<span style={{ fontSize: '18px', lineHeight: 1 }}>←</span>
|
|
||||||
Back to Parent View
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<BarGraph
|
<BarGraph
|
||||||
data={chartData}
|
data={chartData}
|
||||||
width={chartWidth}
|
width={chartWidth}
|
||||||
|
|||||||
Reference in New Issue
Block a user