User (Legacy) Posted September 24, 2004 Report Share Posted September 24, 2004 I would like to display a label for the time and date seperately on the X Axis. I have the time displayed from 0 to 24 and I am re-scaling the X Axis depending on the number of days selected. The scaling calc is probably not perfect yet. I want to show the date in format 'MM/DD/YYYY' seperately. In other words, I want to show the time as the main label and have accomplished this but I also want to indicate when the date changes. Something like this: 1, 2, 3, 4, 5, ...... 24, 1, 2, 3, 4, 5, ...... 9/19/2004...........9/20/2004 I need to use the following settings to scale time: Chart1.AxisX.Min Chart1.AxisX.Max Chart1.AxisX.Step Chart1.AxisX.MinorStep I am returning the date/time value in two seperate fields in the DataSet. One I am using for the Label and the other for the Value. How can I include the date when it changes? Thanks. Jay Barbee Here is some example data: Value_Date_1 Value_Date_2 Value 2004-04-29 00:00:06.730 2004-04-29 00:00:06.730 72.985474 2004-04-29 00:00:06.733 2004-04-29 00:00:06.733 72.985474 The two date fields are SQL Server datetime data types. Here is the code: 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) 'Need to create the title dynamically 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.Red Chart1.BorderColor = Color.Black Chart1.BackColor = Color.Black Chart1.InsideColor = Color.Black Chart1.PageColor = Color.Red Chart1.AxisX.Grid.Color = Color.Black Chart1.AxisX.TextColor = Color.Red Chart1.AxisY.TextColor = Color.Red Chart1.Series(1).Color = Color.Red Chart1.AxisX.LabelsFormat.Format = AxisFormat.DateTime Chart1.AxisX.LabelsFormat.CustomFormat = "HH:mm" 'Chart1.AxisX.LabelsFormat.CustomFormat = "yyyy-mm-dd hh:mm:ss" 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.Gridlines = True 'Chart1.AxisX.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dot Chart1.AxisX.Title.Font = GraphFontSmall 'Chart1.AxisX.Style = Chart1.AxisX.Style And Not AxisStyle.AutoFirstLabel '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) 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.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 = 0.5 Chart1.Series(1).YAxis = YAxis.Main Chart1.DataSource = oDataGraph.GetRawData(ddlPoint.SelectedItem.Text, tbBeginDate.Text, tbEndDate.Text).Tables(0) Chart1.DataBind() Chart1.Visible = True Cache.Insert("chart1", Chart1) Catch ex As Exception lblStatus.Text = ex.Message End Try End Sub Link to comment Share on other sites More sharing options...
Software FX Posted September 27, 2004 Report Share Posted September 27, 2004 What you can do is to create another X-Axis. Your Main X-Axis will have the times, and your secondary X-Axis will have the dates. For example: // Main X-Axis will contain the time. chart1.AxisX.LabelsFormat.Format = AxisFormat.Time; chart1.AxisX.LabelsFormat.CustomFormat = "HH"; chart1.AxisX.DataFormat.Format = AxisFormat.DateTime; chart1.AxisX.Step = 1/24.0; // 1 hour // Secondary X-Axis contains the Date. 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; -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.