Jump to content
Software FX Community

Number of points in x axis


User (Legacy)

Recommended Posts

I suspect I am missing something basic here but ...

I want to establish how many points there are in the x axis so that I

can scale my data and labels to fit.

i.e I have time based data. If I can only show every 2 minutes I will

step the labels by 2 but if I can show every minute I will step by one.

I am sure that I am being dumb here but ...

Many thanks for any help.

Jack Russell

Link to comment
Share on other sites

I don't exactly understand what you want to do.

There is 2 main types of chart in relation to labels:

1) Categorical charts: You supply Y-Value and a label for each point. Each

point has a label attached to it. Chart FX will automatically select a Step

in the X-Axis to fit as many labels as possible depending on your Axis Style

(Vertical Labels, Staggered, etc.). You can also et the Step manually using

AxisX.Step.

2) X/Y Chats: Each point has a X-Value and a Y-Value. You can either set an

axis format (Date, Time, etc.) or you can assign string labels to the

X-Axis. In this case the labels are attached to the axis NOT to the points.

Again, Chart FX can choose a step or you can set your own. In an X/Y chart,

the number of labels is independent of the number of points.

--

FP

Software FX

Link to comment
Share on other sites

SoftwareFX Support wrote:

> I don't exactly understand what you want to do.

>

> There is 2 main types of chart in relation to labels:

>

> 1) Categorical charts: You supply Y-Value and a label for each point. Each

> point has a label attached to it. Chart FX will automatically select a Step

> in the X-Axis to fit as many labels as possible depending on your Axis Style

> (Vertical Labels, Staggered, etc.). You can also et the Step manually using

> AxisX.Step.

>

> 2) X/Y Chats: Each point has a X-Value and a Y-Value. You can either set an

> axis format (Date, Time, etc.) or you can assign string labels to the

> X-Axis. In this case the labels are attached to the axis NOT to the points.

> Again, Chart FX can choose a step or you can set your own. In an X/Y chart,

> the number of labels is independent of the number of points.

>

Sorry, I will try to explain again. I have a series of experiments

lasting different amounts of time.

I could not work out how to set the time format and thought that I would

have to make my own up (although I would rather not).

Ideally I would like a label at every minute (i.e. 1 ,2 ,3 etc)

However with a long test there is obviously not enough room so I assume

that I need to be able to work out the steps for the labels (i.e 5

minutes or 10 minutes). To do that I need to be able to find out the

"width" of the graph area.

As I said originally I think I must be missing something basic here,

Chart Fx seems to do everything else for me.

Thanks for your patience,

Link to comment
Share on other sites

Jack Russell wrote:

> SoftwareFX Support wrote:

>

>> I don't exactly understand what you want to do.

>>

>> There is 2 main types of chart in relation to labels:

>>

>> 1) Categorical charts: You supply Y-Value and a label for each point.

>> Each

>> point has a label attached to it. Chart FX will automatically select a

>> Step

>> in the X-Axis to fit as many labels as possible depending on your Axis

>> Style

>> (Vertical Labels, Staggered, etc.). You can also et the Step manually

>> using

>> AxisX.Step.

>>

>> 2) X/Y Chats: Each point has a X-Value and a Y-Value. You can either

>> set an

>> axis format (Date, Time, etc.) or you can assign string labels to the

>> X-Axis. In this case the labels are attached to the axis NOT to the

>> points.

>> Again, Chart FX can choose a step or you can set your own. In an X/Y

>> chart,

>> the number of labels is independent of the number of points.

>>

> Sorry, I will try to explain again. I have a series of experiments

> lasting different amounts of time.

> I could not work out how to set the time format and thought that I would

> have to make my own up (although I would rather not).

>

> Ideally I would like a label at every minute (i.e. 1 ,2 ,3 etc)

> However with a long test there is obviously not enough room so I assume

> that I need to be able to work out the steps for the labels (i.e 5

> minutes or 10 minutes). To do that I need to be able to find out the

> "width" of the graph area.

>

> As I said originally I think I must be missing something basic here,

> Chart Fx seems to do everything else for me.

>

> Thanks for your patience,

I must be missing a very basic point.

If I try to open a graph with too many points it just displays nothing.

i.e. I found by trial and error that with a chart on a maximised form

I could draw 700 points. When I make the form (and its attached chart)

smaller and try to draw 700 points I just end up with a totally blank

chart (no legends etc).

As I support resizable forms how do I tell how many points I can show on

the chart?

(perhaps I should explain all the charting I have done before has been

at the nuts and bolts level using windows api calls to draw or straight

to memory under dos so maybe I am trying too hard!)

Link to comment
Share on other sites

> Ideally I would like a label at every minute (i.e. 1 ,2 ,3 etc)

> However with a long test there is obviously not enough room so I assume

> that I need to be able to work out the steps for the labels (i.e 5

> minutes or 10 minutes). To do that I need to be able to find out the

> "width" of the graph area.

I think what you want is an X/Y chart. For each point, you are going to set

both X-Value (Time) and the Y-Value (experiment result).

The you are going to set the X-Axis format to Time as follows:

chart.AxisX.LabelsFormat.Format = AxisFormat.Time;

This should be enough. Chart FX will calculate a "nice" step depending on

the available space and the size of your labels. As I mentioned before you

can play with different styles (LabelAngle, Staggered, etc.) to make more

room for the labels.

You should not need to calculate your own step based on the chart width.

This will be quite complicated as you will need to measure the labels (in

pixels) and then the available space, rounding, etc. All that is already

built into the axis object.

So in conclusion, if you let Chart FX do its job it will be much easier. Try

this simple things and let me know if that works out for you.

Examples of X/Y charts can be found in the documentation.

--

FP

Software FX

Link to comment
Share on other sites

SoftwareFX Support wrote:

>>Ideally I would like a label at every minute (i.e. 1 ,2 ,3 etc)

>>However with a long test there is obviously not enough room so I assume

>>that I need to be able to work out the steps for the labels (i.e 5

>>minutes or 10 minutes). To do that I need to be able to find out the

>>"width" of the graph area.

>

>

> I think what you want is an X/Y chart. For each point, you are going to set

> both X-Value (Time) and the Y-Value (experiment result).

>

> The you are going to set the X-Axis format to Time as follows:

>

> chart.AxisX.LabelsFormat.Format = AxisFormat.Time;

>

> This should be enough. Chart FX will calculate a "nice" step depending on

> the available space and the size of your labels. As I mentioned before you

> can play with different styles (LabelAngle, Staggered, etc.) to make more

> room for the labels.

>

> You should not need to calculate your own step based on the chart width.

> This will be quite complicated as you will need to measure the labels (in

> pixels) and then the available space, rounding, etc. All that is already

> built into the axis object.

>

> So in conclusion, if you let Chart FX do its job it will be much easier. Try

> this simple things and let me know if that works out for you.

>

> Examples of X/Y charts can be found in the documentation.

>

>

Thanks, that looks brilliant.

I took me a while to work out that I needed two opendata and closedata

statements.

If you do not do that VB gives a totally meaningless error message!

Thanks again.

Link to comment
Share on other sites

Nearly there but ...

To recap my problem. I have data recorded in elapsed seconds.

By plotting an xy graph with x as seconds divided by 60 I get exactly

the graph that I want with the x axis labels in elapsed minutes (i.e 1,2

3 etc.)

Everything looks perfect until I use the data editor or hover the mouse

on the graph. Then I see only minutes in the data whereas I want to see

seconds for each point.

Is there any way around this, I can obviuosly write my own data editor

and can presumably take over the mouse hover but it seems a pity when

you guys do it so well.

Link to comment
Share on other sites

SoftwareFX Support wrote:

> Can you please attach a screenshot of this. I don't understand where is this

> data appearing.

>

Here is my code and a screenshot.

As you can see I divide datatime (held in seconds) by 60 to get the x

axis labels to show minutes. The graph is exactly as I want it.

However when I show the data editor or mouse hover the x values are all

minutes (as they would be since that is what I gave it). Ideally I would

like this to show minutes and seconds or just seconds.

Thanks again for your patience.

For i = 1 To j 'ReadData.iDataPoints

If DataArray(k).iDataPoints <> 0 Then

If i > DataArray(k).iDataPoints Then

.Value(k - 1, i) = Chart.Hidden

.XValue(k - 1, i) = Chart.Hidden

Else

.Value(k - 1, i) = DataArray(k).iDataVisc(i)

.XValue(k - 1, i) = DataArray(k).iDataTime(i) / 60

End If

End If

Next i

Jack Russell

Link to comment
Share on other sites

SoftwareFX Support wrote:

> Can you please attach a screenshot of this. I don't understand where is this

> data appearing.

>

Here is my code and a screenshot.

As you can see I divide datatime (held in seconds) by 60 to get the x

axis labels to show minutes. The graph is exactly as I want it.

However when I show the data editor or mouse hover the x values are all

minutes (as they would be since that is what I gave it). Ideally I would

like this to show minutes and seconds or just seconds.

Thanks again for your patience.

For i = 1 To j 'ReadData.iDataPoints

If DataArray(k).iDataPoints <> 0 Then

If i > DataArray(k).iDataPoints Then

.Value(k - 1, i) = Chart.Hidden

.XValue(k - 1, i) = Chart.Hidden

Else

.Value(k - 1, i) = DataArray(k).iDataVisc(i)

.XValue(k - 1, i) = DataArray(k).iDataTime(i) / 60

End If

End If

Next i

Jack Russell

Chartfx.bmp

Link to comment
Share on other sites

Ok. I see.

1) In the X-Axis you are not displaying a time format. Like 1:00. Is that

what you want ?

2) To change the format used in the Data Editor and Tooltip without

affecting the format used in the axis labels you can do:

chart.AxisY.DataFormat.Decimals = 2;

Or:

chart.AxisY.DataFormat.Format = AxisFormat.Time;

chart.AxisY.DataFormat.CustomFormat = "mm:ss";

If the data is actually time data, if you are passing 1,2,3 ... etc. as your

X-Values this won't work you need to pass DateTime data.

--

FP

Software FX

ChartFx.zip

Link to comment
Share on other sites

SoftwareFX Support wrote:

> Ok. I see.

>

> 1) In the X-Axis you are not displaying a time format. Like 1:00. Is that

> what you want ?

Yes

>

>

> chart.AxisY.DataFormat.Format = AxisFormat.Time;

> chart.AxisY.DataFormat.CustomFormat = "mm:ss";

>

> If the data is actually time data, if you are passing 1,2,3 ... etc. as your

> X-Values this won't work you need to pass DateTime data.

>

But Vb wont let me pass a datetime to xvalue, only a double.

Sorry to be so thick

Link to comment
Share on other sites

Yippee

Its ok, I think that I have cracked it.

I could never have done it without your help.

Jack Russell

Jack Russell wrote:

> SoftwareFX Support wrote:

>

>> Ok. I see.

>>

>> 1) In the X-Axis you are not displaying a time format. Like 1:00. Is

>> that what you want ?

>

> Yes

>

>>

>>

>> chart.AxisY.DataFormat.Format = AxisFormat.Time;

>> chart.AxisY.DataFormat.CustomFormat = "mm:ss";

>>

>> If the data is actually time data, if you are passing 1,2,3 ... etc.

>> as your X-Values this won't work you need to pass DateTime data.

>>

> But Vb wont let me pass a datetime to xvalue, only a double.

>

> Sorry to be so thick

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...