2012-10-11 2 views
3

차트를 만들었지 만 Y.Axis와 차트 테두리 사이에 왼쪽 여백이 있습니다.차트 여백을 조정할 수 없습니다.

어떻게 할 수 있습니까?

차트와 테두리 사이에 5px 균일 한 여백 (왼쪽, 위쪽, 오른쪽, 아래쪽)을 정의 할 수 있습니까? 당신은 Axis.IsMarginVisible = false와 축 마진을 제거 할 수 있습니다

Chart chart = new Chart { 
    AntiAliasing = AntiAliasingStyles.All, 
    TextAntiAliasingQuality = TextAntiAliasingQuality.High, 
    BackColor = Color.FromArgb(250, 250, 250), 
    Height = size.Height, 
    Width = size.Width 
}; 

chart.Legends.Clear(); 

ChartArea area = new ChartArea { 
    BackColor = Color.Transparent, 
    BorderColor = Color.FromArgb(240, 240, 240), 
    BorderWidth = 1, 
    BorderDashStyle = ChartDashStyle.Solid, 
    AxisX = new Axis { 
    Enabled = AxisEnabled.True, 
    IntervalAutoMode = IntervalAutoMode.VariableCount, 
    IsLabelAutoFit = true, 
    IsMarginVisible = true, 
    LabelStyle = new LabelStyle { ForeColor = Color.FromArgb(100, 100, 100), Font = new Font("Arial", 10, FontStyle.Regular) }, 
    LineColor = Color.FromArgb(220, 220, 220), 
    MajorGrid = new Grid { LineColor = Color.FromArgb(240, 240, 240), LineDashStyle = ChartDashStyle.Solid }, 
    MajorTickMark = new TickMark { LineColor = Color.FromArgb(220, 220, 220), Size = 4.0f }, 
    }, 
    AxisY = new Axis { 
    Enabled = AxisEnabled.True, 
    IntervalAutoMode = IntervalAutoMode.VariableCount, 
    IsLabelAutoFit = true, 
    IsMarginVisible = true, 
    LabelStyle = new LabelStyle { ForeColor = Color.FromArgb(100, 100, 100), Font = new Font("Arial", 10, FontStyle.Regular) }, 
    LineColor = Color.Transparent, 
    MajorGrid = new Grid { LineColor = Color.FromArgb(240, 240, 240), LineDashStyle = ChartDashStyle.Solid }, 
    MajorTickMark = new TickMark { LineColor = Color.FromArgb(240, 240, 240), Size = 2.0f } 
    }, 
    Position = new ElementPosition { Height = 100, Width = 100, X = 0, Y = 0 } 
}; 

chart.ChartAreas.Add(area); 

area.AxisX.LabelStyle.Format = "H:mm"; 
area.AxisX.LabelStyle.IntervalType = DateTimeIntervalType.Hours; 

Series series = new Series { 
    CustomProperties = "PointWidth = 1", 
    IsXValueIndexed = true, 
    XValueType = (ChartValueType)Enum.Parse(typeof(ChartValueType), x.Data.GetType().GetGenericArguments()[0].Name) 
}; 

series.BorderWidth = 2; 
series.BorderColor = Color.FromArgb(84, 164, 232); 
series.ChartType = SeriesChartType.Area; 
series.Color = Color.FromArgb(222, 234, 244); 

series.Points.DataBindXY(x.Data, s.Data); 

chart.Series.Add(series); 

당신을 감사

미구엘

답변

3

:

내 차트 코드는 다음과 같다.
ChartArea.Position을 사용하여 차트 영역을 배치하거나 플로팅 영역의 위치를 ​​ChartArea.InnerPlotPosition

관련 문제