146 lines
3.0 KiB
TypeScript
146 lines
3.0 KiB
TypeScript
"use client";
|
|
import dynamic from "next/dynamic";
|
|
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
|
|
import { colors } from "@/lib/colors";
|
|
import { useTheme } from "next-themes";
|
|
import { hexToRGB } from "@/lib/utils";
|
|
import { useConfig } from "@/hooks/use-config";
|
|
import {
|
|
getGridConfig,
|
|
getLabel,
|
|
getYAxisConfig,
|
|
} from "@/lib/appex-chart-options";
|
|
|
|
const BasicBubble = ({ height = 350 }) => {
|
|
const [config] = useConfig();
|
|
const { theme: mode } = useTheme();
|
|
|
|
interface DataRange {
|
|
min: number;
|
|
max: number;
|
|
}
|
|
function generateData(baseval: number, count: number, yrange: DataRange) {
|
|
var i = 0;
|
|
var series: [number, number, number][] = [];
|
|
while (i < count) {
|
|
var x = Math.floor(Math.random() * (750 - 1 + 1)) + 1;
|
|
var y =
|
|
Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;
|
|
var z = Math.floor(Math.random() * (75 - 15 + 1)) + 15;
|
|
|
|
series.push([x, y, z]);
|
|
baseval += 86400000;
|
|
i++;
|
|
}
|
|
return series;
|
|
}
|
|
const series = [
|
|
{
|
|
name: "Bubble1",
|
|
data: generateData(new Date("11 Feb 2017 GMT").getTime(), 20, {
|
|
min: 10,
|
|
max: 60,
|
|
}),
|
|
},
|
|
{
|
|
name: "Bubble2",
|
|
data: generateData(new Date("11 Feb 2017 GMT").getTime(), 20, {
|
|
min: 10,
|
|
max: 60,
|
|
}),
|
|
},
|
|
{
|
|
name: "Bubble3",
|
|
data: generateData(new Date("11 Feb 2017 GMT").getTime(), 20, {
|
|
min: 10,
|
|
max: 60,
|
|
}),
|
|
},
|
|
{
|
|
name: "Bubble4",
|
|
data: generateData(new Date("11 Feb 2017 GMT").getTime(), 20, {
|
|
min: 10,
|
|
max: 60,
|
|
}),
|
|
},
|
|
];
|
|
|
|
const options: any = {
|
|
chart: {
|
|
toolbar: {
|
|
show: false,
|
|
},
|
|
},
|
|
dataLabels: {
|
|
enabled: false,
|
|
},
|
|
fill: {
|
|
opacity: 0.8,
|
|
},
|
|
stroke: {
|
|
curve: "smooth",
|
|
width: 4,
|
|
},
|
|
colors: [
|
|
colors.primary,
|
|
colors.info,
|
|
colors.primary,
|
|
colors.success,
|
|
],
|
|
tooltip: {
|
|
theme: mode === "dark" ? "dark" : "light",
|
|
},
|
|
grid: getGridConfig(),
|
|
plotOptions: {
|
|
bar: {
|
|
horizontal: true,
|
|
},
|
|
},
|
|
|
|
xaxis: {
|
|
axisBorder: {
|
|
show: false,
|
|
},
|
|
axisTicks: {
|
|
show: false,
|
|
},
|
|
labels: getLabel(mode === 'light' ? colors["default-600"] : colors["default-300"]),
|
|
},
|
|
yaxis: getYAxisConfig(
|
|
mode === 'light' ? colors["default-600"] : colors["default-300"]
|
|
),
|
|
legend: {
|
|
labels: {
|
|
colors: mode === 'light' ? colors["default-600"] : colors["default-300"],
|
|
},
|
|
itemMargin: {
|
|
horizontal: 5,
|
|
vertical: 5,
|
|
},
|
|
markers: {
|
|
width: 10,
|
|
height: 10,
|
|
radius: 10,
|
|
offsetX: config.isRtl ? 5 : -5
|
|
}
|
|
},
|
|
padding: {
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
}
|
|
};
|
|
return (
|
|
<Chart
|
|
options={options}
|
|
series={series}
|
|
type="bubble"
|
|
height={height}
|
|
width={"100%"}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default BasicBubble;
|