ChartsPanel.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import { Card, Tabs, TabPane } from '@douyinfe/semi-ui';
  17. import { PieChart } from 'lucide-react';
  18. import { VChart } from '@visactor/react-vchart';
  19. const ChartsPanel = ({
  20. activeChartTab,
  21. setActiveChartTab,
  22. spec_line,
  23. spec_model_line,
  24. spec_pie,
  25. spec_rank_bar,
  26. CARD_PROPS,
  27. CHART_CONFIG,
  28. FLEX_CENTER_GAP2,
  29. hasApiInfoPanel,
  30. t,
  31. }) => {
  32. return (
  33. <Card
  34. {...CARD_PROPS}
  35. className={`!rounded-2xl ${hasApiInfoPanel ? 'lg:col-span-3' : ''}`}
  36. title={
  37. <div className='flex flex-col lg:flex-row lg:items-center lg:justify-between w-full gap-3'>
  38. <div className={FLEX_CENTER_GAP2}>
  39. <PieChart size={16} />
  40. {t('模型数据分析')}
  41. </div>
  42. <Tabs
  43. type='slash'
  44. activeKey={activeChartTab}
  45. onChange={setActiveChartTab}
  46. >
  47. <TabPane tab={<span>{t('消耗分布')}</span>} itemKey='1' />
  48. <TabPane tab={<span>{t('消耗趋势')}</span>} itemKey='2' />
  49. <TabPane tab={<span>{t('调用次数分布')}</span>} itemKey='3' />
  50. <TabPane tab={<span>{t('调用次数排行')}</span>} itemKey='4' />
  51. </Tabs>
  52. </div>
  53. }
  54. bodyStyle={{ padding: 0 }}
  55. >
  56. <div className='h-96 p-2'>
  57. {activeChartTab === '1' && (
  58. <VChart spec={spec_line} option={CHART_CONFIG} />
  59. )}
  60. {activeChartTab === '2' && (
  61. <VChart spec={spec_model_line} option={CHART_CONFIG} />
  62. )}
  63. {activeChartTab === '3' && (
  64. <VChart spec={spec_pie} option={CHART_CONFIG} />
  65. )}
  66. {activeChartTab === '4' && (
  67. <VChart spec={spec_rank_bar} option={CHART_CONFIG} />
  68. )}
  69. </div>
  70. </Card>
  71. );
  72. };
  73. export default ChartsPanel;