Jump to content
Software FX Community

Align series with other controls on the screen


Recommended Posts

Hi,

I'm using a bar chart type in the Chart FX 98 control and I'm trying to

align the bars in the chart with other controls on the screen.

My x-axis consists of years values. The number of years that can show on

the graph range from 5 to 10 depending on what the user selects. I want to

put a text box underneath each of the bars and have it line up exactly with

the bar above it. Is there any way to do this? I think I need the left

property for each bar and the width of each bar.

Thanks!

Link to post
Share on other sites

Yes, you can calculate this:

The bar size is calculated as follows:

BarWidth = ((((ChartWidth - LeftGap -

RightGap)/NumberOfPoints)/NumberOfSeries)*Volume)/100

The bars are evenly spaced along all the area.

You can use the ValueToPixel method to determine the position of a specific

tickmark in the X or Y axis.

--

FP

Software FX, Inc.

Link to post
Share on other sites

I'm having trouble determining the position of the specific coordinate using

the ValueToPixel method.

Here's my scenario.

I have a bar chart. It's name is chtMain. The values on the x-axis are

years that range from 1998 to 2006. The values on the y-axis shouldn't

matter because I don't care about the y-coordinate. Can someone give me an

example of how I would obtain the x-coordinate for say "2000"?

Here's how I would think you would do it: chtMain.ValueToPixel 2, 0,

x_return, y_return, AXIS_X

Thanks!

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:LGhb29ofCHA.3564@webserver1.softwarefx.com...

> Yes, you can calculate this:

>

> The bar size is calculated as follows:

>

> BarWidth = ((((ChartWidth - LeftGap -

> RightGap)/NumberOfPoints)/NumberOfSeries)*Volume)/100

>

> The bars are evenly spaced along all the area.

>

> You can use the ValueToPixel method to determine the position of a

specific

> tickmark in the X or Y axis.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

The value returned to me in x_return is way to small to be lined up with the

2nd value in the graph. Here's my code and a picture of what is happening.

The text box directly below the chart is named text1 and should be lining up

with the second bar but something's going wrong. Do I need to do anything

with the "leftgap"?

Thanks for your help!

Dim x_return As Long

Dim y_return As Long

chtMain.ValueToPixel 2, 0, x_return, y_return, AXIS_X

Text1.Left = x_return + chtmain.left ' chtmain.left is equal to 0

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:zLf02BtfCHA.3208@webserver1.softwarefx.com...

> chtMain.ValueToPixel 2, 0, x_return, y_return, AXIS_X

>

> Will return in x_return the pixel position (x coordinate) of the tickmark

> corresponding to 2, this corresponds to the MIDDLE of the bar group for

year

> 2000 (assuming consecutive years).

>

> What are you getting ?

>

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

Notice the x_return is in PIXELS, not in TWIPS. What is the value you are

getting back ? also it is important the timing, you must make sure the call

to ValueToPixel happens AFTER the chart has all the data and sizes. You need

to use UpdateSizeNow to make sure all calculations are finished if you need

to call ValueToPixel BEFORE the chart is ever drawn.

--

FP

Software FX, Inc.

Link to post
Share on other sites

Awesome!!!   Thanks!!!!!!!  I forgot to convert to twips.

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:3LhSvJ2fCHA.392@webserver1.softwarefx.com...

> Notice the x_return is in PIXELS, not in TWIPS. What is the value you are

> getting back ? also it is important the timing, you must make sure the

call

> to ValueToPixel happens AFTER the chart has all the data and sizes. You

need

> to use UpdateSizeNow to make sure all calculations are finished if you

need

> to call ValueToPixel BEFORE the chart is ever drawn.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

Hi,

I'm having trouble getting the bar width to work properly. In the attached

screenshot, I put a textbox (text1) in the chart area. I tried to get the

width of this text box to match the width of the bars but haven't had any

luck. Here's the code I've been using:

Dim lBarWidth As Long

lBarWidth = ((((chtMain.Width - chtMain.LeftGap - chtMain.RightGap) / 6)

/ 1) * chtMain.Volume) / 100

Text1.Width = lBarWidth

Thanks!!

Link to post
Share on other sites

Has anyone been able to figure this out???

Thanks!

"Jim Gaull" <jgaull@genisysinc.com> wrote in message

news:pcuWwDCgCHA.2308@webserver1.softwarefx.com...

> Hi,

>

> I'm having trouble getting the bar width to work properly. In the

attached

> screenshot, I put a textbox (text1) in the chart area. I tried to get the

> width of this text box to match the width of the bars but haven't had any

> luck. Here's the code I've been using:

>

> Dim lBarWidth As Long

>

> lBarWidth = ((((chtMain.Width - chtMain.LeftGap - chtMain.RightGap) /

6)

> / 1) * chtMain.Volume) / 100

>

> Text1.Width = lBarWidth

>

>

> Thanks!!

>

>

>

Link to post
Share on other sites

I add 1 to the number of data series and now it works perfectly.

lBarWidth = ((((chtMain.Width - chtMain.LeftGap - chtMain.RightGap) /

(chtMain.NValues + 1)) / chtMain.NSeries) * chtMain.Volume) / 100

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:9UmINBbhCHA.1748@webserver1.softwarefx.com...

> This code works for me. I put this calculation in a button and I get a

> textbox that EXACTLY the same width as the bar. I don't know what you are

> doing different. Please try to reproduce it in an EMPTY project.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...