-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/f 155 charts download button should be available on minimized (…
…#121) * feat: chart download button to own componentn - and added button to LineChart component * fix: added colors to LineChartOperations as hex - fixing the chart png and svg download * fix: using tailwind-util.getTailwindColor to use nextui colors for highcharts options - fixes the chart export color problem --------- Co-authored-by: Bohdan Garchu <[email protected]>
- Loading branch information
1 parent
d88d7b1
commit 9249760
Showing
10 changed files
with
166 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Button } from '@nextui-org/button'; | ||
import { Popover, PopoverContent, PopoverTrigger } from '@nextui-org/popover'; | ||
import { DocumentDownload, GalleryImport } from 'iconsax-react'; | ||
|
||
import { Tooltip } from '@/components/Tooltip/Tooltip'; | ||
import { LineChartDownloadButtonProps } from '@/domain/props/LineChartProps'; | ||
import LineChartOperations from '@/operations/charts/LineChartOperations.ts'; | ||
|
||
/** | ||
* This component is tied to the `LineChart` and `LineChartModal` component | ||
* and should not be used independently. | ||
* It renders a button to open a dropdown menu to download the chart as csv, png, etc. | ||
*/ | ||
export default function LineChartDownloadButton({ chartRef, lineChartData }: LineChartDownloadButtonProps) { | ||
return ( | ||
<Popover placement="bottom" offset={10} backdrop="opaque"> | ||
<PopoverTrigger> | ||
<Button isIconOnly variant="light" size="sm"> | ||
<Tooltip text="Export Chart / Data"> | ||
<DocumentDownload className="h-4 w-4" /> | ||
</Tooltip> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-fit h-fit p-2 flex flex-col gap-1 items-start"> | ||
<Button | ||
variant="light" | ||
size="sm" | ||
className="w-full justify-start" | ||
onPress={() => { | ||
if (chartRef.current) LineChartOperations.downloadChartPNG(chartRef.current); | ||
}} | ||
startContent={<GalleryImport className="h-4 w-4" />} | ||
> | ||
Chart as PNG | ||
</Button> | ||
<Button | ||
variant="light" | ||
size="sm" | ||
className="w-full justify-start" | ||
onPress={() => { | ||
if (chartRef.current) LineChartOperations.downloadChartDataSVG(chartRef.current); | ||
}} | ||
startContent={<GalleryImport className="h-4 w-4" />} | ||
> | ||
Chart as SVG | ||
</Button> | ||
<Button | ||
variant="light" | ||
size="sm" | ||
className="w-full justify-start" | ||
onPress={() => { | ||
if (chartRef.current) LineChartOperations.downloadChartDataCSV(chartRef.current); | ||
}} | ||
startContent={<DocumentDownload className="h-4 w-4" />} | ||
> | ||
Data as CSV | ||
</Button> | ||
<Button | ||
variant="light" | ||
size="sm" | ||
className="w-full justify-start" | ||
onPress={() => { | ||
LineChartOperations.downloadDataJSON(lineChartData); | ||
}} | ||
startContent={<DocumentDownload className="h-4 w-4" />} | ||
> | ||
Data as JSON | ||
</Button> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.