[#812,package][xl]: changed project to Vite, created stories for LineChart, Table, Vega and VegaLite

This commit is contained in:
deme
2023-05-02 16:37:22 -03:00
parent 016f3e20e9
commit ea5802a908
43 changed files with 4299 additions and 6448 deletions

View File

@@ -0,0 +1,21 @@
export default function applyFullWidthDirective({
Component,
defaultWFull = true,
}) {
return (props) => {
const newProps = { ...props };
let newClassName = newProps.className || "";
if (newProps.fullWidth === true) {
newClassName += " w-[90vw] ml-[calc(50%-45vw)] max-w-none";
} else if (defaultWFull) {
// So that charts and tables will have the
// same width as the text content, but images
// can have its width set using the width prop
newClassName += " w-full";
}
newProps.className = newClassName;
return <Component {...newProps} />;
};
}

View File

@@ -1,14 +1,18 @@
import papa from "papaparse";
const parseCsv = (csv) => {
const parseCsv = (csv: string) => {
csv = csv.trim();
const rawdata = papa.parse(csv, { header: true });
const cols = rawdata.meta.fields.map((r, i) => {
return { key: r, name: r };
});
let cols: any[] = [];
if(rawdata.meta.fields) {
cols = rawdata.meta.fields.map((r: string) => {
return { key: r, name: r };
});
}
return {
rows: rawdata.data,
rows: rawdata.data as any,
fields: cols,
};
};