Just uploaded a new release of FoxCharts, that brings the so asked "double Y axis" charts as the main change.
Apart from that, 2 important fixes were applied:
- Multicharts with negative values that were not being drawn correctly in some situations;
- Line charts are drawn much faster (5x faster) when drawing with line caps (with shapes in the chart intersections);
- Other small tweaks
Still waiting for some feedback to push it as the "Recommended download". Please test it and let me know how it goes.
Originally I thought of making a special subclass of FoxCharts for this purpose, but at the end I decided to go through the hardest but best way, updating the whole class.
Have a look at the sample "chartssample_builder_2y.scx" in the samples folder of FoxCharts.
Just some few but important comments:
- needs to use depth = 0 (max 2)
- preferrably 2 data lines, one using the left axis and the other for the 2nd
- set the legends to the top
Pay attention to the new properties:
- ChartType = 18 && the newest chart type
- Fields(n).AxisIndex = 2 && to what axis the data will correspond (1 = default)
- LegendPosition = 6 && top center
Having this, now you are able to create a chart like this, with no effort:
Below is a simple script showing how to achieve the chart below directly:
create cursor sales( ;
chart1 i null, ;
chart2 i null, ;
legend c (30) NULL)
insert into sales values (130, 0, "jan")
insert into sales values (120, 25000, "feb")
insert into sales values ( 45, 50000, "mar")
insert into sales values ( 60, 75000, "apr")
insert into sales values ( 75, 100000, "may")
insert into sales values (110, 135000, "jun")
set classlib to locfile("foxcharts.vcx")
public oform as form
oform = createobject("form")
local loChart as Foxcharts of "foxcharts.vcx"
loChart = oForm.oChart
.Backcolor = rgb(255,255,255)
.BrushType = 2
.ChartsCount = 2
.ChartType = 18
.ColorType = 1
.Depth = 0
.FieldAxis2 = 'legend'
.FieldLegend = 'legend'
.FontName = 'verdana'
.Height = 288
.LegendPosition = 6
.SourceAlias = 'sales'
.Width = 732
.caption = 'chart subtitle'
.caption = 'testing 2nd y axis'
.forecolor = rgb(0,128,255)
.axisindex = 1
.color = rgb(255,0,191)
.fieldvalue = 'chart1'
.legend = 'gr1'
.shape = 5
endwith with .fields(2)
.axisindex = 2
.color = rgb(0,142,146)
.fieldvalue = 'chart2'
.legend = 'gr2'
.shape = 2 && 'vfpxicon.png'
loChart.DrawChart() loChart.Visible = .t.
oForm.Width = loChart.Width
oForm.Height = loChart.Height
Donations are welcome. I'm accepting donations from people that use foxcharts and would like to contribute. The donations for the FOXCHARTS project will not go to my pocket. Please make your donation to the Ceil Silver Ambassador fund, from SWFOX.
The ceil silver ambassador fund is intended to raise money from the vfp community to bring a developer to the southwest fox conference as an ambassador for the developers in his or her country. this gives the recipient the opportunity to meet and share experiences with developers attending southwest fox and gives other attendees the opportunity to learn about vfp development in the recipient's country.
I received this great honor and oportunity in 2010, and would be happy to help them to offer this fantastic gift to more people. That was a terrific experience, I learned lots of things there, met most of my best partners, knew many new other great people and this brought lots of strength to keep working in these tools.