User (Legacy) Posted May 13, 2003 Report Share Posted May 13, 2003 Hi!Would like some help with a problem regarding annotation objects and Gantt charts.I'm using ASP to render the chart. The version of ChartFx is 5.5.5.0.I'm trying to print a explanatory text inside (or near) the bars in my Gantt chart.The chart consists of dates on the Yaxis.I've been trying to find an explanation in the help pages but unsuccessfully.The code below shows what I'm trying to do.The problem is to get the x and y coordinates for the annotation object.I've tried two alternatives, but none of them work. Alternative 1 results in x = null and y = null.Alternative 2 results in x = 763 and y = 0, for all values even though they should differ and none of them being 763. Can someone please explain to me what I'm doing wrong? Regards, Peter Krickner ... For i = 0 To (oChart.NValues - 1) 'Create a Text object Set ObjText = AnnotX.Add(6) '6 is a Text object 'Get the position for the annotation object 'Alternative 1 (x and y are out-, the rest are in-parameters): Call oChart.ValueToPixel(i, oChart.IniValueEx(0, i), CDbl(x), CDbl(y), 1) 'Alternative 2 (4 = CPI_VALUETOPIXEL): nMarkerPosition = oChart.PaintInfo(4, oChart.IniValueEx(0, i)) x = CHART_LOWORD(nMarkerPosition) y = CHART_HIWORD(nMarkerPosition) 'Set position for annotation object. ObjText.Top = x ObjText.Left = y 'Enter text ObjText.Text = "Text inside the Gantt bars" 'Set annotation object properties ObjText.Width = 200 ObjText.Height = 30 ObjText.BkColor = CHART_TRANSPARENT ObjText.Color = RGB(0,255,0) ObjText.AllowMove = False Set ObjText = Nothing Next Link to comment Share on other sites More sharing options...
Software FX Posted May 14, 2003 Report Share Posted May 14, 2003 You are using ValueToPixel incorrectly. Passing just ONE value, you will get back only ONE coordinate (either X or Y, but not both). Neither ValueToPixel nor PaintInfo can be called from a script, both require typed variables. These functions only work when the chart is already visible and has a size assigned. The best way to achieve what you need is to attach the annotation object to the logical coordinates of the bar in question as follows: fromvalue = oChart.IniValueEx(0, i) tovalue = oChart.IniValueEx(0, i) ObjText.Attach ATTACH_ELASTIC,CStr(i)+","+CStr(fromvalue)+","+CStr(i+1)+","CStr(tovalue) -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
User (Legacy) Posted May 15, 2003 Author Report Share Posted May 15, 2003 Thank you, but I'm sorry to say it didn't help. No texts are showing in the gantt chart. I presume that the ToValue should be ValueEx and not IniValueEx, meaning the endpoint of the bar in the gantt chart? I do not understand why the third parameter in the string should be i+1 and not i, but I've tried all combinations. To clarify what I mean, I've attached a picture displaying the chart. The code looks like this: For i = 0 To (oChart.NValues - 1) Set ObjText = AnnotX.Add(6) 'Create a Text Object FromValue = oChart.IniValueEx(0, i) ToValue = oChart.ValueEx(0, i) 'Attach object using: ATTACH_ELASTIC = 2 ObjText.Attach 2, CStr(i) & "," & CStr(FromValue) & "," & CStr(i+1) & "," & CStr(ToValue) ObjText.Text = "Text inside Gantt bar" ObjText.Width = 200 ObjText.Height = 40 ObjText.BkColor = CHART_TRANSPARENT Set ObjText = Nothing Next 'ObjText.Attach 2, "0,37712,1,37756" The row above displays the values sent in the first time in the loop. Why isn't anything showing? Am I doing this in the wrong order or something? This is the last thing I'm doing before printing out the chart with: oChart.ImgHeight = 400 oChart.ImgWidth = 1000 oChart.GetHtmlTag("100%", "100%", "Image") Once again grateful for further help! / Peter. ... "SoftwareFX Support" <support@softwarefx.com> wrote in message news:ZXlU4WlGDHA.2972@webserver1.softwarefx.com... You are using ValueToPixel incorrectly. Passing just ONE value, you will get back only ONE coordinate (either X or Y, but not both). Neither ValueToPixel nor PaintInfo can be called from a script, both require typed variables. These functions only work when the chart is already visible and has a size assigned. The best way to achieve what you need is to attach the annotation object to the logical coordinates of the bar in question as follows: fromvalue = oChart.IniValueEx(0, i) tovalue = oChart.IniValueEx(0, i) ObjText.Attach ATTACH_ELASTIC,CStr(i)+","+CStr(fromvalue)+","+CStr(i+1)+","CStr(tovalue) -- 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.