I have been trying to solve this issue from some time now. The symptom is with the X axis I see that the value get overrided to a lower value from what I have set it at in Chart1.ChartAreas(0).AxisX.Minimum = Xmin (8.5 in this case) . However when I times the values by 100 the curve seems to center to a min and max. I am also not experiencing this with the Y axis at all. In the picture attached I am setting the min to 8.5 ( as seen where the curve starts in the picture. I also notice if I set the min below 8 it will let me set it to that. So this leads me to believe there is some sort of value that its overriding ratio to make the minimum inside of MSchart.
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.IO
Imports System.Drawing
Public Class Test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim value As Double
Dim xxmax As Double
Dim yymax As Double
Dim xxmin As Double
Dim yymin As Double
Dim XPlot As New ArrayList
Dim YPlot As New ArrayList
XPlot.Add(10.1)
XPlot.Add(10.15)
XPlot.Add(10.2)
XPlot.Add(10.25)
XPlot.Add(10.3)
YPlot.Add(1)
YPlot.Add(2)
YPlot.Add(3)
YPlot.Add(4)
YPlot.Add(5)
xxmin = 10.1
xxmax = 10.3
yymin = 1
yymax = 5
Chart1.Series.Clear()
Chart1.Series.Add("Polfit Fit")
Chart1.Series("Polfit Fit").XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.Int32
Chart1.Series("Polfit Fit").ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line
Chart1.Series.Add("Plotted Data")
Chart1.Series("Plotted Data").XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.Int32
Chart1.Series("Plotted Data").ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Point
Chart1.Series("Plotted Data").MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Circle
Chart1.Series("Plotted Data").MarkerSize = 10
Chart1.Series("Plotted Data").MarkerColor = Color.Green
Chart1.Series("Polfit Fit").Color = Color.Blue
Dim mylegend As New System.Web.UI.DataVisualization.Charting.Legend
mylegend.Font = New System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold)
mylegend.Name = "Legend"
mylegend.BorderWidth = 4
mylegend.BorderColor = Color.Black
mylegend.Docking = DataVisualization.Charting.Docking.Right
Chart1.Legends.Add(mylegend)
Chart1.ChartAreas(0).AxisX.Title = Value
Chart1.ChartAreas(0).AxisX.TitleFont = New System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold)
Chart1.ChartAreas(0).AxisY.TitleFont = New System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold)
Chart1.ChartAreas(0).AxisY.Title = "Margin Of Safety"
Chart1.ChartAreas(0).AxisX.IsMarginVisible = True
Chart1.ChartAreas(0).AxisY.IsMarginVisible = True
Chart1.ChartAreas(0).AxisY.IsStartedFromZero = False
Chart1.ChartAreas(0).AxisX.IsStartedFromZero = False
Chart1.ChartAreas(0).AxisX.Interval = 0.05
Chart1.ChartAreas(0).AxisY.Interval = 0.05
Chart1.ChartAreas(0).AxisX.Maximum = Math.Round((xxmax + Math.Abs(xxmax * 0.0)), 6)
Chart1.ChartAreas(0).AxisX.Minimum = Math.Round((xxmin - Math.Abs(xxmax * 0.0)), 6)
Chart1.ChartAreas(0).AxisY.Maximum = Math.Round((yymax + Math.Abs(yymax * 0.0)), 6)
Chart1.ChartAreas(0).AxisY.Minimum = Math.Round((yymin - Math.Abs(yymin * 0.0)), 6)
Chart1.Height = 600
Chart1.Width = 1500
Dim j
Dim b
While j < XPlot.Count
If Not YPlot(j) = "0" And Not (CDbl(XPlot(j)) / CDbl(YPlot(j)) = 1) Then
Dim point As New System.Web.UI.DataVisualization.Charting.DataPoint
point.SetValueXY((XPlot(j)), (YPlot(j)))
Chart1.Series("Plotted Data").Points.Add(point)
End If
j += 1
End While
b = 0
End Sub
End Class
<%@ Page Language="VB" Inherits ="Test" CodeFile ="Test.vb" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server" >
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</form>
</body>
</html>
series.IsXValueIndexed = true;
, if it is true you might need to set it to false. It's hard to know for sure what the problem is since you have provided no code, for all we know somewhere in your code you could be resetting the x minimum to a lower value from 8.5. - Baddackchart1.ChartAreas[0].AxisX.IsStartedFromZero = false;
- Baddack