efowl
asked on
MSChart Pie Chart - Data Labels
I have managed to load data into a pie chart format using an MSChart control, but I have been unable to find a way to display % data labels for each pie slice. I am not using a DBgrid control at this moment, is this possibly the reason that I can't get labels? The DBgrid control was not necessary in order for me to display the pie chart data. Any suggestions would be greatly appreciated.
ASKER
Adjusted points to 200
That's crap, MSCHART can print, you just need to know how to do it.
Check the properties of the MSChart. Also, are you displaying the Chart in 3d or 2d? What is your data array? You do know that the first element (no of sections generally) needs to be a string, even if you want just numbers to appear.
Check the properties of the MSChart. Also, are you displaying the Chart in 3d or 2d? What is your data array? You do know that the first element (no of sections generally) needs to be a string, even if you want just numbers to appear.
That's crap, MSCHART can print, you just need to know how to do it.
Check the properties of the MSChart. Also, are you displaying the Chart in 3d or 2d? What is your data array? You do know that the first element (no of sections generally) needs to be a string, even if you want just numbers to appear.
Check the properties of the MSChart. Also, are you displaying the Chart in 3d or 2d? What is your data array? You do know that the first element (no of sections generally) needs to be a string, even if you want just numbers to appear.
Ok, Tommoy_boy, just *HOW* do *YOU* print the MSChart control? The !@#$%^ doesn't have a .Print method! Or do you just print a *picture* of the graph with the blockyness that comes with it?
M
M
Mark2150:
Briefly, a print a MSCHART you need to copy it's image (yes it is a bitmap, or similar) to the clipboard. From there it is a simple matter of printing the contents of the clipboard (as a bitmap).
Try this:
MSCHART1.EditCopy
Printer.Print " "
Printer.PaintPicture Clipboard.GetData(), 0, 0
Printer.EndDoc
Best Regards
TB
Briefly, a print a MSCHART you need to copy it's image (yes it is a bitmap, or similar) to the clipboard. From there it is a simple matter of printing the contents of the clipboard (as a bitmap).
Try this:
MSCHART1.EditCopy
Printer.Print " "
Printer.PaintPicture Clipboard.GetData(), 0, 0
Printer.EndDoc
Best Regards
TB
The problem with the bitmap is that your text is rendered at the resolution of the screen object. When you put it down on paper it either comes out *tiny* but sharp, or Large and *UGLY*. I want the control to print with full fidelity so that my text legends don't look like a screen dump. There is *NO WAY* for that control to do this so instead of having my output look like a 4th graders I don't use the control. I generate my own graphing routines that render with full fidelity. Both my customers and myself prefer the quality level improvement that this provides.
Printing a form as a bitmap is a *kludge* and a "workaround" and *NOT* suitable for commercial ($$$$) code.
M
Printing a form as a bitmap is a *kludge* and a "workaround" and *NOT* suitable for commercial ($$$$) code.
M
ASKER
enough about printing I still need to know how to display data labels, it is not part of the properties that I can see of.
Again, the answer is to give up on the control. Once you start writing your own graph routine you can use .CurrentX and .CurrentY to position the cursor whereever you want. Then a .Print "this is my label" will allow you to put text whereever you need it. Text is always drawn down and to the right of your cursor position so you might need to use the .TextWidth("this is my label") property to determine how wide your string is and then adjust the .CurrentX accordingly.
M
M
ASKER
I tried your sample code and could not get it to work. Is there possibly another VB control that has graphing capability.
You can graph to a picture box.
You want operational source?
Write me direct:
Mark_Lambert@ntsc.navy.mil
M
You want operational source?
Write me direct:
Mark_Lambert@ntsc.navy.mil
M
I would like to see mark2150 write code to render a clickable 3d graph as effortlessly as the MSChart control. Sure its poorly documented and some of its properties are esoteric
but why reinvent the wheel?
Meanwhile, back to efowl
Have you actualy entered labels for your chart?
with MSChart1
'-- enter text
For i = 1 to .ColCount
.column = i
.collabel = "your label here"
next i
For i = 1 to .RowCount
.row = i
.rowlabel = "your label here"
next i
'-- control legend
.legend.location.visible = true
.legend.location.locationt ype = 8
.legend.location.RECT.min. set Xval, Yval
.legend.location.RECT.max. set Xval, Yval
end with
but why reinvent the wheel?
Meanwhile, back to efowl
Have you actualy entered labels for your chart?
with MSChart1
'-- enter text
For i = 1 to .ColCount
.column = i
.collabel = "your label here"
next i
For i = 1 to .RowCount
.row = i
.rowlabel = "your label here"
next i
'-- control legend
.legend.location.visible = true
.legend.location.locationt
.legend.location.RECT.min.
.legend.location.RECT.max.
end with
ASKER
Yes, I have added row and column labels, as you defined, but to no avail. I do agree with your comment about MSCHART, I just wish it had all the bells and whistles, and I wish there was more documentation on it.
ASKER
A microsoft support engineer has found the solution to my problem with the following code:
For i = 1 To mschart1.Plot.SeriesCollec tion.Count
With mschart1.Plot.SeriesCollec tion(i) &_
.DataPoints(-1).DataPointL abel
.LocationType = VtChLabelLocationTypeOutsi de
.Component= VtChLabelComponentPercent
.PercentFormat = "0%"
.VtFont.Size = 10
End With
Next
...this will obtain pie chart data labels.
Thanks for everyone's input,
Eric
For i = 1 To mschart1.Plot.SeriesCollec
With mschart1.Plot.SeriesCollec
.DataPoints(-1).DataPointL
.LocationType = VtChLabelLocationTypeOutsi
.Component= VtChLabelComponentPercent
.PercentFormat = "0%"
.VtFont.Size = 10
End With
Next
...this will obtain pie chart data labels.
Thanks for everyone's input,
Eric
ASKER
A microsoft support engineer has found the solution to my problem with the following code:
For i = 1 To mschart1.Plot.SeriesCollec tion.Count
With mschart1.Plot.SeriesCollec tion(i) &_
.DataPoints(-1).DataPointL abel
.LocationType = VtChLabelLocationTypeOutsi de
.Component= VtChLabelComponentPercent
.PercentFormat = "0%"
.VtFont.Size = 10
End With
Next
...this will obtain pie chart data labels.
Thanks for everyone's input,
Eric
For i = 1 To mschart1.Plot.SeriesCollec
With mschart1.Plot.SeriesCollec
.DataPoints(-1).DataPointL
.LocationType = VtChLabelLocationTypeOutsi
.Component= VtChLabelComponentPercent
.PercentFormat = "0%"
.VtFont.Size = 10
End With
Next
...this will obtain pie chart data labels.
Thanks for everyone's input,
Eric
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have working source for piecharts.
email me direct at Mark_Lambert@ntsc.navy.mil
M