using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Hippo;
using Hippo.WindowsForm4;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
SeriesList sList;
SeriesItem[] items;
// 총 데이터 수
int totalCount = 1000;
// 차트 한 화면에 보여줄 개수
int counts = 100;
public Form1()
{
InitializeComponent();
Init();
}
private void Form1_Load_1(object sender, EventArgs e)
{
}
private void Init()
{
sList = new SeriesList();
sList.SeriesCollection.Add(new Series());
items = new SeriesItem[totalCount];
Random R = new Random();
for(int i = 1; i < totalCount + 1; i++)
{
SeriesItem item = new SeriesItem();
item.XDateTimeValue = DateTime.Parse("2013-01-01").AddDays(i);
item.YStartValue = R.Next(1000, 1050) * i - 11 * i; // 시가
item.LowValue = R.Next(1000, 1050) * i - 12 * i; // 저가
item.YValue = R.Next(1000, 1050) * i - 15 * i; // 종가
item.HighValue = R.Next(1000, 1050) * i - 10 * i; // 고가
if (i > 950 && i < 990)
{
item.YStartValue = R.Next(950, 1000) * i - 33 * i; // 시가
item.LowValue = R.Next(950, 1000) * i - 22 * i; // 저가
item.YValue = R.Next(950, 1000) * i - 30 * i; // 종가
item.HighValue = R.Next(950, 1000) * i - 14 * i; // 고가
}
if (i > 200 && i < 600)
{
item.YStartValue = R.Next(1100, 1200) * i - 40 * i; // 시가
item.LowValue = R.Next(1100, 1200) * i - 60 * i; // 저가
item.YValue = R.Next(1100, 1200) * i - 30 * i; // 종가
item.HighValue = R.Next(1100, 1200) * i - 10 * i; // 고가
}
items.SetValue(item, i - 1);
}
for(int i = totalCount - 1; i > totalCount - 1 - counts; i--)
{
sList.SeriesCollection[0].items.Add(items[i]);
}
sList.ChartType = ChartType.CandleStick;
sList.AxisFactor.YAxis.Direction = AxisDirection.Right;
sList.AxisFactor.XAxis.DataType = AxisDataType.DateTime;
sList.AxisFactor.XAxis.DateTimeLabelType = DateTimeLabelType.Day;
//sList.AxisFactor.XAxis.DateTimeFormat = "dd";
sList.GraphArea.Grid.IsBackGridColor = false;
sList.AxisFactor.YAxis.AxisMagin = 50;
sList.AxisFactor.YAxis.IsZeroStartScale = false;
sList.AxisFactor.XAxis.Interval = counts / 5;
AxisTick tk2 = new AxisTick("8월 20일");
tk2.Label.Text = "8월 20일 09:00";
tk2.Label.ForeColor = Color.Blue;
tk2.Label.Font = new Font("굴림", 12, FontStyle.Bold);
tk2.IsShowGridLine = true;
sList.AxisFactor.XAxis.Ticks.Add(tk2);
this.hHippoChart1.Designer.InnerBackColor = Color.FromArgb(214, 226, 239);
this.hHippoChart1.LegendBox.Visible = false;
this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart();
this.hHippoChart1.DrawChart();
}
}
}
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Hippo
Imports Hippo.WindowsForm4
Namespace WindowsApplication1
Public Partial Class Form1
Inherits Form
Private sList As SeriesList
Private items As SeriesItem()
` 총 데이터 수
Private totalCount As Integer = 1000
` 차트 한 화면에 보여줄 개수
Private counts As Integer = 100
Public Sub New()
InitializeComponent()
Init()
End Sub
Private Sub Form1_Load_1(sender As Object, e As EventArgs)
End Sub
Private Sub Init()
sList = New SeriesList()
sList.SeriesCollection.Add(New Series())
items = New SeriesItem(totalCount - 1) {}
Dim R As New. Random()
For i As Integer = 1 To totalCount
Dim item As New. SeriesItem()
item.XDateTimeValue = DateTime.Parse("2013-01-01").AddDays(i)
item.YStartValue = R.[Next](1000, 1050) * i - 11 * i
` 시가
item.LowValue = R.[Next](1000, 1050) * i - 12 * i
` 저가
item.YValue = R.[Next](1000, 1050) * i - 15 * i
` 종가
item.HighValue = R.[Next](1000, 1050) * i - 10 * i
` 고가
If i > 950 AndAlso i < 990 Then
item.YStartValue = R.[Next](950, 1000) * i - 33 * i
` 시가
item.LowValue = R.[Next](950, 1000) * i - 22 * i
` 저가
item.YValue = R.[Next](950, 1000) * i - 30 * i
` 종가
` 고가
item.HighValue = R.[Next](950, 1000) * i - 14 * i
End If
If i > 200 AndAlso i < 600 Then
item.YStartValue = R.[Next](1100, 1200) * i - 40 * i
` 시가
item.LowValue = R.[Next](1100, 1200) * i - 60 * i
` 저가
item.YValue = R.[Next](1100, 1200) * i - 30 * i
` 종가
` 고가
item.HighValue = R.[Next](1100, 1200) * i - 10 * i
End If
items.SetValue(item, i - 1)
Next
For i As Integer = totalCount - 1 To totalCount - 1 - counts + 1 Step -1
sList.SeriesCollection(0).items.Add(items(i))
Next
sList.ChartType = ChartType.CandleStick
sList.AxisFactor.YAxis.Direction = AxisDirection.Right
sList.AxisFactor.XAxis.DataType = AxisDataType.DateTime
sList.AxisFactor.XAxis.DateTimeLabelType = DateTimeLabelType.Day
`sList.AxisFactor.XAxis.DateTimeFormat = "dd";
sList.GraphArea.Grid.IsBackGridColor = False
sList.AxisFactor.YAxis.AxisMagin = 50
sList.AxisFactor.YAxis.IsZeroStartScale = False
sList.AxisFactor.XAxis.Interval = counts / 5
Dim tk2 As New. AxisTick("8월 20일")
tk2.Label.Text = "8월 20일 09:00"
tk2.Label.ForeColor = Color.Blue
tk2.Label.Font = New Font("굴림", 12, FontStyle.Bold)
tk2.IsShowGridLine = True
sList.AxisFactor.XAxis.Ticks.Add(tk2)
Me.hHippoChart1.Designer.InnerBackColor = Color.FromArgb(214, 226, 239)
Me.hHippoChart1.LegendBox.Visible = False
Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()
Me.hHippoChart1.DrawChart()
End Sub
End Class
End Namespace