Hi i am using React Fuse theme suggested from one of my client. On Dashboard i am showing some chart line chart bar and line chart etc. According to the design there are app icons at the top of the chart bars. Look at the screenshot attached with this message I read apexcharts official documentation and try many other things which i found from internet but still got not any progress. Here i am sharing my function every thing works fine but i don't have any idea that how i can show these icons at the top of chart bars.
function PlatformCompareWidget(props) {
const chartSeries = [
{
name: 'IOS',
data: props.singupUserData?.map((item) => Number(item.ios).toFixed(2)),
color: '#51ABFF',
},
{
name: 'Android',
data: props.singupUserData?.map((item) => Number(item.android).toFixed(2)),
color: '#34C759',
},
{
name: 'Web',
data: props.singupUserData?.map((item) => Number(item.web).toFixed(2)),
color: '#9994FF',
},
]
const filterSeries =
props.platform === ''
? chartSeries
: chartSeries.filter((series) => series.name.toLowerCase() === props.platform);
const chartOptions = {
series: filterSeries,
options: {
grid: {
show: false, // Hide background horizontal lines
},
legend: {
show: false,
},
chart: {
type: 'bar',
height: 350,
toolbar: {
show: false,
},
},
plotOptions: {
bar: {
borderRadius: 6,
horizontal: false,
columnWidth: props.platform === '' ? '25%' : '8%',
endingShape: 'rounded',
},
},
dataLabels: {
enabled: false,
},
stroke: {
show: true,
width: 2,
colors: ['transparent'],
},
xaxis: {
categories: props.singupUserData?.map((item) =>
item.date
? format(parse(item.date, 'yyyy-MM-dd', new Date()), 'dd MMM yyyy')
: format(parse(item.month, 'yyyy-MM', new Date()), 'MMM yyyy')
),
},
yaxis: {
show: false,
},
fill: {
opacity: 1,
},
},
};
return (
<ReactApexChart
className="flex-auto w-full"
options={chartOptions.options}
series={chartOptions.series}
height={320}
type="bar"
/>
);
}
Apexcharts has annotations that can be used to place images at different places on the plot area.
However, placing the annotations so that they are at the top of the bar is not as simple as it could be. In the particular case of your type of plot, the problem is with positioning the annotation/image on the x direction. Point annotation's
xcan either be a category (which is not good enough for each series in the category) or a pixel coordinate (which is not easy to measure exactly).The best solution I found is to enable
dataLabels, place them on top of the bars, but make them invisible and use the space allocated automatically by apexcharts for the data labels to place the annotations.The creation of the annotations can be done in the mounted event, on a configuration like this:
If the plot is resizable
Here's a full example in vanilla js