cowcow Posted June 20, 2008 Report Posted June 20, 2008 Hi, I want to use the ChartFx multiple panes features to display 3 to 6 charts in a single ChartFx Control. I am using VB6. I followed the sample code, but it never worked. Here is the sample: Dim series0 As Object Set series0 = Chart1.Series(0) series0.Gallery = Gallery_Lines series0.LineWidth = 2 series0.MarkerShape = MarkerShape_None series0.YAxis = YAxis_Main Chart1.AxisY.Pane = 0 Dim series1 As Object Set series1 = Chart1.Series(1) series1.Gallery = Gallery_Lines series1.Border = True series1.YAxis = YAxis_Secondary Chart1.AxisY.Pane = 1 ' First Pane Dim pane1 As Object Set pane1 = Chart1.Panes(0) pane1.Proportion = 15 pane1.Title.Text = "Price" 'Second Pane Dim pane2 As Object Set pane2 = Chart1.Panes(1) pane2.Proportion = 8 pane2.Title.Text = "Volume (in Millions)" 'Third Pane Dim pane3 As Object Set pane3 = Chart1.Panes(2) pane3.Proportion = 10 pane3.Title.Text = "Height (in Millions)" Chart1.AxisX.LabelsFormat.Format = AxisFormat_Date ' Add data With Chart1 ' First chart .Value(0, 0) = 103 .Value(0, 1) = 1045 .Value(0, 2) = 1030 ' Second chart .Value(1, 0) = 10030 .Value(1, 1) = 10015 .Value(1, 2) = 10021 ' Third chart .Value(2, 0) = 130 .Value(2, 1) = 115 .Value(2, 2) = 121 End With I found that the second and thrid series were displayed in the second chart, while the third chart didn't display anything. Could you please give me some suggestions what I did wrong? Do you have any similar example? Thank you
sfalla Posted June 30, 2008 Report Posted June 30, 2008 You need to assign a series to an axis, then assign an axis to the pane. Series 0 -> YAxis_Main ' 0 Series 1 -> YAxis_Secondary ' 1 Series 2 -> 3 ' All Extra Axis start from 3, as 2 is reserved Try this, it works for me and you should get series 0 in the first pane, series 1 in the seocnd pane and series 2 in the third pane. With Chart1.Series(0) .Gallery = Gallery_Lines .Border = True .YAxis = YAxis_Main End With Chart1.AxisY.Pane = 0 With Chart1.Series(1) .Gallery = Gallery_Lines .LineWidth = 2 .MarkerShape = MarkerShape_None .YAxis = YAxis_Secondary End With Chart1.AxisY2.Pane = 1 With Chart1.Series(2) .Gallery = Gallery_Lines .Border = True .YAxis = 3 ' YAxis_Main = 0, YAxis_Secondary = 1, 2 is reserved for XAxis, extra axis start from 3 End With Chart1.axis(3).Pane = 2
cowcow Posted July 1, 2008 Author Report Posted July 1, 2008 Hi, Thank for your help. I got it, here is my sample code: Dim s, v As IntegerDim a As IntegerDim sCount, vCount As Integer sCount = Rnd * 5 + 1vCount = Rnd * 100 + 1 With Chart1 .Scrollable = True .AxisX.ScrollPosition = 10000 ' Scroll to the end .Panes.Clear .ClearData ClearDataFlag_AllData .Grid = ChartGrid_Vert For v = 0 To vCount - 1 .Legend(v) = v Next Chart1.OpenData COD_Values, sCount, vCount For s = 0 To sCount - 1 Select Case s Case 0 .Series(s).Gallery = Gallery_Lines .Series(s).Stacked = True .Series(s).YAxis = YAxis_Main .Series(s).LineWidth = 2 .AxisY.Pane = s Case 1 .Series(s).Gallery = Gallery_Lines .Series(s).YAxis = YAxis_Secondary .AxisY2.Pane = s .AxisY2.Position = AxisPosition_Near Case Else .Series(s).Gallery = Gallery_Lines .Series(s).YAxis = s + 1 .Axis(s + 1).Pane = s .Axis(s + 1).Position = AxisPosition_Near End Select .Panes(s).Separation = 8 .Panes(s).Proportion = 10 .Panes(s).Title.Text = "Price " & s + 1 For v = 0 To vCount - 1 .Value(s, v) = 1000 * Rnd Next Next .CloseData COD_Values End With
Recommended Posts
Archived
This topic is now archived and is closed to further replies.