-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathlivechart.cs
81 lines (67 loc) · 2.78 KB
/
livechart.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Drawing;
using System.Windows.Forms;
namespace ZeroTrace_Stealer
{
internal class LiveChart : UserControl
{
private Timer updateTimer;
private int[] chartData;
private int maxDataPoints = 200; // Increase max data points
private int dataIndex = 0;
private int[] counts; // Array to store counts for different labels
private string[] labels = { "uscount", "italycount", "canadacount", "germanycount", "romaniacount", "swedencount", "denmarkcount", "chinacount" };
public LiveChart()
{
this.Size = new Size(800, 400);
this.DoubleBuffered = true;
// Initialize Timer
updateTimer = new Timer();
updateTimer.Interval = 1000; // Slower animation (1 second update interval)
updateTimer.Tick += UpdateChart;
// Initialize chart data array and counts array
chartData = new int[maxDataPoints];
counts = new int[labels.Length];
// Start the timer
updateTimer.Start();
}
private void UpdateChart(object sender, EventArgs e)
{
// Update counts for each label
foreach (string label in labels)
{
// Replace the next line with actual logic to read count for the label
// Example: counts[i] = GetLabelCount(label);
counts[Array.IndexOf(labels, label)] = new Random().Next(0, this.Height);
}
// Update chart data with the sum of counts for visualization
int sumCounts = 0;
for (int i = 0; i < counts.Length; i++)
{
sumCounts += counts[i];
}
chartData[dataIndex] = sumCounts;
// Move index
dataIndex = (dataIndex + 1) % maxDataPoints;
// Redraw the control
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
using (var brush = new SolidBrush(Color.FromArgb(77, 86, 99)))
{
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
for (int i = 0; i < chartData.Length - 1; i++)
{
int x1 = i * (this.Width / maxDataPoints);
int y1 = this.Height - chartData[i];
int x2 = (i + 1) * (this.Width / maxDataPoints);
int y2 = this.Height - chartData[(i + 1) % maxDataPoints];
g.DrawLine(new Pen(brush, 2), x1, y1, x2, y2); // Increase pen width
}
}
}
}
}