翻譯|使用教程|編輯:吳園園|2019-07-24 14:44:08.030|閱讀 651 次
概述:使用LightningChart,您可以為各種用例創(chuàng)建不同類型的圖表。之前的教程演示了如何創(chuàng)建具有多個(gè)線系列和軸,區(qū)域系列和條形系列的簡(jiǎn)單2D圖表。在本教程中,我們將展示如何使用IntensityGridSeries創(chuàng)建簡(jiǎn)單的2D熱圖。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
使用LightningChart,您可以為各種用例創(chuàng)建不同類型的圖表。之前的教程演示了如何創(chuàng)建具有多個(gè)線系列和軸,區(qū)域系列和條形系列的簡(jiǎn)單2D圖表。在本教程中,我們將展示如何使用IntensityGridSeries創(chuàng)建簡(jiǎn)單的2D熱圖。(LightningChart Ultimate SDK現(xiàn)已加入在線訂購(gòu),點(diǎn)擊訂購(gòu)立享優(yōu)惠)
點(diǎn)擊下載LightningChart Ultimate SDK最新試用版
熱圖是包含單個(gè)值的矩陣,這些值以顏色顯示。在數(shù)據(jù)可視化中,熱圖可用于通過顏色的變化提供關(guān)于數(shù)據(jù)值的視覺內(nèi)容和反饋。對(duì)于本教程,我們建議您創(chuàng)建一個(gè)新的WinForms或WPF應(yīng)用程序。LightningChart提供了兩種創(chuàng)建熱圖的方法 - IntensityGridSeries和IntensityMeshSeries。IntensityGrid在X和Y空間中是均勻間隔的矩形系列,允許可視化M×N節(jié)點(diǎn)陣列。IntensityMesh類似于IntensityGrid,但在IntensityMesh中,系列不需要是矩形,而系列節(jié)點(diǎn)可以在X和Y空間任意定位。在本教程中,我們使用的是IntensityGridSeries。
1.創(chuàng)建一個(gè)熱圖實(shí)例作為IntensityGridSeries。
// Create a Heat Map as IntensityGridSeries.var heatMap = new IntensityGridSeries(_chart.ViewXY, axisX, axisY);
為了以所需顏色顯示數(shù)據(jù)值,我們需要?jiǎng)?chuàng)建ValueRangePalette。ValueRangePalette用于根據(jù)值定義數(shù)據(jù)著色的顏色。
2.為IntensityGridSeries創(chuàng)建ValueRangePalette。
// Creating palette for IntensityGridSeries.var palette = new
ValueRangePalette(series);
LightningChart具有ValueRangePalette的預(yù)設(shè)值。為了以期望的方式為數(shù)據(jù)著色,我們首先需要清除ValueRangePalette及其調(diào)色板步驟。
3.清除ValueRangePalette中的預(yù)設(shè)值。
// LightningChart has some preset values for palette steps.// Clear the preset values from palette before setting new ones.foreach (var step in palette.Steps){ step.Dispose();} palette.Steps.Clear();
然后我們需要為PaletteType和PaletteType設(shè)置顏色。您可以使用System.Windows.Media.Color或System.Drawing.Color定義顏色,具體取決于您使用的是WPF還是WinForms。PaletteType定義調(diào)色板著色在應(yīng)用程序中的外觀。
對(duì)于此示例,我們將PaletteType設(shè)置為Gradient。
4.定義用于著色數(shù)據(jù)的調(diào)色板步驟。
// Add steps into palette. // Palette is used for presenting data in Heat Map with different colors based on their value. palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(0, 0, 255), -25)); palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(20, 150, 255), 0)); palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(0, 255, 0), 25)); palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(255, 255, 20), 50)); palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(255, 150, 20), 75)); palette.Steps.Add(new PaletteStep(palette, Color.FromRgb(255, 0, 0), 100)); palette.Type = PaletteType.Gradient; palette.MinValue = -50;
您可以使用IntensityPoints將數(shù)據(jù)添加到熱圖。IntensityPoints是Intensity系列的數(shù)據(jù)點(diǎn)。在這個(gè)例子中,我們填補(bǔ)了我國(guó)IntensityGrid與價(jià)值觀IntensityPoints其著色與ValueRangePalette。
5.為熱圖生成數(shù)據(jù)。
// Generate data.public void GenerateData(int columns, int rows){ // Create new IntensityPoint series for data. var data = new IntensityPoint[_columns, _rows]; // Disable rendering before updating chart properties to improve performance // and to prevent unnecessary chart redrawing while changing multiple properties. _chart.BeginUpdate(); // Set data values and add them to Heat Map. for (int i = 0; i < _columns; i++) { for (int j = 0; j < _rows; j++) { // Add values to the IntensityPoint series, points are generated by using following function. data[i, j].Value = 30.0 + 20 * Math.Cos(20 + 0.0001 * (double)(i * j)) + 70.0 * Math.Cos((double)(j - i) * 0.01); } } // Add generated data as Heat Map data. _heatMap.Data = data; // Call EndUpdate to enable rendering again. _chart.EndUpdate();}
想要購(gòu)買LightningChart Ultimate SDK正版授權(quán)的朋友可以。
有關(guān)產(chǎn)品資訊的更多精彩內(nèi)容,敬請(qǐng)關(guān)注下方的微信公眾號(hào)▼▼▼
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: