NumberFormat does not change the label format

S

Sputnik

I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
A

Alvin Bruney [MVP]

numberformatting code has been posted in one form or the other in this forum
for years now. If you google the archives you will find a suitable snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
S

Sputnik

Alvin,

Below is an example (based upon a microsoft example). If you save this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian
numberformatting code has been posted in one form or the other in this forum
for years now. If you google the archives you will find a suitable snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
A

Alvin Bruney [MVP]

I'll take a look at this when i have a chance, been kinda busy lately sorry.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
Alvin,

Below is an example (based upon a microsoft example). If you save this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian
numberformatting code has been posted in one form or the other in this
forum
for years now. If you google the archives you will find a suitable
snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
A

Alvin Bruney [MVP]

This is not a bug, it's a feature - you must love that.

With axis type set to chAxisGroupingTypeNone, the chart disables the
formatting of axis. Consequently, there's no workaround. In fact, when you
run the code, you should see a script error at the number format line which
should clue you in that support is disabled. Here's a similar thread for
reference: (watch for line wrap
http://www.dbforums.com/archive/index.php/t-364025.html)

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
Alvin,

Below is an example (based upon a microsoft example). If you save this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian
numberformatting code has been posted in one form or the other in this
forum
for years now. If you google the archives you will find a suitable
snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
S

Sputnik

I thought that would be the case.

The problem that I am actually trying to get round is that the regional
settings seem to have absolutely no affect on the format of dates on
OWC graphs. If I change the regional settings and restart the web
application then the graph shows british date formats on one machine
and american on the other even though the regional settings are
identical on both machines. This is really confusing.

Is there any reason that you can think why regional settings may not
have any affect on the date format?

Thanks

Ian

This is not a bug, it's a feature - you must love that.

With axis type set to chAxisGroupingTypeNone, the chart disables the
formatting of axis. Consequently, there's no workaround. In fact, when you
run the code, you should see a script error at the number format line which
should clue you in that support is disabled. Here's a similar thread for
reference: (watch for line wrap
http://www.dbforums.com/archive/index.php/t-364025.html)

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
Alvin,

Below is an example (based upon a microsoft example). If you save this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian
numberformatting code has been posted in one form or the other in this
forum
for years now. If you google the archives you will find a suitable
snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
S

Sputnik

In fact nothing in the regional settings seems to have any affect on
the format of the graph dates. Do you know which settings in the
regional settings should change the graph format?

I thought that also setting the thread culture would do the trick i.e.

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

but this does not work either.

Any help would be appreciated.

Regards

Ian

I thought that would be the case.

The problem that I am actually trying to get round is that the regional
settings seem to have absolutely no affect on the format of dates on
OWC graphs. If I change the regional settings and restart the web
application then the graph shows british date formats on one machine
and american on the other even though the regional settings are
identical on both machines. This is really confusing.

Is there any reason that you can think why regional settings may not
have any affect on the date format?

Thanks

Ian

This is not a bug, it's a feature - you must love that.

With axis type set to chAxisGroupingTypeNone, the chart disables the
formatting of axis. Consequently, there's no workaround. In fact, when you
run the code, you should see a script error at the number format line which
should clue you in that support is disabled. Here's a similar thread for
reference: (watch for line wrap
http://www.dbforums.com/archive/index.php/t-364025.html)

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
Alvin,

Below is an example (based upon a microsoft example). If you save this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian

Alvin Bruney [MVP] wrote:
numberformatting code has been posted in one form or the other in this
forum
for years now. If you google the archives you will find a suitable
snippet.

Regional settings depend on the client computer which is set in control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


I am trying to use the NumberFormat property on the X Axis on an OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format at
all.

In fact on one machine the dates come out in US format and on another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 
A

Alvin Bruney [MVP]

i'm re-reading the thread and i am kinda lost as to what you are trying to
do. You've set the chAxisGroupingTypeNone which disables axis formatting.
Doesn't matter what you do after this, your formatting won't take effect.
Are you saying that when you do not have chAxisGroupingTypeNone set, then
the number format is still not working? Because it is working nicely on my
machine according to the number format i specify.

with the number formatting on, the axis should recognize dates. If there is
no specific date format, the regional settings will be used on the computer.
If you force formatting, the regional settings should be overridden. There
are some quirks with regional format and OWC but I doubt this should be a
concern at this point.
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Sputnik said:
In fact nothing in the regional settings seems to have any affect on
the format of the graph dates. Do you know which settings in the
regional settings should change the graph format?

I thought that also setting the thread culture would do the trick i.e.

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

but this does not work either.

Any help would be appreciated.

Regards

Ian

I thought that would be the case.

The problem that I am actually trying to get round is that the regional
settings seem to have absolutely no affect on the format of dates on
OWC graphs. If I change the regional settings and restart the web
application then the graph shows british date formats on one machine
and american on the other even though the regional settings are
identical on both machines. This is really confusing.

Is there any reason that you can think why regional settings may not
have any affect on the date format?

Thanks

Ian

This is not a bug, it's a feature - you must love that.

With axis type set to chAxisGroupingTypeNone, the chart disables the
formatting of axis. Consequently, there's no workaround. In fact, when
you
run the code, you should see a script error at the number format line
which
should clue you in that support is disabled. Here's a similar thread
for
reference: (watch for line wrap
http://www.dbforums.com/archive/index.php/t-364025.html)

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------



Alvin,

Below is an example (based upon a microsoft example). If you save
this
as an .htm file and load it into IE you will see what I mean (you may
need to change the clsid id - see article
http://support.microsoft.com/kb/289288/). Click on the button and you
will see that the dates have been correctly formatted as specified in
the script i.e.mm-dd-yyyy. If you select yes on the message box that
is
displayed then the grouping type is set to chAxisGroupingNone. When
this is done the NumberFormat is ignored.

Here is the code:

<html>
<body>
<p align="Left"/>
<button id="btnChart1" style="width:30%">TimeScale With Missing
Dates</button><br/><br/>
<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="SSheet" width="30%" height="75%">
</object>  
<object classid="clsid:0002E556-0000-0000-C000-000000000046"
id="CSpace" width="65%" height="75%">
</object>
</body>

<script language="VBScript">

'
' This example is based upon the example from microsoft
(http://support.microsoft.com/kb/289288/)
'

Dim c
Set c = CSpace.Constants

Function BuildWorksheet1()

'Builds a worksheet with dates in A2:A5 and numeric values
representing
'sales figures in B2:B5.
Dim oSheet
Set oSheet = SSheet.Worksheets(1)
oSheet.Cells.Clear
oSheet.Range("A1:B1").Value = Array("Date", "Sale")
oSheet.Range("A2:B2").Value = Array(#1/1/2001#, 3000)
oSheet.Range("A3:B3").Value = Array(#3/5/2001#, 1850)
oSheet.Range("A4:B4").Value = Array(#3/23/2001#, 2790)
oSheet.Range("A5:B5").Value = Array(#6/7/2001#, 4925)
oSheet.Range("A2:A5").NumberFormat = "mmm d, yyyy"

End Function

Function btnChart1_OnClick()

BuildWorksheet1

'Bind the Chart component to the spreadsheet. Categories are in
A2:A5 and
'values are in B2:B5.
CSpace.Clear
Set CSpace.DataSource = SSheet
CSpace.SetData c.chDimCategories, c.chDataBound, "A2:A5"
CSpace.SetData c.chDimValues, c.chDataBound, "B2:B5"
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"

'Prompt to disable timescale functionality.
Dim RetVal
RetVal = MsgBox("Disable time scale functionality?", vbYesNo)
If RetVal = vbYes Then
'We want a continuous timescale axes so set the grouping to none
CSpace.Charts(0).Axes(chAxisPositionCategory).GroupingType =
c.chAxisGroupingNone
CSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat =
"mm-dd-yyyy"
End If

End Function

</script>
</html>

As you can see setting the grouping to none effectively ignores the
formatting. Any ideas?

Thanks

Ian

Alvin Bruney [MVP] wrote:
numberformatting code has been posted in one form or the other in
this
forum
for years now. If you google the archives you will find a suitable
snippet.

Regional settings depend on the client computer which is set in
control
panel.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


I am trying to use the NumberFormat property on the X Axis on an
OWC
graph component in ASP .NET.

The X axis is populated by a series of dates from a SQL query.

This is what I am doing:

// Add the dates to the array (a series of dates are added)
rgDates.Add(SqlData.GetDateTime(idxDate));

// Set the dates
Series.SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral,
rgDates.ToArray());
DateAxis.HasTitle = true;
DateAxis.NumberFormat = "MM/YYYY"
DateAxis.GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;

Setting the NumberFormat does not seem to change the label format
at
all.

In fact on one machine the dates come out in US format and on
another
in UK format even though the regional settings are identical.

Does anyone know how to get the x axis labels to use a different
date
format? Is there a workaround which will allow me to do this?

Regards

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top