Jump to content
Software FX Community

Re: Secondary X Axis Dates


User (Legacy)

Recommended Posts

I tried this and it still does not work.  It is as if the second XAxis is

not aware of the data at all. Here is my code and some example data.

WRITTEN_DATE, WRITTEN_DATE1, VALUE

2004-04-29 11:33:11.087, 2004-04-29 11:33:11.087, 6.940413

2004-04-29 11:33:26.087, 2004-04-29 11:33:26.087, 7.186521

2004-04-29 11:33:41.090, 2004-04-29 11:33:41.090, 7.252600

Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles btnRefresh.Click

Try

If tbBeginDate.Text.Length = 0 Then

Dim oJava As New JAVA.Script

MasterPage.StartupScript = oJava.SetFocus("tbBeginDate")

Throw New Exception("Begin Date Required")

End If

If tbEndDate.Text.Length = 0 Then

Dim oJava As New JAVA.Script

MasterPage.StartupScript = oJava.SetFocus("tbEndDate")

Throw New Exception("End Date Required")

End If

If tbBeginDate.Text > tbEndDate.Text Then

Dim oJava As New JAVA.Script

MasterPage.StartupScript = oJava.SetFocus("tbBeginDate")

Throw New Exception("Begin Date must be earlier than End Date.")

End If

Cache.Remove("chart1")

Dim oDataGraph As New

ProcessData(ConfigurationSettings.AppSettings("HydraDataSource"))

Dim sbTitle As New System.Text.StringBuilder

Dim GraphFontSmall As New System.Drawing.Font("Arial", 8,

System.Drawing.FontStyle.Bold)

Dim GraphFontLarge As New System.Drawing.Font("Arial", 14,

System.Drawing.FontStyle.Bold)

Dim Title As Internet.Server.TitleDockable

'Calculate the diffence between the dates entered.

Dim dteDiff As Long = 0

dteDiff = DateDiff(DateInterval.Day, CDate(tbBeginDate.Text),

CDate(tbEndDate.Text))

Title = Chart1.Titles(0)

sbTitle.Append(ddlPoint.SelectedItem.Text)

sbTitle.Append(": ")

sbTitle.Append(tbBeginDate.Text)

sbTitle.Append(" to ")

sbTitle.Append(tbEndDate.Text)

Title.Text = sbTitle.ToString

Title.Font = GraphFontLarge

Chart1.ContextMenus = True

Chart1.Gallery = SoftwareFX.ChartFX.Gallery.Lines

'Colors

Title.TextColor = Color.Blue

Chart1.BorderColor = Color.Black

Chart1.BackColor = Color.White

Chart1.InsideColor = Color.White

Chart1.PageColor = Color.Blue

Chart1.AxisX.Grid.Color = Color.White

Chart1.AxisX.TextColor = Color.Blue

Chart1.AxisY.TextColor = Color.Blue

Chart1.Series(1).Color = Color.Red

Chart1.AxisX.LabelsFormat.Format = AxisFormat.DateTime

Chart1.AxisX.LabelsFormat.CustomFormat = "HH:mm"

Chart1.AxisX.Staggered = True

Chart1.AxisX.Visible = True

Chart1.AxisX.Min = 0 * dteDiff

Chart1.AxisX.Max = 24 * dteDiff

Chart1.AxisX.Step = 240 * dteDiff

Chart1.AxisX.MinorStep = 60 * dteDiff

'Max - 24 hours in a day.

'Step - (4 values a minute - 1 Every 15 sec. 4 * 60 in an hour. 4*60 = 240)

'MinorStep is the 60 minute in an hour so shows a mark every 15 mintues

Chart1.AxisX.MinorTickMark = SoftwareFX.ChartFX.TickMark.Cross

Chart1.AxisX.Title.Font = GraphFontSmall

'Secondary X-Axis contains the Date.

Dim axisX2 As SoftwareFX.ChartFX.Internet.Server.Axis

axisX2 = Chart1.Axis(3)

axisX2.YAxis = False

axisX2.Visible = True

axisX2.Position = AxisPosition.Near

axisX2.LabelsFormat.Format = AxisFormat.Date

'Align with main X-axis

axisX2.Min = Chart1.AxisX.Min - 1

axisX2.Max = Chart1.AxisX.Max - 1

axisX2.Style = AxisStyle.Centered

'Chart1.AxisY.Interlaced = True

Chart1.AxisY.LabelsFormat.Format = AxisFormat.Number

Chart1.AxisY.Min = oDataGraph.MinValue(ddlPoint.SelectedItem.Text,

tbBeginDate.Text, tbEndDate.Text)

Chart1.AxisY.Max = oDataGraph.MaxValue(ddlPoint.SelectedItem.Text,

tbBeginDate.Text, tbEndDate.Text)

If Chart1.AxisY.Min = Chart1.AxisY.Max Then

Chart1.AxisY.Min = Chart1.AxisY.Min - 1

Chart1.AxisY.Max = Chart1.AxisY.Max + 1

End If

Chart1.AxisY.Step = Math.Round(((Chart1.AxisY.Max - Chart1.AxisY.Min) *

0.1))

Chart1.AxisY.Title.Alignment = StringAlignment.Center

Chart1.AxisY.Title.Text = "Value"

Chart1.AxisY.Title.TextColor = Color.Blue

Chart1.AxisY.Title.Font = GraphFontSmall

Chart1.AxisY.Font = GraphFontSmall

Chart1.AxisY.ForceZero = False

Chart1.DataSourceSettings.DataType(0) = DataType.Label

Chart1.DataSourceSettings.DataType(1) = DataType.Value

Chart1.DataSourceSettings.DataType(2) = DataType.Value

Chart1.DataEditorObj.Visible = False

Chart1.Series(1).LineStyle = Drawing2D.DashStyle.Solid

Chart1.Series(1).LineWidth = 1

Chart1.Series(1).YAxis = YAxis.Main

Chart1.DataSource = oDataGraph.GetRawData(ddlPoint.SelectedItem.Text,

tbBeginDate.Text, tbEndDate.Text).Tables(0)

Chart1.DataBind()

'This is what you suggested.

axisX2.Min = Chart1.AxisX.Min

axisX2.Max = Chart1.AxisX.Max

'Need to implement the auto refresh feature. Have a toggle button to turn

feature on and off.

'Also, dress the chart up as much as possible. Implement MouseOver Data

Label.

Chart1.Visible = True

Cache.Insert("chart1", Chart1)

Catch ex As Exception

lblStatus.Text = ex.Message

End Try

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

news:eMF$sMaxEHA.3492@webserver3.softwarefx.com...

> This secondary X-Axis is completely detached from your data. You need to

> manipulate the Min and Max of this axis to "synchronize it" with the main

> X-Axis.

>

> After setting the data (after the Main X-Axis is all set) you can do:

>

> axisX2.Min = chart.AxisX.Min;

> axisX2.Max = chart.AxisX.Max;

>

> --

> FP

> Software FX

>

>

Link to comment
Share on other sites

Its hard to tell with all that code and not having your data. Here is a 

sample program I put togethwe that demostrate how to synchronize the two

X-Axes:

DateTime dt = new DateTime(2004,1,1);

TimeSpan interval = new TimeSpan(0,0,15,0,0);

chart1.Gallery = Gallery.Lines;

chart1.MarkerShape = MarkerShape.None;

// Axis X Configuration

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

chart1.AxisX.LabelsFormat.CustomFormat = "hh:mm";

// Fill chart with data at intervals of 15 minutes

int n = 288;

chart1.OpenData(COD.Values,1,n);

chart1.OpenData(COD.XValues,1,n);

for (int i = 0; i < n; i++) {

chart1.Value[0,i] = i*10;

chart1.XValue[0,i] = dt.ToOADate();

dt = dt.Add(interval);

}

chart1.CloseData(COD.XValues);

chart1.CloseData(COD.Values);

// Axis X2 Configuration

Axis axisX2 = chart1.Axis[3];

axisX2.LabelsFormat.Format = AxisFormat.Date;

axisX2.Position = AxisPosition.Near;

axisX2.YAxis = false;

axisX2.Style |= AxisStyle.Centered;

axisX2.Min = chart1.AxisX.Min-1; // -1 because I want to offset the labels

by one day as they are centered instead of being at the end of the period.

axisX2.Max = chart1.AxisX.Max-1;

--

FP

Software FX

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...