How to display the chart python code?
Autore: Josef D.I need to display active charts ( the code is in python). What is the way to display it? Converting it to html is not good. Is there any possibility?
Thank you
Code
importReactfrom'react';import{Card,CardContent,CardHeader,CardTitle}from"@/components/ui/card";import{LineChart,Line,XAxis,YAxis,CartesianGrid,Tooltip,ResponsiveContainer}from'recharts';constInflationChart=()=>{const data =[{ month:'2024-01', rate:3.1},{ month:'2023-12', rate:3.4},{ month:'2023-11', rate:3.1},{ month:'2023-10', rate:3.2},{ month:'2023-09', rate:3.7},{ month:'2023-08', rate:3.7},{ month:'2023-07', rate:3.2},{ month:'2023-06', rate:3.0},{ month:'2023-05', rate:4.0},{ month:'2023-04', rate:4.9},{ month:'2023-03', rate:5.0},{ month:'2023-02', rate:6.0}];return(<CardclassName="w-full max-w-4xl"><CardHeader><CardTitle>Míra inflace USD (v %)</CardTitle></CardHeader><CardContent><divclassName="h-80 w-full"><ResponsiveContainerwidth="100%"height="100%"><LineChartdata={data}margin={{ top:5, right:30, left:20, bottom:5}}><CartesianGridstrokeDasharray="3 3"/><XAxisdataKey="month"tickFormatter={(value)=>{const date =newDate(value);return date.toLocaleDateString('cs-CZ',{ month:'short', year:'2-digit'});}}/><YAxisdomain={[0,'auto']}/><Tooltipformatter={(value)=>[`${value}%`,'Inflace']}labelFormatter={(label)=>{const date =newDate(label);return date.toLocaleDateString('cs-CZ',{ month:'long', year:'numeric'});}}/><Linetype="monotone"dataKey="rate"stroke="#2563eb"strokeWidth={2}dot={{ fill:'#2563eb'}}/></LineChart></ResponsiveContainer></div></CardContent></Card>);};exportdefaultInflationChart;
Hello josef
now you can add python code into htmlpage by using pyscript tool
https://korben.info/code-python-dans-html.html
never tested from my side
hope this helps
Axel