Recent

Author Topic: TsWorkbookChartSource info  (Read 3523 times)

fmolina

  • New Member
  • *
  • Posts: 40
TsWorkbookChartSource info
« on: July 22, 2018, 03:57:16 am »
Hi all,

Is there any place were to find info/tutorial/wiki/etc about use of TsWorkbookChartSource component? I can only find the announcement in the fp spreadsheet  1.6 version, recommending it, but nothing more. I am looking specially for how to add data series to plot.

Thank you

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorkbookChartSource info
« Reply #1 on: July 23, 2018, 10:35:21 am »
There is no explicitly written documentation about this component. But if you know how to work with the visual FPSpreadsheet components (http://wiki.lazarus.freepascal.org/FPSpreadsheet_tutorial:_Writing_a_mini_spreadsheet_application) and with TAChart (http://wiki.lazarus.freepascal.org/TAChart_documentation, http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Getting_started plus more) you should be able to find your way with it.

You can find a demo in the folder "examples/visual/fpschart/workbookchartsource" (note that this folder has been mis-named as "workbookchartsource-deprecated" which has been corrected now).

How to add a series to a chart is more a question related to TAChart than to fpspreadsheet. Double-click on the chart, click on "+ Add" and select the new series type from the menu. Then add another TsWorkbookChartSource component and link it to the "Source" property of the new series. Link the "WorkbookSource" of the TsWorkbookChartSource component to the TsWorkbookComponent which gives access to the spreadsheet file loaded. In the WorkbookChartSource, enter the cell range addesses for the x and y data in Excel format (e.g. Sheet1!A1:A10)

There were a couple of changes made recently. Therefore I recommend to use the svn trunk version of fprspreadsheet for this issue. The new version is able to display the chart at designtime once the spreadsheet file has been loaded by the WorkbookSource.

fmolina

  • New Member
  • *
  • Posts: 40
Re: TsWorkbookChartSource info
« Reply #2 on: July 27, 2018, 04:28:55 am »
Hi,

Thank you for the answer. Just to confirm (I mean here dynamically, not at design time):
- A new series needs a corresponding new TsWorkbookChartSource, right?
- The only way to specify the cell range is through an Excel like string? Not CellStartX, etc.?

Thanks

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorkbookChartSource info
« Reply #3 on: July 27, 2018, 10:00:03 am »
- A new series needs a corresponding new TsWorkbookChartSource, right?
Yes.

- The only way to specify the cell range is through an Excel like string?
Yes. Something like "A1:A10" or "Sheet2!A1:A10" - the latter version is preferred because is clearly shows from which sheet the data will be taken; the first version can be recommended only for single-sheet files.

See the attached demo which assumes a designtime-created TChart and TsWorkbookSource, reads an xlsx file and creates a series for each of the worksheet y columns at runtime.

 

TinyPortal © 2005-2018