# Plot to PNG A console program that creates a `TAtlasPlot` in code, adds a bar series and a line series with a trend line, and exports the chart as PNG, SVG and CSV without ever showing a window. It then verifies the files it wrote and exits with code 0. ## What it demonstrates - `AddSeries`, `AddY` with category text, `Marks`, `ShowPoints`, `LineWidth` - `Title`, `Footnote`, `LegendPosition`, axis titles - `AddTrendLine` (a least-squares snapshot) - `SaveToFile` choosing PNG, SVG or CSV by extension, at a given pixel size - `DataFromCSV` / `DataToCSV` round trip - `EAtlasPlotError` on invalid input, leaving the chart unchanged - `BeginUpdate` / `EndUpdate` around bulk changes ## Build and run Open `PlotToPng.dpr` in Delphi 13; the IDE creates the project file. Add the Atlas Plot `src` folder to the project's search path, then build and run for Win32 or Win64. No packages need to be installed. The program needs no input. It checks its own results and stops with an error if any of them differs from the output below. The program writes `plot-output/orders.png`, `orders.svg` and `orders.csv` in its current directory. ## Expected output ``` ok: chart has two data series and one trend line ok: a trend line has exactly two points Exporting to ...\plot-output ok: PNG file has content ok: PNG is 800 x 500 ok: SVG root has the requested size ok: SVG contains the title ok: SVG shows category ticks from the point text ok: SVG clips the series to the plot area ok: CSV header is series,kind,x,y,text ok: CSV has one row per point ok: first row is the first order bar ok: numbers use a decimal point regardless of locale ok: the trend line is exported as a series ok: CSV import recreates all three series ok: series kinds survive the round trip ok: import and export are symmetric ok: a value beyond 1E100 is rejected and nothing changes ok: no partial files are left behind PlotToPng: all checks passed ``` ## Adapting it Replace the `Months`, `OrderCounts` and `Revenue` constants with your own data, or load a CSV file with `Plot.DataFromCSV(TFile.ReadAllText(...))` instead of calling `AddY`. Change the extension in `SaveToFile` to `.bmp` or `.emf` for the other image formats, or call `RenderTo(Printer.Canvas, ...)` to print.