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