User (Legacy) Posted May 2, 2003 Report Share Posted May 2, 2003 Hi I am using the Paint method to paint a graph on to the HDC. The legend box does not get printed correctly if the Chart type is a Pie. For all other Chart Types the Legend Box appears correctly. Why does this happen? In the display mode and save as bmp the legend box appears right. Attached is the generated PDF file thanks Indhu Link to comment Share on other sites More sharing options...
Software FX Posted May 2, 2003 Report Share Posted May 2, 2003 As oppose to other chart types, the Pie chart doesn't have a series legend as it has only one series, it has a values legend, so make sure you turn on the values legend (LegendBox = true) and call LegendBoxObj.SizeToFit after setting your data. -- FP Software FX, Inc. Attachments.zip Link to comment Share on other sites More sharing options...
User (Legacy) Posted May 2, 2003 Author Report Share Posted May 2, 2003 I have done that already, it shows up fine when I display it but while printing, I am doing a Paint() to print the chart to the printer, the legend does not print "SoftwareFX Support" <support@softwarefx.com> wrote in message news:GDxlncMEDHA.1336@webserver1.softwarefx.com... > As oppose to other chart types, the Pie chart doesn't have a series legend > as it has only one series, it has a values legend, so make sure you turn on > the values legend (LegendBox = true) and call LegendBoxObj.SizeToFit after > setting your data. > > -- > FP > Software FX, Inc. > > Attachments.zip Link to comment Share on other sites More sharing options...
Software FX Posted May 6, 2003 Report Share Posted May 6, 2003 The following code, draws a Pie chart into a Printer DC, it works as expected, it prints the chart as well as the legend. My guess would be that you are specifying a rectangle that bleeds out of the page and therefore you don't get to see the legend on the right. To confirm this, move the legend to the Top or Left of the chart. Another possibility is that the printer driver has something to do with it, please try printing to a real printer instead of a PDF to see if you get different results. Private Sub Command1_Click() Dim l, r, t, b As Integer 'left,right,top and bottom Printer.Print "" px = Printer.TwipsPerPixelX py = Printer.TwipsPerPixelY w = Printer.Width h = Printer.Height gap = 100 / px t = gap b = ((h / 2) / py) - gap l = gap r = (w / px) - gap ChartFX1.Paint Printer.hDC, l, t, r, b, CPAINT_PRINT, 0 Printer.EndDoc End Sub Private Sub Form_Load() ChartFX1.Legend(0) = "Legend 1" ChartFX1.Legend(1) = "Legend 2" ChartFX1.Legend(2) = "Legend 3" ChartFX1.Legend(3) = "Legend 4" ChartFX1.Legend(4) = "Legend 5" ChartFX1.LegendBox = True End Sub -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
User (Legacy) Posted May 6, 2003 Author Report Share Posted May 6, 2003 Thank you for getting back to me. I tried the code in VB and again tried the same code in VC++, I seem to be getting different results the LegendBox is not shown. Here is my piece of code. Can you please test this and tell what is going on ? Thanks Indhu IChartFXPtr m_pChartFX; BOOL bRet = TRUE; try { m_pChartFX.CreateInstance(__uuidof(ChartFX)); } catch(...) { bRet = FALSE; } m_pChartFX->Gallery = PIE; //chart type m_pChartFX->Chart3D = FALSE; m_pChartFX->LegendBox = TRUE; m_pChartFX->SerLegBox = FALSE; m_pChartFX->Title[CHART_TOPTIT] = ""; m_pChartFX->OpenDataEx((CfxCod) (COD_VALUES|COD_REMOVE), 1, 5); //5 pie slices m_pChartFX->ValueEx[0][0] = 10.00; m_pChartFX->ValueEx[0][1] = 20.00; m_pChartFX->ValueEx[0][2] = 30.00; m_pChartFX->ValueEx[0][3] = 25.00; m_pChartFX->ValueEx[0][4] = 15.00; m_pChartFX->Legend[0] = (LPCTSTR)"Legend 1"; m_pChartFX->Legend[1] = (LPCTSTR)"Legend 2"; m_pChartFX->Legend[2] = (LPCTSTR)"Legend 3"; m_pChartFX->Legend[3] = (LPCTSTR)"Legend 4"; m_pChartFX->Legend[4] = (LPCTSTR)"Legend 5"; m_pChartFX->CloseData(COD_VALUES); m_pChartFX->LegendBoxObj->AutoSize = TRUE; m_pChartFX->LegendBoxObj->SizeToFit(); CPrintDialog dlg(FALSE, PD_SELECTION | PD_USEDEVMODECOPIES); if (dlg.DoModal() == IDOK) { HDC hdc = dlg.GetPrinterDC(); int width = GetDeviceCaps(hdc,HORZRES); int height = GetDeviceCaps(hdc,VERTRES); CRect rect; rect.left = (width / 10); rect.top = (height/ 10); rect.right = width - (width / 10); rect.bottom = height - (height / 10); DOCINFO docinfo; memset( &docinfo, 0, sizeof( DOCINFO ) ); docinfo.cbSize = sizeof( DOCINFO ); StartDoc(hdc,&docinfo); StartPage(hdc); m_pChartFX->Paint((long)hdc,rect.left,rect.top,rect.right,rect.bottom,CPAINT _PRINT,0); EndPage(hdc); EndDoc(hdc); } "SoftwareFX Support" <support@softwarefx.com> wrote in message news:7VOfz89EDHA.2532@webserver1.softwarefx.com... > The following code, draws a Pie chart into a Printer DC, it works as > expected, it prints the chart as well as the legend. > > My guess would be that you are specifying a rectangle that bleeds out of the > page and therefore you don't get to see the legend on the right. To confirm > this, move the legend to the Top or Left of the chart. > > Another possibility is that the printer driver has something to do with it, > please try printing to a real printer instead of a PDF to see if you get > different results. > > Private Sub Command1_Click() > Dim l, r, t, b As Integer 'left,right,top and bottom > Printer.Print "" > px = Printer.TwipsPerPixelX > py = Printer.TwipsPerPixelY > w = Printer.Width > h = Printer.Height > gap = 100 / px > t = gap > b = ((h / 2) / py) - gap > l = gap > r = (w / px) - gap > ChartFX1.Paint Printer.hDC, l, t, r, b, CPAINT_PRINT, 0 > Printer.EndDoc > End Sub > > Private Sub Form_Load() > ChartFX1.Legend(0) = "Legend 1" > ChartFX1.Legend(1) = "Legend 2" > ChartFX1.Legend(2) = "Legend 3" > ChartFX1.Legend(3) = "Legend 4" > ChartFX1.Legend(4) = "Legend 5" > ChartFX1.LegendBox = True > End Sub > > > -- > FP > Software FX, Inc. > > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.