using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
このトピックでは、XamDataChart コントロールおよびその散布バブル シリーズ タイプで使用するデータおよびデータ モデルを提供します。
C# の場合:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
Visual Basic の場合:
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Linq
Namespace Infragistics.Models
' TODO add sample data model
' TODO add sample data source
End Namespace
C# の場合:
public class BubbleDataPoint
{
public string Label { get; set; }
public double Radius { get; set; }
public double X { get; set; }
public double Y { get; set; }
}
Visual Basic の場合:
Public Class BubbleDataPoint
Public Property Label As String
Public Property Radius As Double
Public Property X As Double
Public Property Y As Double
End Class
C# の場合:
public class BubbleDataSource : List<BubbleDataPoint>
{
public static Random Rand = new Random();
public BubbleDataSource()
{
int value = 50;
for (int i = 0; i < 100; i++)
{
double change = Rand.NextDouble();
if (change > .5)
{
value += (int)(change * 20);
}
else
{
value -= (int)(change * 20);
}
value %= 100;
this.Add(new BubbleDataPoint
{
Label = "Item " + i.ToString(),
Radius = Rand.Next(10, 50),
X = Rand.Next(i, i + 5),
Y = Rand.Next(value - 50, value + 50)
});
}
}
}
Visual Basic の場合:
Public Class BubbleDataSource Inherits List(Of BubbleDataPoint)
Public Shared Rand As New Random()
Public Sub New()
Dim value As Integer = 50
For i As Integer = 0 To 99
Dim change As Double = Rand.NextDouble()
If change > 0.5 Then
value += CInt(Math.Truncate(change * 20))
Else
value -= CInt(Math.Truncate(change * 20))
End If
value = value Mod 100
Me.Add(New BubbleDataPoint() With { _
.Label = "Item " + i.ToString(), _
.Radius = Rand.Next(10, 50), _
.X = Rand.Next(i, i + 5), _
.Y = Rand.Next(value - 50, value + 50) _
})
Next
End Sub
End Class