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

박스플롯차트 마우스 이벤트(수치보기)







박스플롯 차트위 Q1, Q2 등 수치를 보여주는 이벤트 구현 방법을 알아봅니다




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


C#
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Hippo;

namespace WindowsHippoTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Draw();
}

Rectangle rec;

private void Draw()
{
SeriesList sList = new SeriesList();
sList.ChartType = ChartType.BoxPlot;
sList.Transparency = 55;


Random r = new Random();
for(int i = 0; i < 1; i++)
{
Series sr = new Series();
//sr.BoxPlotsAttributes.IsShowFigureText = true;

for(int x = 0; x < 12; x++)
{
SeriesItem item = new SeriesItem();
item.GroupName = "G2";
item.Name = "item" + x.ToString();
item.YValue = r.Next(5, 700);

sr.items.Add(item);
}

for(int x = 0; x < 14; x++)
{
SeriesItem item = new SeriesItem();
item.GroupName = "G3";
item.Name = "item" + x.ToString();
item.YValue = r.Next(5, 700);

if (x > 10) item.YValue = r.Next(800, 1100);

sr.items.Add(item);
}

for(int x = 0; x < 9; x++)
{
SeriesItem item = new SeriesItem();
item.GroupName = "G4";
item.Name = "item" + x.ToString();
item.YValue = r.Next(5, 700);

sr.items.Add(item);
}

sList.SeriesCollection.Add(sr);
}

this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart();
}

private void hHippoChart1_ChartMouseDoubleClick(object sender, MouseEventArgs e)
{
this.hHippoChart1.SeriesListDictionary.Clear();

Draw();
}

private void hHippoChart1_ChartMouseMove_1(object sender, MouseEventArgs e)
{
for(int i = 0; i < this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList.Count; i++)
{
PointF firstpoint = this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].FigurePoint;

float lastPoX = (float)(firstpoint.X + this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].Column.Width);
float lastPoY = (float)(firstpoint.Y + this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].Q3 - this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].Q1);

PointF lastPoint = new PointF(lastPoX, lastPoY);

if (e.X >= firstpoint.X && e.X <= lastPoint.X && e.Y >= firstpoint.Y && e.Y <= lastPoint.Y)
{
this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].IsShowFigureText = true;
}
else
{
this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].BoxPlotList[i].IsShowFigureText = false;
}
}

this.hHippoChart1.DrawChart();
}
}
}


VB
 
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Hippo

Namespace WindowsHippoTest
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs)
Draw()
End Sub

Private rec As Rectangle

Private Sub Draw()
Dim sList As New. SeriesList()
sList.ChartType = ChartType.BoxPlot
sList.Transparency = 55


Dim r As New. Random()
For i As Integer = 0 To 0
Dim sr As New. Series()
`sr.BoxPlotsAttributes.IsShowFigureText = true;

For x As Integer = 0 To 11
Dim item As New. SeriesItem()
item.GroupName = "G2"
item.Name = "item" & x.ToString()
item.YValue = r.[Next](5, 700)

sr.items.Add(item)
Next

For x As Integer = 0 To 13
Dim item As New. SeriesItem()
item.GroupName = "G3"
item.Name = "item" & x.ToString()
item.YValue = r.[Next](5, 700)

If x > 10 Then
item.YValue = r.[Next](800, 1100)
End If

sr.items.Add(item)
Next

For x As Integer = 0 To 8
Dim item As New. SeriesItem()
item.GroupName = "G4"
item.Name = "item" & x.ToString()
item.YValue = r.[Next](5, 700)

sr.items.Add(item)
Next

sList.SeriesCollection.Add(sr)
Next

Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()
End Sub

Private Sub hHippoChart1_ChartMouseDoubleClick(sender As Object, e As MouseEventArgs)
Me.hHippoChart1.SeriesListDictionary.Clear()

Draw()
End Sub

Private Sub hHippoChart1_ChartMouseMove_1(sender As Object, e As MouseEventArgs)
For i As Integer = 0 To Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList.Count - 1
Dim firstpoint As PointF = Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).FigurePoint

Dim lastPoX As Single = CSng(firstpoint.X + Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).Column.Width)
Dim lastPoY As Single = CSng(firstpoint.Y + Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).Q3 - Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).Q1)

Dim lastPoint As New. PointF(lastPoX, lastPoY)

If e.X >= firstpoint.X AndAlso e.X <= lastPoint.X AndAlso e.Y >= firstpoint.Y AndAlso e.Y <= lastPoint.Y Then
Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).IsShowFigureText = True
Else
Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).BoxPlotList(i).IsShowFigureText = False
End If
Next

Me.hHippoChart1.DrawChart()
End Sub
End Class
End Namespace


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

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

helpdesk@hippochart.com





Copyright © 2009-2018 투데이트레이딩. Inc.  All Rights Reserved.