Skip to content

Commit e8f06d7

Browse files
committed
add assam geojson to render maps
1 parent 32035f9 commit e8f06d7

File tree

1 file changed

+17
-4
lines changed
  • app/[locale]/(user)/datasets/[datasetIdentifier]/components/Details

1 file changed

+17
-4
lines changed

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Details/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import React from 'react';
1+
import React, { useRef } from 'react';
22
import Link from 'next/link';
33
import { useParams } from 'next/navigation';
4+
import assam_geojson from '@/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/charts/components/data';
45
import { graphql } from '@/gql';
56
import { useQuery } from '@tanstack/react-query';
7+
import ReactECharts from 'echarts-for-react';
8+
import * as echarts from 'echarts/core';
69
import {
710
Button,
811
Carousel,
@@ -14,12 +17,11 @@ import {
1417
Spinner,
1518
Text,
1619
} from 'opub-ui';
17-
import { BarChart } from 'opub-ui/viz';
1820

1921
import { GraphQL } from '@/lib/api';
2022
import { Icons } from '@/components/icons';
2123

22-
const charts: any = graphql(`
24+
const charts = graphql(`
2325
query chartsData($datasetId: UUID!) {
2426
chartsDetails(datasetId: $datasetId) {
2527
aggregateType
@@ -37,6 +39,7 @@ const charts: any = graphql(`
3739

3840
const Details = () => {
3941
const params = useParams();
42+
const chartRef = useRef<ReactECharts>(null);
4043

4144
const {
4245
data,
@@ -56,6 +59,15 @@ const Details = () => {
5659
)
5760
);
5861

62+
const renderChart = (item: any) => {
63+
if (item.chartType === 'ASSAM_DISTRICT') {
64+
// Register the map
65+
echarts.registerMap('assam_district', assam_geojson);
66+
}
67+
68+
return <ReactECharts option={item.chart} ref={chartRef} />;
69+
};
70+
5971
return (
6072
<div className="mb-8 flex w-full flex-col gap-4 p-2">
6173
{isLoading ? (
@@ -75,7 +87,8 @@ const Details = () => {
7587
<CarouselItem key={index} className="m-auto">
7688
<div className="w-full border-2 border-solid border-baseGraySlateSolid4 bg-surfaceDefault p-6 text-center shadow-basicLg max-sm:p-2">
7789
<div className="lg:p-10">
78-
<BarChart options={item.chart} height={'450px'} />
90+
{renderChart(item)}{' '}
91+
{/* Call the renderChart function */}
7992
</div>
8093
<div className="flex items-center justify-between gap-2 max-sm:flex-wrap">
8194
<div className="flex flex-col gap-1 py-2 text-start">

0 commit comments

Comments
 (0)