Home 소개       다운로드       온라인 설명서      주식차트    Q & A     Blog    

차트 영역 드래그 하기







차트 영역을 드래그하여 사각형의 영역을 만드는 기능입니다. 마우스업 이벤트를 통해 줌 기능을 응용 사용가능합니다.




차트 영역 드래그 하기  마우스 Move 이벤트를 통해 수치 표현  박스플롯차트 마우스 이벤트(수치보기)  범례 클릭 마우스 이벤트 주기  주식차트 마우스무브 이벤트로 십자 라인 그리기  라인차트 마우스무브 이벤트 데이터 수치 보이기  히포차트 4.3 - 현재 마우스가 위치한 곳의 YValue 값 알기  


C#
 
private void draw4()
{
this.hHippoChart1.SeriesListDictionary.Clear();

SeriesList sList = new SeriesList();
sList.ChartType = ChartType.Column;

Random r = new Random();
for(int i = 0; i < 5; i++)
{
Series sr = new Series();

for(int x = 0; x < 5; x++)
{
SeriesItem item = new SeriesItem();
item.Name = x.ToString();
item.YValue = r.Next(10, 70);

sr.items.Add(item);
}
sList.SeriesCollection.Add(sr);
}

this.hHippoChart1.DesignType = ChartDesignType.None;
this.hHippoChart1.PaletteType = PaletteType.Bright;
this.hHippoChart1.LegendBox.Visible = false;
this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart();

this.hHippoChart1.SetThemeSeries(Color.Black);

}

bool isDrag = false;
Point startPoint = new Point();
Rectangle theRectangle = new Rectangle();

private void hHippoChart1_ChartMouseMove(object sender, MouseEventArgs e)
{
if (isDrag)
{
ControlPaint.DrawReversibleFrame(theRectangle,
this.BackColor, FrameStyle.Dashed);

Point endPoint = ((Control)sender).PointToScreen(new Point(e.X, e.Y));

int width = endPoint.X - startPoint.X;
int height = endPoint.Y - startPoint.Y;
theRectangle = new Rectangle(startPoint.X,
startPoint.Y, width, height);

ControlPaint.DrawReversibleFrame(theRectangle,
this.BackColor, FrameStyle.Dashed);
}

}

private void hHippoChart1_ChartMouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isDrag = true;
}

Control control = (Control)sender;

startPoint = control.PointToScreen(new Point(e.X, e.Y));

}

private void hHippoChart1_ChartMouseUp(object sender, MouseEventArgs e)
{
isDrag = false;

ControlPaint.DrawReversibleFrame(theRectangle,
this.BackColor, FrameStyle.Dashed);

Rectangle controlRectangle;
for(int i = 0; i < Controls.Count; i++)
{
controlRectangle = Controls[i].RectangleToScreen
(Controls[i].ClientRectangle);
if (controlRectangle.IntersectsWith(theRectangle))
{
Controls[i].BackColor = Color.BurlyWood;
}
}

theRectangle = new Rectangle(0, 0, 0, 0);
}


VB
 
Private Sub draw4()
Me.hHippoChart1.SeriesListDictionary.Clear()

Dim sList As New. SeriesList()
sList.ChartType = ChartType.Column

Dim r As New. Random()
Dim i As Integer = 0
While i < 5
Dim sr As New. Series()

Dim x As Integer = 0
While x < 5
Dim item As New. SeriesItem()
item.Name = x.ToString()
item.YValue = r.[Next](10, 70)

sr.items.Add(item)
System.Math.Max(System.Threading.Interlocked.Increment(x),x - 1)
End While
sList.SeriesCollection.Add(sr)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Me.hHippoChart1.DesignType = ChartDesignType.None
Me.hHippoChart1.PaletteType = PaletteType.Bright
Me.hHippoChart1.LegendBox.Visible = False
Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()

Me.hHippoChart1.SetThemeSeries(Color.Black)

End Sub



Private isDrag As Boolean = False
Private startPoint As New. Point()
Private theRectangle As New. Rectangle()



Private Sub hHippoChart1_ChartMouseMove(sender As Object, e As MouseEventArgs)
If isDrag Then
ControlPaint.DrawReversibleFrame(theRectangle, Me.BackColor, FrameStyle.Dashed)

Dim endPoint As Point = (DirectCast(sender, Control)).PointToScreen(New Point(e.X, e.Y))

Dim width As Integer = endPoint.X - startPoint.X
Dim height As Integer = endPoint.Y - startPoint.Y
theRectangle = New Rectangle(startPoint.X, startPoint.Y, width, height)

ControlPaint.DrawReversibleFrame(theRectangle, Me.BackColor, FrameStyle.Dashed)
End If

End Sub



Private Sub hHippoChart1_ChartMouseDown(sender As Object, e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
isDrag = True
End If

Dim control As Control = DirectCast(sender, Control)

startPoint = control.PointToScreen(New Point(e.X, e.Y))

End Sub



Private Sub hHippoChart1_ChartMouseUp(sender As Object, e As MouseEventArgs)
isDrag = False

ControlPaint.DrawReversibleFrame(theRectangle, Me.BackColor, FrameStyle.Dashed)

Dim controlRectangle As Rectangle
Dim i As Integer = 0
While i < Controls.Count
controlRectangle = Controls(i).RectangleToScreen(Controls(i).ClientRectangle)
If controlRectangle.IntersectsWith(theRectangle) Then
Controls(i).BackColor = Color.BurlyWood
End If
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

theRectangle = New Rectangle(0, 0, 0, 0)
End Sub



※ 히포차트 샘플 코드는 버전별로 상이한 결과를 나타낼 수 있습니다.

이 코드 관련 문의 사항은 페이스북 리플을 달아주시거나 아래 이메일로 이 페이지 주소와 함께 문의주세요.

helpdesk@hippochart.com





Copyright © 2009-2016, HippoChart. Inc.  All Rights Reserved.