Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing DataLabels.Font.Size
Message
From
09/12/2003 12:46:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/12/2003 12:10:33
Stan Vaninger
Mitek Industries, Inc
Missouri, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00857169
Message ID:
00857287
Views:
25
See comments between your code :

>Cetin,
>
>Thanks very much for your reply.
>
>The sample code you included is very different from the code I am working with and I am having a hard time determining how to do the same thing in my code. Perhaps if you see the code I am using, you will be able to show me where and how it can be done.
>
>Lparameters lcCursor, lcGraphField, lcYAxisLabel, lcXAxisLabel
>
>* create the Excel spreadsheet
>loXL = Createobject('Excel.Application')
>loWB = loXL.Workbooks.Add()
>With loWB.ActiveSheet
> .Name = 'BudgetData'
> lnFldCount = Fcount((lcCursor))
> lnRecCnt = Reccount((lcCursor)) + 1


> Select &lcCursor
> Go Top
> _vfp.DataToClip((lcCursor),Reccount((lcCursor)),3)
> lcCell = 'A1:' + Chr(64 + lnFldCount) + Transform(lnRecCnt)
> .Paste(.Range(lcCell))
* Notes: _vfp.Datatoclip adds an extra col
* No need to calculate paste area - specify start cell
* Moreover it's dangerous to use :
* lcCell = 'A1:' + Chr(64 + lnFldCount) + Transform(lnRecCnt)
* It'd fail if you had more than 26 fields
* Avoid macro substitution whenever possible
* Above block could be recoded as :
select (lcCursor)
local lcTemp
lcTemp = sys(2015)+'.tmp'
copy to (lcTemp) delimited with "" with tab
_cliptext = FileToStr(lcTemp)
erase (lcTemp)
.Range('A2').PasteSpecial
* I didn't understand why you're overwriting first data record
* (with headers?)
> .Range('A1').Value = ''
> Do Case
> Case lcCursor = 'cCustomers'
> .Range('B1').Value = '' && 'PPMs'
> Case lcCursor = 'cCustomers2'
> .Range('B1').Value = '' && 'Defect Categories'
> Endcase
> Go Top In (lcCursor)
>Endwith
>
>* loXL.Visible = .T. && for testing only
>* create the graph
>loChart = loWB.Charts.Add()
>lnPlotBy = xlColumns && xlRows
>With loChart
> .SetSourceData(loWB.Sheets('BudgetData').Range(lcCell),lnPlotBy)
        .ApplyDataLabels()
        .SeriesCollection(1).Datalabels.Font.Size = 9
> .ChartType = 51 && xlBar && 2
> .PlotArea.Interior.Color = Rgb(255,255,255)
> * save graph to a temporary file
> lcFileName = Sys(2015)+'.xls'
> .SaveAs(Fullpath(Curdir()) + lcFileName)
>Endwith
>
>* quit Excel
>loXL.Quit()

Past this point I've no idea why you're getting it into a general field and erasing xls. Instead of the xls itself in general field it might be better to save data snapshot (same as _cliptext data pasted into excel) in a memo and generate the graph from it on demand probably using alternatives to xls, MSGraph like MsChartFX, OWCChart etc. IMHO Excel and MSGraph are a little heavy and slow. OTOH if it works don't fix it :)


>
>* insert graph into cursor
>Select coGraphs
>Append General (lcGraphField) From (lcFileName) Class 'Excel.Chart'
>Tableupdate(.T., .T., 'coGraphs')
>Erase (lcFileName)
>
>With Thisform
> .oGraph.ControlSource = (lcGraphField)
> .oGraph.Visible = .F. && .T.
> .LockScreen = .F.
> .oGraph.Refresh()
>Endwith
>
>Local lnAxisId, lnCnt
>With Thisform.oGraph.Object.ActiveChart
> *FOR lnSeries = 1 TO lnTopParts
> * .SeriesCollection[lnSeries].HasDataLabels = .T. && this works
> * .SeriesCollection[lnSeries].DataLabels.Font.Name = 'Times New Roman'
> * .SeriesCollection[lnSeries].DataLabels.Font.Size = 6 && this does not reduce the label font size - why ???
> *ENDFOR
>
> .SeriesCollection[1].HasDataLabels = .T.
> *.SeriesCollection[1].DataLabels.Font.Size = .SeriesCollection[1].DataLabels.Font.Size - 4 && does not work
> .ChartArea.Font.Name = 'Times New Roman'
> .ChartArea.Font.Bold = .T.
> *****.PlotArea.Interior.Width = 50
> .HasTitle = .T.
> .HasLegend = .F.
> .ChartTitle.Font.Name = 'Times New Roman'
> .ChartTitle.Font.Bold = .F. && .T.
> .ChartTitle.Text = lcYAxisLabel
> .ChartTitle.Font.Size = 14
>
> *** if this is a pie graph, there is no way
> *** to check to see if we have an Axis. Any attempt
> *** to check the chart's HasAxis property or .Axes.Count property
> *** results in a OLE exception
> If Not Inlist( .ChartType, xl3DPie, xlPie, xlPieOfPie, xlPieExploded, xl3DPieExploded, xlBarOfPie )
> *** Now set the axes at right angles for 3-d bar, column, and line charts
> If Inlist( .ChartType, xl3DColumnClustered, xl3DColumnStacked, xl3DColumnStacked100, xl3DBarClustered, xl3DBarStacked, xl3DBarStacked100, xl3DLine )
> .RightAngleAxes = .T.
> Endif
> *.Legend.Font.Size = 12 && 18 && removed 06/30/2003
> With .Axes( xlCategory )
> .TickLabels.Font.Size = 9 && 14
> lcTitleText = lcXAxisLabel
> If Not Empty( lcTitleText )
> .HasTitle = .T.
> .AxisTitle.Text = lcTitleText
> Do Case
> Case lcCursor = 'cCustomers'
> .AxisTitle.Font.Size = 14
> Case lcCursor = 'cCustomers2'
> .AxisTitle.Font.Size = 14
> Case lcCursor = 'cCustomers3'
> .AxisTitle.Font.Size = 14
> Case lcCursor = 'cCustomers4'
> .AxisTitle.Font.Size = 14
> Endcase
> Else
> .HasTitle = .F.
> Endif
> Endwith
> With .Axes( xlValue )
> .TickLabels.Font.Size = 12
> *lcTitleText = ALLTRIM( Queries.cTitleY )
> lcTitleText = lcYAxisLabel
> If Not Empty( lcTitleText )
> .HasTitle = .T.
> .AxisTitle.Text = lcTitleText
> .AxisTitle.Font.Size = 12 && 16
> Else
> .HasTitle = .F.
> Endif
> Endwith
> *Wait window '.Axes.Count = ' + Str(.Axes.Count,2)
> If .Axes.Count > 2
> With .Axes( xlSeriesAxis )
> .TickLabels.Font.Size = 8
> *lcTitleText = ALLTRIM( Queries.cTitleZ )
> lcTitleText = '????'
> If Not Empty( lcTitleText )
> .HasTitle = .T.
> .AxisTitle.Text = lcTitleText
> .AxisTitle.Font.Size = 10
> Else
> .HasTitle = .F.
> Endif
> Endwith
> Endif
> Else
> *** Then we want to set things differently
> *** Because pie charts don't have axes
> .HasTitle = .T.
> .ChartTitle.Text = 'XXXXX' && ALLTRIM( EVALUATE( 'CsrResults.' + FIELD( 1, 'csrResults' ) ) )
> .ChartTitle.Font.Size = 12
> .Legend.Font.Size = 10
> .ApplyDataLabels()
> .SeriesCollection( 1 ).Datalabels.Font.Size = 8
> Endif
>Endwith
>
>Tableupdate(.T., .T., 'coGraphs')
>
>*** And refresh the control
>With Thisform.oGraph
> .Visible = .F. && .T.
> .Refresh()
>Endwith
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform