Page 1 of 1

Multi Pie Chart Title

Posted: Sat Sep 03, 2005 2:00 pm
by 9525099
Is there any way to display a title directly underneath a pie chart. I would like to display the current month/year for the data that is being displayed directly underneath the pie chart. I have multiple pie charts in my graph so I would need this funtionality for all displayed pies.

Posted: Mon Sep 05, 2005 7:33 am
by narcis
Hi JW,

Yes, you can use TChart.Canvas.TextOut method as shown here:

Code: Select all

Private Sub Form_Load()
  With TChart1
    .Legend.Visible = True
    For i = 0 To 3
      .AddSeries scPie
      .Series(i).FillSampleValues 7
      .Series(i).Marks.Style = smsValue
    Next i
  End With
End Sub

Private Sub TChart1_OnSeriesBeforeDrawValues(ByVal SeriesIndex As Long)
  'Place the new location of the Chart before painting the Series
  With TChart1
    Select Case SeriesIndex
      Case 0: .ChartRect 0, 0, .Canvas.Width / 2, .Canvas.Height / 2
              .Canvas.TextOut .Canvas.Width / 4, (.Canvas.Height / 2) - 10, "Series" + CStr(SeriesIndex)
      Case 1: .ChartRect .Canvas.Width / 2, 0, .Canvas.Width, .Canvas.Height / 2
              .Canvas.TextOut .Canvas.Width / 1.3, (.Canvas.Height / 2) - 10, "Series" + CStr(SeriesIndex)
      Case 2: .ChartRect 0, .Canvas.Height / 2, .Canvas.Width / 2, .Canvas.Height
              .Canvas.TextOut .Canvas.Width / 4, .Canvas.Height - 20, "Series" + CStr(SeriesIndex)
      Case 3: .ChartRect .Canvas.Width / 2, .Canvas.Height / 2, .Canvas.Width, .Canvas.Height
              .Canvas.TextOut .Canvas.Width / 1.3, .Canvas.Height - 20, "Series" + CStr(SeriesIndex)
    End Select
  End With
End Sub

Posted: Wed Mar 01, 2006 6:44 pm
by 9525099
NarcĂ­s,

Many thanks on this answer. Sorry it took so long to return the post-reply, but I had to resort to using the annotations versus the printing the text (plus the annotations were a big hit w/ QA).

I THINK that trapping the events at print-time for a var like say, m_bChartPrinting, in the code as described above and alter the FONT size by using the HEIGHT of the printer font may solve some BIG printing problems?

Posted: Tue Mar 07, 2006 5:44 pm
by Pep
Hi,

I'm not sure what you refer here, using the above code you should be able to print the pies with the text into the pie chart.

In case you want to change the font and print , you should use font.height to define the font size.