
'use client'
import React from 'react'
import { LineChart } from '@mui/x-charts/LineChart';
import { useTheme } from "@mui/material";
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'SimpleLineChart ',
},
];
function SimpleLineChart() {
const monthlyProfits = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const monthlyRevenue = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = ["January", "February", "March", "April", "May", "June", "July"];
const theme = useTheme();
const primary = theme.palette.primary.main;
const secondary = theme.palette.secondary.main;
return (
<LineChart
width={500}
height={300}
series={[
{ data: monthlyRevenue, label: 'Revenue', color: primary },
{ data: monthlyProfits, label: 'Profits', color: secondary },
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
/>
)
}
export default SimpleLineChart
'use client';
import React from 'react';
import { useTheme } from '@mui/material';
import { ChartContainer, LinePlot, MarkPlot } from '@mui/x-charts';
const BCrumb = [
{ to: '/', title: 'Home' },
{ title: 'SimpleLineChart' },
];
function SimpleLineChart() {
const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = [
'Page A',
'Page B',
'Page C',
'Page D',
'Page E',
'Page F',
'Page G',
];
const theme = useTheme();
const primary = theme.palette.primary.main;
return (
<ChartContainer
width={500}
height={300}
series={[{ type: 'line', data: pData, color: primary }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
disableAxisListener
>
<LinePlot />
<MarkPlot />
</ChartContainer>
);
}
export default SimpleLineChart;
'use client'
import * as React from 'react';
import {
LineChart,
lineElementClasses,
markElementClasses,
} from '@mui/x-charts/LineChart';
import { useTheme } from "@mui/material";
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'DashedLineChart ',
},
]; export default function DashedLineChart() {
const monthlyProfits = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const monthlyRevenue = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = ["January", "February", "March", "April", "May", "June", "July"];
const theme = useTheme();
const primary = theme.palette.primary.main;
const secondary = theme.palette.secondary.main;
return (
<LineChart
width={500}
height={300}
series={[
{ data: monthlyRevenue, label: "Revenue", id: "pvId", color: primary },
{ data: monthlyProfits, label: "Profits", id: "uvId", color: secondary },
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={`
${`& .${lineElementClasses.root}, .${markElementClasses.root}`}: {
strokeWidth: 1,
},
`.MuiLineElement-series-pvId`: {
strokeDasharray: '5 5',
},
`.MuiLineElement-series-uvId`: {
strokeDasharray: '3 4 5 2',
},
${`& .${markElementClasses.root}:not(.MuiMarkElement-highlighted)`}: {
fill: '#fff',
},
${`& .${markElementClasses.highlighted}`}: {
stroke: 'none',
},
`}
/>
);
}
"use client";
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { useTheme } from "@mui/material";
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'BiaxialLineChart ',
},
];
export default function BiaxialLineChart() {
const monthlyProfits = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const monthlyRevenue = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = ["January", "February", "March", "April", "May", "June", "July"];
const theme = useTheme();
const primary = theme.palette.primary.main;
const secondary = theme.palette.secondary.main;
return (
<LineChart
width={500}
height={300}
series={[
{ data: monthlyRevenue, label: "Revenue", yAxisId: "leftAxisId", color: primary },
{
data: monthlyProfits,
label: "Profits",
yAxisId: "rightAxisId",
color: secondary,
},
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
yAxis={[{ id: 'leftAxisId' }, { id: 'rightAxisId' }]}
/>
);
}
"use client";
import * as React from "react";
import { ChartContainer } from "@mui/x-charts/ChartContainer";
import { ChartsReferenceLine } from "@mui/x-charts/ChartsReferenceLine";
import { LinePlot, MarkPlot } from "@mui/x-charts/LineChart";
import { ChartsXAxis } from "@mui/x-charts/ChartsXAxis";
import { ChartsYAxis } from "@mui/x-charts/ChartsYAxis";
import { useTheme } from "@mui/material";
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'LineChartWithReferenceLines ',
},
];
export default function LineChartWithReferenceLines() {
const monthlyProfits = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const monthlyRevenue = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = ["January", "February", "March", "April", "May", "June", "July"];
const theme = useTheme();
const primary = theme.palette.primary.main;
const secondary = theme.palette.secondary.main;
const Linecolor = theme.palette.warning.main;
return (
<ChartContainer
width={500}
height={300}
series={[
{ data: monthlyRevenue, label: "Revenue", type: "line", color: primary },
{ data: monthlyProfits, label: "Profits", type: "line", color: secondary },
]}
xAxis={[{ scaleType: "point", data: xLabels }]}
>
<LinePlot />
<MarkPlot />
<ChartsReferenceLine
x="March"
label="Max Profits"
lineStyle={{ stroke: Linecolor }}
/>
<ChartsReferenceLine
y={9800}
label="Max"
lineStyle={{ stroke: Linecolor }}
/>
<ChartsXAxis />
<ChartsYAxis />
</ChartContainer>
);
}
'use client'
import * as React from 'react';
import { LineChart, AnimatedLine, AnimatedLineProps } from '@mui/x-charts/LineChart';
import { useChartId, useDrawingArea, useXScale } from '@mui/x-charts/hooks';
import ParentCard from "@/app/components/shared/ParentCard";
import { useTheme } from "@mui/material";
import LinewithforecastCode from '../../code/linechartscode/LinewithforecastCode';
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'LinewithforecastChart ',
},
];
function CustomAnimatedLine(props) {
const { limit, sxBefore, sxAfter, ...other } = props;
const { top, bottom, height, left, width } = useDrawingArea();
const scale = useXScale();
const chartId = useChartId();
if (limit === undefined) {
return <AnimatedLine {...other} />;
}
const limitPosition = scale(limit); // Convert value to x coordinate.
if (limitPosition === undefined) {
return <AnimatedLine {...other} />;
}
const clipIdLeft = `${chartId}-${props.ownerState.id}-line-limit-${limit}-1`;
const clipIdRight = `${chartId}-${props.ownerState.id}-line-limit-${limit}-2`;
return (
<React.Fragment>
{/* Clip to show the line before the limit */}
<clipPath id={clipIdLeft}>
<rect
x={left}
y={0}
width={limitPosition - left}
height={top + height + bottom}
/>
</clipPath>
{/* Clip to show the line after the limit */}
<clipPath id={clipIdRight}>
<rect
x={limitPosition}
y={0}
width={left + width - limitPosition}
height={top + height + bottom}
/>
</clipPath>
<g clipPath={`url(#${clipIdLeft})`}>
<AnimatedLine {...other} sx={sxBefore} />
</g>
<g clipPath={`url(#${clipIdRight})`}>
<AnimatedLine {...other} sx={sxAfter} />
</g>
</React.Fragment>
);
}
export default function LinewithforecastChart() {
const theme = useTheme();
const primary = theme.palette.primary.main;
return (
<LineChart
series={[
{
type: 'line',
data: [1, 2, 3, 4, 1, 2, 3, 4, 5],
valueFormatter: (v, i) => `${v}${i.dataIndex > 5 ? ' (estimated)' : ''}`,
color: primary,
},
]}
xAxis={[{ data: [0, 1, 2, 3, 4, 5, 6, 7, 8] }]}
height={200}
width={400}
slots={{ line: CustomAnimatedLine }}
slotProps={{ line: { limit: 5, sxAfter: { strokeDasharray: '10 5' } } as any }}
/>
);
}