1import{r as o,J as P,j as e,x as $,H as S,B as W,y as X,ab as H,ac as Y,ad as _,af as G,ae as K,ag as N,ah as U,ai as V,ba as J,a9 as M,a1 as q}from"./index-BACUqBz4.js";import{D as Q,a as Z}from"./DateRangePicker-B4UuHqRU.js";import{E as ee,D as te}from"./EmptyState-Bfv-WZ-b.js";import{E as ae}from"./ExportMenu-D8Z6Rm_7.js";import{O as se}from"./OpenInAskYourData-wBi-dzNc.js";import{P as re}from"./PinToDashboard-DnNSHhVa.js";import{S as oe}from"./SuggestedChartType-B3teiSU0.js";import{n as ne,f as ie,g as le,d as de,b as ce}from"./series-6vDvXsE1.js";import{L as he}from"./LineChart-BbW1TiXi.js";import"./EmptyState-CRi2jFBw.js";const u=["#e91e8c","#06b6d4","#10b981","#f59e0b","#8b5cf6"];function Se(){const[C,k]=o.useState([]),[c,R]=o.useState(""),[d,B]=o.useState([]),[h,w]=o.useState([]),[r,D]=o.useState(""),[n,p]=o.useState([""]),[x,L]=o.useState(!0),[g,E]=o.useState(!1),[s,m]=o.useState(null),[f,v]=o.useState(null),j=o.useRef(null);o.useEffect(()=>{P.list().then(t=>k(t.data||[])).catch(()=>{})},[]);function I(t){R(t),m(null),v(null),t&&q.preview(t).then(a=>{B(a.data.headers||[]),w(a.data.rows||[])}).catch(()=>{})}function z(){if(!r||!n.filter(Boolean).length||!h.length)return;const t=n.filter(Boolean),a=Z(h,f);if(!a.length){m(null);return}const{data:i}=le(a,r,t,"sum"),l=i.map(y=>{const b={x:y.name};return t.forEach((F,O)=>{b[F]=y["v"+O]}),b}),T=de(a,d);m({data:l,active:t,rangeLabel:ce(a,T)})}const A=ne(h,d);return e.jsxs($,{children:[e.jsx(S,{title:e.jsxs(e.Fragment,{children:["Line ",e.jsx(S.Accent,{children:"Chart"})]}),description:"Visualize trends over time with multi-series line charts"}),e.jsxs("div",{style:{background:"var(--bg-raised)",borderRadius:12,padding:20,boxShadow:"var(--elev-1)",marginBottom:24},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--fg-secondary)",marginBottom:5},children:"File"}),e.jsxs("select",{value:c,onChange:t=>I(t.target.value),style:{width:"100%",padding:"9px 12px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.9rem"},children:[e.jsx("option",{value:"",children:"-- Choose --"}),C.map(t=>e.jsx("option",{value:t.id,children:t.filename},t.id))]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--fg-secondary)",marginBottom:5},children:"X Axis (Label/Date)"}),e.jsxs("select",{value:r,onChange:t=>D(t.target.value),style:{width:"100%",padding:"9px 12px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.9rem"},children:[e.jsx("option",{value:"",children:"-- Column --"}),d.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--fg-secondary)",marginBottom:8},children:"Y Axis Series (up to 5)"}),n.map((t,a)=>e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,alignItems:"center"},children:[e.jsx("div",{style:{width:12,height:12,borderRadius:3,background:u[a%u.length]}}),e.jsxs("select",{value:t,onChange:i=>{const l=[...n];l[a]=i.target.value,p(l)},style:{flex:1,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:6,fontSize:"0.85rem"},children:[e.jsxs("option",{value:"",children:["-- Series ",a+1," --"]}),A.map(i=>e.jsx("option",{value:i,children:i},i))]}),n.length>1&&e.jsx("button",{onClick:()=>p(n.filter((i,l)=>l!==a)),style:{padding:"8px 10px",background:"#fee2e2",color:"#ef4444",border:"none",borderRadius:6,cursor:"pointer"},children:"â"})]},a)),n.length<5&&e.jsx("button",{onClick:()=>p([...n,""]),style:{padding:"6px 14px",background:"var(--bg-sunken)",color:"var(--fg-secondary)",border:"none",borderRadius:6,cursor:"pointer",fontSize:"0.85rem"},children:"+ Add Series"})]}),e.jsxs("div",{style:{display:"flex",gap:16,marginBottom:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:t=>L(t.target.checked)}),e.jsx("span",{style:{fontSize:"0.875rem"},children:"Smooth curves"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:g,onChange:t=>E(t.target.checked)}),e.jsx("span",{style:{fontSize:"0.875rem"},children:"Show data points"})]})]}),d.length>0&&e.jsx("div",{style:{marginBottom:14},children:e.jsx(Q,{columns:d,value:f,onChange:v,storageKey:"line-chart.dateRange"})}),r&&n.find(Boolean)&&e.jsx("div",{style:{marginBottom:12},children:e.jsx(oe,{rows:h,xCol:r,yCol:n.find(Boolean),currentTool:"line",fileId:c})}),e.jsx(W,{onClick:z,disabled:!r||!n.some(Boolean),children:"Build Chart"})]}),s&&e.jsxs("div",{ref:j,style:{background:"var(--bg-raised)",borderRadius:12,padding:24,boxShadow:"var(--elev-1)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{style:{fontWeight:700,color:"var(--fg-primary)"},children:[s.active.join(", ")," over ",r]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(se,{fileId:c,prompt:`In a line chart of ${s.active.join(", ")} over ${r}, where do the series diverge or converge most? Are there obvious turning points?`}),e.jsx(re,{widget:{type:"line",col:s.active[0],label:`${s.active.join(", ")} over ${r}`,file_id:c,extra:{xCol:r,series:s.active,smooth:x,showDots:g}}}),e.jsx(ae,{data:s.data,filename:`line-${r}`,containerRef:j,title:`Line Chart: ${s.active.join(", ")} over ${r}`})]})]}),s.rangeLabel&&e.jsx("div",{style:{fontSize:"0.68rem",color:"var(--fg-tertiary)",fontWeight:600,marginBottom:8},children:s.rangeLabel}),e.jsx(X,{width:"100%",height:320,children:e.jsxs(he,{data:s.data,children:[e.jsx(H,{...Y}),e.jsx(_,{dataKey:"x",tick:{fontSize:10},interval:"preserveStartEnd"}
1),e.jsx(G,{...K,tickFormatter:ie}),e.jsx(N,{...V,cursor:U}),e.jsx(J,{}),s.active.map((t,a)=>e.jsx(M,{type:x?"monotone":"linear",dataKey:t,stroke:u[a%u.length],strokeWidth:2,dot:g?{r:3}:!1,connectNulls:!0},t))]})})]}),!s&&e.jsx(ee,{icon:"ð",title:"Configure axes and add series",body:"Pick an X-axis (often a date), then up to 5 numeric series to overlay. Use the date range filter to scope to a window.",teaser:e.jsx(te,{variant:"line"})})]})}export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.