Skip to content

An open source alternative to Tableau. Embeddable visual analytic

feat: add pagination for table (#208)

Observed Observer49b01a014737
diff --git a/packages/graphic-walker/src/App.tsx b/packages/graphic-walker/src/App.tsx
index 89fcd256..2268132b 100644
--- a/packages/graphic-walker/src/App.tsx
+++ b/packages/graphic-walker/src/App.tsx
@@ -1,7 +1,18 @@
import React, { useEffect, useMemo, useRef, useCallback } from 'react';
import { observer } from 'mobx-react-lite';
import { useTranslation } from 'react-i18next';
-import { IGeographicData, IComputationFunction, ISegmentKey, IThemeKey, IMutField, IGeoDataItem, VegaGlobalConfig, IChannelScales, Specification, IDarkMode } from './interfaces';
+import {
+ IGeographicData,
+ IComputationFunction,
+ ISegmentKey,
+ IThemeKey,
+ IMutField,
+ IGeoDataItem,
+ VegaGlobalConfig,
+ IChannelScales,
+ Specification,
+ IDarkMode,
+} from './interfaces';
import type { IReactVegaHandler } from './vis/react-vega';
import VisualSettings from './visualSettings';
import PosFields from './fields/posFields';
@@ -75,7 +86,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
geographicData,
computationTimeout = 60000,
spec,
- onError
+ onError,
} = props;
const { t, i18n } = useTranslation();
@@ -109,7 +120,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
const rendererRef = useRef<IReactVegaHandler>(null);
- const downloadCSVRef = useRef<{ download: () => void }>({download() {}});
+ const downloadCSVRef = useRef<{ download: () => void }>({ download() {} });
const reportError = useCallback(
(msg: string, code?: number) => {
@@ -126,10 +137,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
const { segmentKey, vizEmbededMenu } = vizStore;
const wrappedComputation = useMemo(
- () =>
- computation
- ? withErrorReport(withTimeout(computation, computationTimeout), (err) => reportError(parseErrorMessage(err), 501))
- : async () => [],
+ () => (computation ? withErrorReport(withTimeout(computation, computationTimeout), (err) => reportError(parseErrorMessage(err), 501)) : async () => []),
[reportError, computation, computationTimeout]
);
return (
@@ -141,8 +149,13 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
{props.dataSelection}
<div className="px-2 mx-2">
<SegmentNav />
- {segmentKey === ISegmentKey.vis && <VisNav />}
</div>
+ {segmentKey === ISegmentKey.vis && (
+ <div className="px-2 mx-2 mt-2">
+ <VisNav />
+ </div>
+ )}
+
{segmentKey === ISegmentKey.vis && (
<div style={{ marginTop: '0em', borderTop: 'none' }} className="m-4 p-4 border border-gray-200 dark:border-gray-700">
{enhanceAPI?.features?.askviz && (
@@ -152,7 +165,8 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
/>
)}
<VisualSettings
- csvHandler={downloadCSVRef} rendererHandler={rendererRef}
+ csvHandler={downloadCSVRef}
+ rendererHandler={rendererRef}
darkModePreference={darkMode}
exclude={toolbar?.exclude}
extra={toolbar?.extra}
@@ -187,7 +201,8 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
}}
>
{computation && (
- <ReactiveRenderer csvRef={downloadCSVRef}
+ <ReactiveRenderer
+ csvRef={downloadCSVRef}
ref={rendererRef}
themeKey={themeKey}
dark={darkMode}
@@ -203,7 +218,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
</div>
)}
{segmentKey === ISegmentKey.data && (
- <div className="m-4 p-4 border border-gray-200 dark:border-gray-700" style={{ marginTop: '0em', borderTop: 'none' }}>
+ <div className="mx-4 p-4 border border-gray-200 dark:border-gray-700" style={{ marginTop: '0em', borderTop: 'none' }}>
<DatasetConfig />
</div>
)}
diff --git a/packages/graphic-walker/src/components/dataTable/index.tsx b/packages/graphic-walker/src/components/dataTable/index.tsx
index aefde4a0..9a72affd 100644
--- a/packages/graphic-walker/src/components/dataTable/index.tsx
+++ b/packages/graphic-walker/src/components/dataTable/index.tsx
@@ -1,13 +1,13 @@
import React, { useMemo, useState, useRef, useEffect } from 'react';
import styled from 'styled-components';
import { observer } from 'mobx-react-lite';
-import type { IMutField, IRow, DataSet, IComputationFunction } from '../../interfaces';
+import type { IMutField, IRow, IComputationFunction } from '../../interfaces';
import { useTranslation } from 'react-i18next';
-import LoadingLayer from "../loadingLayer";
-import { dataReadRaw } from "../../computation";
+import LoadingLayer from '../loadingLayer';
+import { dataReadRaw } from '../../computation';
import Pagination from './pagination';
-import { ChevronUpDownIcon } from '@heroicons/react/24/outline';
import DropdownContext from '../dropdownContext';
+import DataTypeIcon from '../dataTypeIcon';
interface DataTableProps {
/** page limit */
@@ -22,7 +22,6 @@ interface DataTableProps {
const Container = styled.div`
overflow-x: auto;
max-height: 660px;
- overflow-y: auto;
table {
box-sizing: content-box;
border-collapse: collapse;
@@ -39,7 +38,7 @@ const Container = styled.div`
}
}
`;
-const ANALYTIC_TYPE_LIST = ['dimension', 'measure'];
+// const ANALYTIC_TYPE_LIST = ['dimension', 'measure'];
const SEMANTIC_TYPE_LIST = ['nominal', 'ordinal', 'quantitative', 'temporal'];
// function getCellType(field: IMutField): 'number' | 'text' {
// return field.dataType === 'number' || field.dataType === 'integer' ? 'number' : 'text';
@@ -49,7 +48,7 @@ function getHeaderType(field: IMutField): 'number' | 'text' {
}
function getHeaderClassNames(field: IMutField) {
- return field.analyticType === 'dimension' ? 'border-t-4 border-blue-400' : 'border-t-4 border-purple-400';
+ return field.analyticType === 'dimension' ? 'border-t-2 border-blue-400' : 'border-t-2 border-purple-400';
}
function getSemanticColors(field: IMutField): string {
@@ -122,13 +121,6 @@ const DataTable: React.FC<DataTableProps> = (props) => {
const { t } = useTranslation();
const computationFunction = computation;
- const analyticTypeList = useMemo<{ value: string; label: string }[]>(() => {
- return ANALYTIC_TYPE_LIST.map((at) => ({
- value: at,
- label: t(`constant.analytic_type.${at}`),
- }));
- }, []);
-
const semanticTypeList = useMemo<{ value: string; label: string }[]>(() => {
return SEMANTIC_TYPE_LIST.map((st) => ({
value: st,
@@ -146,18 +138,20 @@ const DataTable: React.FC<DataTableProps> = (props) => {
useEffect(() => {
setDataLoading(true);
const taskId = ++taskIdRef.current;
- dataReadRaw(computationFunction, size, pageIndex).then(data => {
- if (taskId === taskIdRef.current) {
- setDataLoading(false);
- setRows(data);
- }
- }).catch(err => {
- if (taskId === taskIdRef.current) {
- console.error(err);
- setDataLoading(false);
- setRows([]);
- }
- });
+ dataReadRaw(computationFunction, size, pageIndex)
+ .then((data) => {
+ if (taskId === taskIdRef.current) {
+ setDataLoading(false);
+ setRows(data);
+ }
+ })
+ .catch((err) => {
+ if (taskId === taskIdRef.current) {
+ console.error(err);
+ setDataLoading(false);
+ setRows([]);
+ }
+ });
return () => {
taskIdRef.current++;
};
@@ -168,122 +162,108 @@ const DataTable: React.FC<DataTableProps> = (props) => {
const headers = useMemo(() => getHeaders(metas), [metas]);
return (
- <Container className="rounded border-gray-200 dark:border-gray-700 border relative">
- <Pagination
- total={total}
- from={from + 1}
- to={to + 1}
- onNext={() => {
- setPageIndex(Math.min(Math.ceil(total / size) - 1, pageIndex + 1));
- }}
- onPrev={() => {
- setPageIndex(Math.max(0, pageIndex - 1));
- }}
- />
- <table className="min-w-full divide-y">
- <thead className="bg-gray-50 dark:bg-gray-900">
- {headers.map((row) => (
- <tr
- className="divide-x divide-gray-200 dark:divide-gray-700"
- key={`row_${getHeaderKey(row[0])}`}
- >
- {row.map((f) => (
- <th
- colSpan={f.colSpan}
- rowSpan={f.rowSpan}
- key={getHeaderKey(f)}
- className={'align-top'}
- >
- {f.type === 'name' && (
- <div
- className={
- 'border-t-4 border-yellow-400 whitespace-nowrap py-3.5 text-left text-xs font-semibold text-gray-900 dark:text-gray-50'
- }
- >
- <b className="sticky inset-x-0 w-fit px-6 sm:pl-6">{f.value}</b>
- </div>
- )}
- {f.type === 'field' && (
- <div
- className={
- getHeaderClassNames(f.value) +
- ' whitespace-nowrap py-3.5 px-6 text-left text-xs font-semibold text-gray-900 dark:text-gray-50 sm:pl-6'
- }
- >
- <b>{f.value.basename || f.value.name || f.value.fid}</b>
- <div>
- <DropdownContext
- options={analyticTypeList}
- onSelect={(value) => {
- onMetaChange(f.value.fid, f.fIndex, {
- analyticType: value as IMutField['analyticType'],
- });
- }}
+ <Container className="relative">
+ <nav
+ className="flex items-center justify-between bg-white dark:bg-zinc-900 p-2"
+ aria-label="Pagination"
+ >
+ <div className="hidden sm:block">
+ <p className="text-sm text-gray-800 dark:text-gray-100">
+ Showing <span className="font-medium">{from + 1}</span> to <span className="font-medium">{to + 1}</span> of{' '}
+ <span className="font-medium">{total}</span> results
+ </p>
+ </div>
+ <Pagination
+ total={total}
+ pageIndex={pageIndex}
+ onNext={() => {
+ setPageIndex(Math.min(Math.ceil(total / size) - 1, pageIndex + 1));
+ }}
+ onPrev={() => {
+ setPageIndex(Math.max(0, pageIndex - 1));
+ }}
+ onPageChange={(index) => {
+ setPageIndex(Math.max(0, Math.min(Math.ceil(total / size) - 1, index)));
+ }}
+ />
+ </nav>
+
+ <div className="overflow-y-auto" style={{ maxHeight: '600px' }}>
+ <table className="min-w-full divide-y relative border-x border-gray-200 dark:border-gray-700">
+ <thead className="">
+ {headers.map((row) => (
+ <tr className="divide-x divide-gray-200 dark:divide-gray-700" key={`row_${getHeaderKey(row[0])}`}>
+ {row.map((f) => (
+ <th
+ colSpan={f.colSpan}
+ rowSpan={f.rowSpan}
+ key={getHeaderKey(f)}
+ className="align-top sticky top-0 bg-white dark:bg-zinc-900"
+ // style={{ zIndex: -100 }}
+ >
+ <div className="border-b border-gray-200 dark:border-gray-700">
+ {f.type === 'name' && (
+ <div
+ className={
+ 'border-t-4 border-yellow-400 whitespace-nowrap py-3.5 text-left text-xs font-medium text-gray-900 dark:text-gray-50'
+ }
>
- <span
- className={
- 'cursor-pointer inline-flex px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full text-white ' +
- (f.value.analyticType === 'dimension'
- ? 'bg-blue-500'
- : 'bg-purple-500')
- }
- >
- {f.value.analyticType}
- <ChevronUpDownIcon className="ml-2 w-3" />
- </span>
- </DropdownContext>
- </div>
- <div>
- <DropdownContext
- options={semanticTypeList}
- onSelect={(value) => {
- onMetaChange(f.value.fid, f.fIndex, {
- semanticType: value as IMutField['semanticType'],
- });
- }}
+ <b className="sticky inset-x-0 w-fit px-4 sm:pl-6">{f.value}</b>
+ </div>
+ )}
+ {f.type === 'field' && (
+ <div
+ className={
+ getHeaderClassNames(f.value) +
+ ' whitespace-nowrap py-3.5 px-4 text-left text-xs font-medium text-gray-900 dark:text-gray-50 flex items-center gap-1'
+ }
>
- <span
- className={
- 'cursor-pointer inline-flex px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full ' +
- getSemanticColors(f.value)
- }
- >
- {f.value.semanticType}
- <ChevronUpDownIcon className="ml-2 w-3" />
- </span>
- </DropdownContext>
- </div>
+ <div className="font-normal inline-block">
+ <DropdownContext
+ position="right-0"
+ options={semanticTypeList}
+ onSelect={(value) => {
+ onMetaChange(f.value.fid, f.fIndex, {
+ semanticType: value as IMutField['semanticType'],
+ });
+ }}
+ >
+ <span
+ className={
+ 'cursor-pointer inline-flex p-0.5 text-xs mt-1 rounded hover:scale-125 ' +
+ getSemanticColors(f.value)
+ }
+ >
+ <DataTypeIcon dataType={f.value.semanticType} analyticType={f.value.analyticType} />
+ </span>
+ </DropdownContext>
+ </div>
+ <b className="inline-block">{f.value.basename || f.value.name || f.value.fid}</b>
+ </div>
+ )}
</div>
- )}
- </th>
- ))}
- </tr>
- ))}
- </thead>
- <tbody className="divide-y divide-gray-100 dark:divide-gray-700 bg-white dark:bg-zinc-900">
- {rows.map((row, index) => (
- <tr
- className={
- 'divide-x divide-gray-200 dark:divide-gray-700 ' +
- (index % 2 ? 'bg-gray-50 dark:bg-gray-900' : '')
- }
- key={index}
- >
- {metas.map((field) => (
- <td
- key={field.fid + index}
- className={
- getHeaderType(field) +
- ' whitespace-nowrap py-2 pl-4 pr-3 text-xs text-gray-500 dark:text-gray-300 sm:pl-6'
- }
- >
- {`${row[field.fid]}`}
- </td>
- ))}
- </tr>
- ))}
- </tbody>
- </table>
+ </th>
+ ))}
+ </tr>
+ ))}
+ </thead>
+ <tbody className="divide-y divide-gray-100 dark:divide-gray-700 bg-white dark:bg-zinc-900 font-mono">
+ {rows.map((row, index) => (
+ <tr className="divide-x divide-gray-200 dark:divide-gray-700" key={index}>
+ {metas.map((field) => (
+ <td
+ key={field.fid + index}
+ className={getHeaderType(field) + ' whitespace-nowrap py-2 px-4 text-xs text-gray-500 dark:text-gray-300'}
+ >
+ {`${row[field.fid]}`}
+ </td>
+ ))}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+
{loading && <LoadingLayer />}
</Container>
);
diff --git a/packages/graphic-walker/src/components/dataTable/pagination.tsx b/packages/graphic-walker/src/components/dataTable/pagination.tsx
index 4431ecf6..dfd4c809 100644
--- a/packages/graphic-walker/src/components/dataTable/pagination.tsx
+++ b/packages/graphic-walker/src/components/dataTable/pagination.tsx
@@ -1,44 +1,112 @@
-import React from 'react';
+import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+
+type IPageItem = {
+ index: number;
+ disabled?: boolean;
+ type: 'page' | 'placeholder';
+};
interface PaginationProps {
- from: number;
- to: number;
total: number;
onPrev: () => void;
onNext: () => void;
+ onPageChange?: (index: number) => void;
+ pageIndex: number;
+ pageSize?: number;
+ extendPageNumber?: number;
+}
+function btnStylePrefix(className?: string) {
+ return `rounded-md border border-gray-300 bg-white dark:bg-zinc-900 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800 ${className}`;
}
export default function Pagination(props: PaginationProps) {
- const { from , to, total, onNext, onPrev } = props;
+ const { total, onNext, onPrev, pageIndex, onPageChange, pageSize = 100, extendPageNumber = 1 } = props;
const { t } = useTranslation();
- return (
- <nav
- className="sticky inset-x-0 flex items-center justify-between border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-zinc-900 px-4 py-3 sm:px-6"
- aria-label="Pagination"
- >
- <div className="hidden sm:block">
- <p className="text-sm text-gray-800 dark:text-gray-100">
- Showing <span className="font-medium">{from}</span> to <span className="font-medium">{to}</span> of{" "}
- <span className="font-medium">{total}</span> results
- </p>
- </div>
- <div className="flex flex-1 justify-between sm:justify-end">
+ const showIndices: IPageItem[] = useMemo<IPageItem[]>(() => {
+ const totalPage = Math.ceil(total / (pageSize ?? 1));
+ const pages = [
+ {
+ index: 0,
+ disabled: false,
+ type: 'page',
+ },
+ ...(new Array(1 + extendPageNumber * 2).fill(0).map((p, i) => ({
+ index: pageIndex - (extendPageNumber - i),
+ disabled: false,
+ type: 'page',
+ })) as IPageItem[]),
+ {
+ index: totalPage - 1,
+ disabled: false,
+ type: 'page',
+ },
+ ].filter((p) => p.index >= 0 && p.index < totalPage) as IPageItem[];
+ const pagesUnique: IPageItem[] = [];
+ const indexSet: Set<number> = new Set();
+ for (let p of pages) {
+ if (!indexSet.has(p.index)) {
+ pagesUnique.push(p);
+ indexSet.add(p.index);
+ }
+ }
+ return pagesUnique;
+ }, [pageIndex, pageSize, extendPageNumber, total, pageIndex]);
+ return showIndices.length > 0 ? (
+ <div className="flex flex-1 justify-between sm:justify-end gap-2">
+ <button
+ onClick={() => {
+ onPrev();
+ }}
+ className="relative inline-flex items-center rounded-md border border-gray-300 bg-white dark:bg-zinc-900 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800"
+ >
+ {t('actions.prev')}
+ </button>
+ <button
+ className={btnStylePrefix('inline-block')}
+ onClick={() => {
+ onPageChange && onPageChange(showIndices[0].index);
+ }}
+ >
+ {showIndices[0].index + 1}
+ </button>
+ {showIndices.length > 2 && showIndices[1].index > showIndices[0].index + 1 && (
+ <div className={btnStylePrefix('inline-block')} aria-hidden>
+ ...
+ </div>
+ )}
+ {showIndices.slice(1, -1).map((page) => (
<button
+ key={page.index}
+ className={btnStylePrefix('inline-block')}
onClick={() => {
- onPrev();
+ onPageChange && onPageChange(page.index);
}}
- className="relative inline-flex items-center rounded-md border border-gray-300 bg-white dark:bg-zinc-900 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800"
>
- {t('actions.prev')}
+ {page.index + 1}
</button>
+ ))}
+ {showIndices.length > 2 && showIndices[showIndices.length - 1].index > showIndices[showIndices.length - 2].index + 1 && (
+ <div className={btnStylePrefix('inline-block')} aria-hidden>
+ ...
+ </div>
+ )}
+ {showIndices.length > 2 && (
<button
+ className={btnStylePrefix('inline-block')}
onClick={() => {
- onNext()
+ onPageChange && onPageChange(showIndices[showIndices.length - 1].index);
}}
- className="relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white dark:bg-zinc-900 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800"
>
- {t('actions.next')}
+ {showIndices[showIndices.length - 1].index + 1}
</button>
- </div>
- </nav>
- );
+ )}
+ <button
+ onClick={() => {
+ onNext();
+ }}
+ className="relative inline-flex items-center rounded-md border border-gray-300 bg-white dark:bg-zinc-900 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800"
+ >
+ {t('actions.next')}
+ </button>
+ </div>
+ ) : null;
}
diff --git a/packages/graphic-walker/src/components/dataTypeIcon.tsx b/packages/graphic-walker/src/components/dataTypeIcon.tsx
index 183f4887..d96fbf39 100644
--- a/packages/graphic-walker/src/components/dataTypeIcon.tsx
+++ b/packages/graphic-walker/src/components/dataTypeIcon.tsx
@@ -6,8 +6,8 @@ const DataTypeIcon: React.FC<{ dataType: IMutField["semanticType"]; analyticType
props
) => {
const { dataType, analyticType } = props;
- const color = analyticType === "dimension" ? "text-blue-500" : "text-purple-500";
- const iconClassName = `w-3 inline-block mr-0.5 ${color}`;
+ const color = analyticType === "dimension" ? "text-blue-500 dark:text-blue-400" : "text-purple-500 dark:text-purple-400";
+ const iconClassName = `w-3 inline-block ${color}`;
switch (dataType) {
case "quantitative":
case "ordinal":
diff --git a/packages/graphic-walker/src/components/dropdownContext/index.tsx b/packages/graphic-walker/src/components/dropdownContext/index.tsx
index 89fc4ba8..19426ac0 100644
--- a/packages/graphic-walker/src/components/dropdownContext/index.tsx
+++ b/packages/graphic-walker/src/components/dropdownContext/index.tsx
@@ -14,9 +14,11 @@ interface IDropdownContextProps {
options?: IDropdownContextOption[];
disable?: boolean;
onSelect?: (value: string, index: number) => void;
+ // left-0 right-0
+ position?: string;
}
const DropdownContext: React.FC<IDropdownContextProps> = (props) => {
- const { options = [], disable } = props;
+ const { options = [], disable, position = 'left-0' } = props;
if (disable) {
return <Fragment>{props.children}</Fragment>;
@@ -35,7 +37,7 @@ const DropdownContext: React.FC<IDropdownContextProps> = (props) => {
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
- <Menu.Items className="absolute left-0 z-50 mt-2 w-56 origin-top-right rounded-md bg-white dark:bg-zinc-900 shadow-lg border border-gray-50 dark:border-gray-800 ring-1 ring-black ring-opacity-5 focus:outline-none">
+ <Menu.Items className={`absolute ${position} z-50 mt-2 w-56 origin-top-right rounded-md bg-white dark:bg-zinc-900 shadow-lg border border-gray-50 dark:border-gray-800 ring-1 ring-black ring-opacity-5 focus:outline-none`}>
<div className="py-1">
{options.map((option, index) => (
<Menu.Item key={option.value}>
diff --git a/packages/graphic-walker/src/components/tabs/defaultTab.tsx b/packages/graphic-walker/src/components/tabs/defaultTab.tsx
index 66dada51..fbbe65b5 100644
--- a/packages/graphic-walker/src/components/tabs/defaultTab.tsx
+++ b/packages/graphic-walker/src/components/tabs/defaultTab.tsx
@@ -20,7 +20,7 @@ export default function Default(props: DefaultProps) {
const { tabs, selectedKey, onSelected } = props;
return (
- <div className="border-b border-gray-200 dark:border-gray-700 mb-2" >
+ <div className="border-b border-gray-200 dark:border-gray-700" >
<nav className="-mb-px flex space-x-8" role="tablist" aria-label="Tabs">
{tabs.map((tab, tabIndex) => (
<span
diff --git a/packages/graphic-walker/src/dataSource/table.tsx b/packages/graphic-walker/src/dataSource/table.tsx
index 5ce17592..6699275d 100644
--- a/packages/graphic-walker/src/dataSource/table.tsx
+++ b/packages/graphic-walker/src/dataSource/table.tsx
@@ -1,9 +1,9 @@
-import React from "react";
-import { observer } from "mobx-react-lite";
-import { useGlobalStore } from "../store";
-import DataTable from "../components/dataTable";
-import { toJS } from "mobx";
-import { getComputation } from "../computation/clientComputation";
+import React from 'react';
+import { observer } from 'mobx-react-lite';
+import { useGlobalStore } from '../store';
+import DataTable from '../components/dataTable';
+import { toJS } from 'mobx';
+import { getComputation } from '../computation/clientComputation';
interface TableProps {
size?: number;
@@ -14,20 +14,22 @@ const Table: React.FC<TableProps> = (props) => {
const commonStore = useGlobalStore();
const { tmpDSRawFields, tmpDataSource } = commonStore;
- const metas = React.useMemo(() => toJS(tmpDSRawFields), [ tmpDSRawFields]);
+ const metas = React.useMemo(() => toJS(tmpDSRawFields), [tmpDSRawFields]);
- const computation = React.useMemo(() => getComputation(tmpDataSource), [tmpDataSource])
+ const computation = React.useMemo(() => getComputation(tmpDataSource), [tmpDataSource]);
return (
- <DataTable
- size={size}
- metas={metas}
- computation={computation}
- total={tmpDataSource.length}
- onMetaChange={(fid, fIndex, diffMeta) => {
- commonStore.updateTempDatasetMetas(fid, diffMeta);
- }}
- />
+ <div className="rounded border-gray-200 dark:border-gray-700 border">
+ <DataTable
+ size={size}
+ metas={metas}
+ computation={computation}
+ total={tmpDataSource.length}
+ onMetaChange={(fid, fIndex, diffMeta) => {
+ commonStore.updateTempDatasetMetas(fid, diffMeta);
+ }}
+ />
+ </div>
);
};
diff --git a/packages/graphic-walker/src/fields/datasetFields/dimFields.tsx b/packages/graphic-walker/src/fields/datasetFields/dimFields.tsx
index 5460c64c..b0e5047b 100644
--- a/packages/graphic-walker/src/fields/datasetFields/dimFields.tsx
+++ b/packages/graphic-walker/src/fields/datasetFields/dimFields.tsx
@@ -38,7 +38,7 @@ const DimFields: React.FC<Props> = (props) => {
{...provided.dragHandleProps}
>
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />
- <span>{f.name}</span>
+ <span className="ml-0.5">{f.name}</span>
<ActionMenu.Button as="div">
<EllipsisVerticalIcon className="w-4 h-4" />
</ActionMenu.Button>
@@ -51,7 +51,7 @@ const DimFields: React.FC<Props> = (props) => {
isDragging={snapshot.isDragging}
>
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />
- <span>{f.name}</span>
+ <span className="ml-0.5">{f.name}</span>
<ActionMenu.Button as="div">
<EllipsisVerticalIcon className="w-4 h-4" />
</ActionMenu.Button>
diff --git a/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx b/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx
index 52408b28..d9c83367 100644
--- a/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx
+++ b/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx
@@ -37,7 +37,7 @@ const MeaFields: React.FC<Props> = (props) => {
{...provided.dragHandleProps}
>
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />
- <span>{f.name}</span>
+ <span className="ml-0.5">{f.name}</span>
<ActionMenu.Button as="div">
<EllipsisVerticalIcon className="w-4 h-4" />
</ActionMenu.Button>
@@ -50,7 +50,7 @@ const MeaFields: React.FC<Props> = (props) => {
isDragging={snapshot.isDragging}
>
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />
- <span>{f.name}</span>
+ <span className="ml-0.5">{f.name}</span>
<ActionMenu.Button as="div">
<EllipsisVerticalIcon className="w-4 h-4" />
</ActionMenu.Button>
diff --git a/packages/graphic-walker/src/visualSettings/index.tsx b/packages/graphic-walker/src/visualSettings/index.tsx
index e5eb78e9..a350eb54 100644
--- a/packages/graphic-walker/src/visualSettings/index.tsx
+++ b/packages/graphic-walker/src/visualSettings/index.tsx
@@ -562,7 +562,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
'-',
{
key: 'kanaries',
- label: 'kanaries',
+ label: 'kanaries docs',
icon: () => (
// Kanaries brand info is not allowed to be removed or changed unless you are granted with special permission.
<a href="https://docs.kanaries.net" target="_blank">
@@ -572,7 +572,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
src="https://imagedelivery.net/tSvh1MGEu9IgUanmf58srQ/b6bc899f-a129-4c3a-d08f-d406166d0c00/public"
fallbackSrc={KanariesLogo}
timeout={1000}
- alt="kanaries"
+ alt="kanaries documents"
/>
</a>
),