彩票走势图

logo DevExpress WPF使用技巧教程
文档彩票走势图>>DevExpress WPF使用技巧教程>>WPF界面开发工具DevExpress WPF使用教程:创建绑定到数据的3D图表控件(第三部分)

WPF界面开发工具DevExpress WPF使用教程:创建绑定到数据的3D图表控件(第三部分)


下载DevExpress v20.1完整版    DevExpress v20.1汉化资源获取

通过DevExpress WPF Controls,您能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。

在本教程中,您将完成可视化数据源所需的步骤。

应该执行以下步骤,本文我们将为大家介绍3个步骤及最后结果,更多完整内容欢迎持续关注!

  • Step 1. 编写一个应用程序
  • Step 2. 为图表和系列绑定添加数据
  • Step 3. 配置系列视图
  • 结果
Step 3. 配置系列视图

本节中系列的外观将被配置,将分配一个不同的系列视图。此外,通过点的ColorIndex值对点进行着色的着色器将用于提供颜色。

  • 打开Series Collection Editor然后选择Series3D,找到属性并将其设置为.。
WPF界面开发工具DevExpress WPF使用教程

展开视图属性,找到属性并将其分配给对象。

WPF界面开发工具DevExpress WPF使用教程

然后,展开model属性,并将其 属性设置为Low,这将提高应用程序性能。

WPF界面开发工具DevExpress WPF使用教程
  • 找到 属性并将其设置为。
WPF界面开发工具DevExpress WPF使用教程

扩展着色器的属性并将其设置为-0.4 0.4 1.8 2。

WPF界面开发工具DevExpress WPF使用教程

将对象指定为属性值。

WPF界面开发工具DevExpress WPF使用教程

将 设置为true。

WPF界面开发工具DevExpress WPF使用教程

最后,将设置为新的对象,然后单击OK关闭编辑器并保存更改。

WPF界面开发工具DevExpress WPF使用教程

当前,该系列的XAML标记应如下所示。

<dxc:Series3D DisplayName="Series 1">
<dxc:Series3D.View>
<dxc:Point3DSeriesView>
<dxc:Point3DSeriesView.MarkerModel>
<dxc:Marker3DSpherePointModel SphereDetalizationLevel="Low"/>
</dxc:Point3DSeriesView.MarkerModel>
<dxc:Point3DSeriesView.Colorizer>
<dxc:RangeColorizer3D RangeStops="-0.4 0.4 1.8 2" 
ApproximateColors="True">
<dxc:RangeColorizer3D.ValueProvider>
<dxc:ColorObjectValueProvider3D/>
</dxc:RangeColorizer3D.ValueProvider>
<dxc:RangeColorizer3D.Palette>
<dxc:YellowPalette/>
</dxc:RangeColorizer3D.Palette>
</dxc:RangeColorizer3D>
</dxc:Point3DSeriesView.Colorizer>
</dxc:Point3DSeriesView>
</dxc:Series3D.View>
<!--Point Source Configuration -->
</dxc:Series3D>

结果

下图演示了已启动的应用程序。

WPF界面开发工具DevExpress WPF使用教程

以下代码是本入门课程的结果。

Star.cs

namespace GettingStarted2 {
public class Star {
public int HipID { get; private set; }
public string Spectr { get; private set; }
public double Luminocity { get; private set; }
public double ColorIndex { get; private set; }
public double X { get; private set; }
public double Y { get; private set; }
public double Z { get; private set; }

public Star(
int id,
double x,
double y,
double z,
string spectr, 
double luminocity, 
double colorIndex
) {
HipID = id;
X = x;
Y = y;
Z = z;
Spectr = spectr;
Luminocity = luminocity;
ColorIndex = colorIndex;
}
}
}

StarDataViewModel.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Windows;
using System.Windows.Resources;

namespace GettingStarted2 {
public class StarStatisticsViewModel {
public IEnumerable<Star> Stars { get; private set; }

public StarStatisticsViewModel() {
Stars = StarStatisticsLoader.Load("/Data/starsdata.csv");
}
}

static class StarStatisticsLoader {
public static IEnumerable<Star> Load(string filepath) {
StreamResourceInfo streamInfo = Application.GetResourceStream(
new Uri(filepath, UriKind.RelativeOrAbsolute)
);
StreamReader reader = new StreamReader(streamInfo.Stream);
Collection<Star> stars = new Collection<Star>();
while (!reader.EndOfStream) {
String dataLine = reader.ReadLine();
String[] serializedValues = dataLine.Split(';');
stars.Add(
new Star(
id: Convert.ToInt32(serializedValues[0], CultureInfo.InvariantCulture),
x: Convert.ToDouble(serializedValues[3], CultureInfo.InvariantCulture),
y: Convert.ToDouble(serializedValues[4], CultureInfo.InvariantCulture),
z: Convert.ToDouble(serializedValues[5], CultureInfo.InvariantCulture),
spectr: serializedValues[1],
luminocity: Convert.ToDouble(serializedValues[6], CultureInfo.InvariantCulture),
colorIndex: Convert.ToDouble(serializedValues[2], CultureInfo.InvariantCulture)
)
);
}

return stars;
}
}
}

StarDataViewModel.vb

Imports System.Collections.ObjectModel
Imports System.Globalization
Imports System.IO
Imports System.Windows.Resources

Public Class StarDataViewModel
Dim mStars As IEnumerable(Of Star)
Public ReadOnly Property Stars As IEnumerable(Of Star)
Get
Return mStars
End Get
End Property

Public Sub New()
mStars = StarStatisticsLoader.Load("/Data/starsdata.csv")
End Sub
End Class

Public Module StarStatisticsLoader
Public Function Load(ByVal filepath As String) As IEnumerable(Of Star)
Dim streamInfo As StreamResourceInfo = Application.GetResourceStream(
New Uri(filepath, UriKind.RelativeOrAbsolute)
)
Dim reader As StreamReader = New StreamReader(streamInfo.Stream)
Dim stars As Collection(Of Star) = New Collection(Of Star)()
While (Not reader.EndOfStream)
Dim dataLine As String = reader.ReadLine()
Dim serializedValues As String() = dataLine.Split(";")
stars.Add(
New Star(
id:=Convert.ToInt32(serializedValues(0), CultureInfo.InvariantCulture),
x:=Convert.ToDouble(serializedValues(3), CultureInfo.InvariantCulture),
y:=Convert.ToDouble(serializedValues(4), CultureInfo.InvariantCulture),
z:=Convert.ToDouble(serializedValues(5), CultureInfo.InvariantCulture),
spectr:=serializedValues(1),
luminocity:=Convert.ToDouble(serializedValues(6), CultureInfo.InvariantCulture),
colorIndex:=Convert.ToDouble(serializedValues(2), CultureInfo.InvariantCulture)
)
)
End While
Return stars
End Function
End Module

Star.vb

Public Class Star
Dim mHipID As Int32
Dim mSpectr As String
Dim mX, mY, mZ, mLuminocity, mColorIndex As Double

Public ReadOnly Property HipID() As Int32
Get
Return mHipID
End Get
End Property

Public ReadOnly Property Spectr() As String
Get
Return mSpectr
End Get
End Property

Public ReadOnly Property X() As Double
Get
Return mX
End Get
End Property

Public ReadOnly Property Y() As Double
Get
Return mY
End Get
End Property

Public ReadOnly Property Z() As Double
Get
Return mZ
End Get
End Property

Public ReadOnly Property Luminocity() As Double
Get
Return mLuminocity
End Get
End Property

Public ReadOnly Property ColorIndex() As Double
Get
Return mColorIndex
End Get
End Property

Public Sub New(
ByVal id As Int32,
ByVal x As Double,
ByVal y As Double,
ByVal z As Double,
ByVal spectr As String,
ByVal luminocity As Double,
ByVal colorIndex As Double)
mHipID = id
mX = x
mY = y
mZ = z
mSpectr = spectr
mLuminocity = luminocity
mColorIndex = colorIndex
End Sub
End Class

MainWindow.xaml(C#)

<Window
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="//schemas.microsoft.com/expression/blend/2008"
xmlns:mc="//schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GettingStarted2"
xmlns:dxc="//schemas.devexpress.com/winfx/2008/xaml/charts" 
x:Class="GettingStarted2.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="720" Width="1280">
<Window.DataContext>
<local:StarStatisticsViewModel/>
</Window.DataContext>
<Grid>
<dxc:Chart3DControl>
<dxc:Chart3DControl.Legends>
<dxc:Legend/>
</dxc:Chart3DControl.Legends>
<dxc:Series3DStorage>
<dxc:Series3D DisplayName="Series 1">
<dxc:Series3D.View>
<dxc:Point3DSeriesView>
<dxc:Point3DSeriesView.MarkerModel>
<dxc:Marker3DSpherePointModel SphereDetalizationLevel="Low"/>
</dxc:Point3DSeriesView.MarkerModel>
<dxc:Point3DSeriesView.Colorizer>
<dxc:RangeColorizer3D RangeStops="-0.4 0.4 1.8 2" 
ApproximateColors="True">
<dxc:RangeColorizer3D.ValueProvider>
<dxc:ColorObjectValueProvider3D/>
</dxc:RangeColorizer3D.ValueProvider>
<dxc:RangeColorizer3D.Palette>
<dxc:YellowPalette/>
</dxc:RangeColorizer3D.Palette>
</dxc:RangeColorizer3D>
</dxc:Point3DSeriesView.Colorizer>
</dxc:Point3DSeriesView>
</dxc:Series3D.View>
<dxc:SeriesPoint3DDataSourceAdapter DataSource="{Binding Stars}" 
XArgumentDataMember="X" 
YArgumentDataMember="Y"
ValueDataMember="Z" 
ColorDataMember="ColorIndex"/>
</dxc:Series3D>
</dxc:Series3DStorage>
</dxc:Chart3DControl>
</Grid>
</Window>

MainWindow.xaml(VB.NET)

<Window xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="//schemas.microsoft.com/expression/blend/2008"
xmlns:mc="//schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GettingStarted2"
xmlns:dxc="//schemas.devexpress.com/winfx/2008/xaml/charts" 
x:Class="GettingStarted2.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="720" Width="1280">
<Window.DataContext>
<local:StarDataViewModel/>
</Window.DataContext>
<Grid>
<dxc:Chart3DControl>
<dxc:Chart3DControl.Legends>
<dxc:Legend/>
</dxc:Chart3DControl.Legends>
<dxc:Series3DStorage>
<dxc:Series3D DisplayName="Series 1">
<dxc:Series3D.View>
<dxc:Point3DSeriesView>
<dxc:Point3DSeriesView.MarkerModel>
<dxc:Marker3DSpherePointModel SphereDetalizationLevel="Low"/>
</dxc:Point3DSeriesView.MarkerModel>
<dxc:Point3DSeriesView.Colorizer>
<dxc:RangeColorizer3D RangeStops="-0.4 0.4 1.8 2" 
ApproximateColors="True">
<dxc:RangeColorizer3D.ValueProvider>
<dxc:ColorObjectValueProvider3D/>
</dxc:RangeColorizer3D.ValueProvider>
<dxc:RangeColorizer3D.Palette>
<dxc:YellowPalette/>
</dxc:RangeColorizer3D.Palette>
</dxc:RangeColorizer3D>
</dxc:Point3DSeriesView.Colorizer>
</dxc:Point3DSeriesView>
</dxc:Series3D.View>
<dxc:SeriesPoint3DDataSourceAdapter DataSource="{Binding Stars}" 
XArgumentDataMember="X" 
YArgumentDataMember="Y"
ValueDataMember="Z" 
ColorDataMember="ColorIndex"/>
</dxc:Series3D>
</dxc:Series3DStorage>
</dxc:Chart3DControl>
</Grid>
</Window>


DevExpress技术交流群2:775869749      欢迎一起进群讨论

慧都2020年终大促
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP