Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxCharts/oChart error

Status
Not open for further replies.

Luikj

Technical User
Jul 23, 2019
5
0
0
US
Hi experts: am trying to learn graphing. . . in vfp9...
(from Doug Hennig sample "Our first chart" FOXCHART)

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Get the data for the chart.
open database _samples + 'Northwind\Northwind'
select Categories.CategoryName, ;
sum(OrderDetails.UnitPrice * OrderDetails.Quantity) as Sales ;
from Products ;
join Categories on Products.CategoryID = Categories.CategoryID ;
join OrderDetails on Products.ProductID = OrderDetails.ProductID ;
group by 1 ;
into cursor ChartData
*BROWSE opens ChartData and does joins just fine. . .placed foxchart.vcx on form. . .
with this.oChart as FoxCharts of FoxCharts.vcx
* But throws error says "oChart" not found
** oChart is the name of my blank form, trying to figure out what I am doing wrong.
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

* Specify the chart type and other settings.
.Anchor = 15
.ChartType = 7 && Bar
.ColorType = 0
* Specify the data for the chart.
.SourceAlias = 'ChartData'
.FieldAxis2 = 'CategoryName'
.Fields(1).FieldValue = 'Sales'
.FieldLegend = .FieldAxis2
* Specify the chart and axis captions.
.Title.Caption = 'Sales by Product Category'
.SubTitle.Caption = ''
.XAxis.Caption = 'Product Category'
.YAxis.Caption = 'Total Sales'
* Draw the chart.
.DrawChart()
endwith

Any feedback would be deeply appreciated.
Lui
 
with this.oChart as FoxCharts of FoxCharts.vcx
* But throws error says "oChart" not found
** oChart is the name of my blank form, trying to figure out what I am doing wrong.

oChart if probably NOT the name of your blank form. oChart is probably the name of your chart control, which you should have placed on a form.

Where exactly are you running this code? I would expect it to be in the Init of the form. If so, it should run fine. If it is in the Load of the form, it won't work, because at that point the chart control has not yet been instantiated.

If it is in the Init of the chart control itself, it won't work because you you are referencing the control as this.oChart. In that case, you should just reference it as [tt]this[/tt] (not followed by a full stop).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike, had the chart control in the load. . .
thanks for the help. Lu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top