JSFiddle - React, Tailwind, and code Playground
by Vince
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/devextreme-dist/23.1.6/js/dx.all.js"></script>
<div class="dx-viewport demo-container">
<div id="chart"></div>
</div>
CSS
#chart {
height: 90vh;
}
.state-tooltip > h4 {
font-size: 14px;
}
.state-tooltip {
display: grid;
width: clamp(150px, 40vw, 300px);
grid-template: 'thumbnail' auto 'stat-box' auto / 1fr;
}
.state-tooltip > img {
width: 100%;
height: auto;
aspect-ratio: 611 / 340;
max-width: 100%;
max-height: 100%;
border: 1px solid rgba(191, 191, 191, 0.25);
border-radius: 10px;
background-color: gray;
}
.state-tooltip .exposure {
font-family: var(--ccp-heading-font-family, "Titillium Web", "Open Sans", sans-serif);
}
.state-tooltip .commitment {
font-weight: 500;
}
.state-tooltip .caption {
font-weight: 500;
}
.state-tooltip sup {
font-size: 0.8em;
vertical-align: super;
line-height: 0;
}
JavaScript
$(() => {
$('#chart').dxChart({
dataSource,
commonSeriesSettings: {
argumentField: 'Series',
type: 'bar',
cornerRadius: 5
},
palette: commitmentSummaryPalette,
series: [
{ valueField: 'Committed', name: 'Unfunded',barOverlapGroup: 'Series', label: {visible: true, position: 'outside', backgroundColor: '#002152', customizeText: function(e) { return USDollar.format(e.point.data.Committed); } } },
{ valueField: 'Called', name: 'Cumulative Called',barOverlapGroup: 'Series' },
{ valueField: 'Distributed', name: 'Cumulative Distributions',barOverlapGroup: 'Series',barPadding: 0.3, },
{ valueField: 'Committed', name: 'Commitment', showInLegend: true, visible: false }
],
legend: {
horizontalAlignment: 'center',
verticalAlignment: 'top',
position: 'outside',
itemTextPosition: 'right',
border: { visible: true, cornerRadius: 5 },
margin: {bottom: 30 }
},
rotated: true,
tooltip: {
enabled: true,
contentTemplate(info, container) {
const contentItems = [
`<div class='state-tooltip'><img src='//web.cdn.crystalfunds.com/public-web/pages/list-of-hedge-funds/images/firm-by-id/logo-${info.point.data.ShopId}-card.png' />`,
'<div class="stat-box">',
"<h4 class='exposure cs-card-ui__title'></h4>",
"<div class='commitment'><span class='caption'>Commitment</span>: </div>",
"<div class='called'><span class='caption'>Cumulative Called</span>:</div>",
`<div class='unfunded'><span class='caption'>Unfunded</span>: </div>`,
`<div class='distributed'><span class='caption'>Cumulative Distributions</span>: </div>`,
`${info.point.data.HasRecallable ? '<br/>* - Recallable Distributions are included in the Unfunded amount' : ''}`,
'</div>',
'</div>'
];
let unfundedValue =...