Blazor チャート アニメーション
アニメーションを使用すると、新しいデータ ソースを読み込むときにシリーズをイーズインできます。利用可能なアニメーションは、シリーズのタイプに基づきます。たとえば、縦棒シリーズは x 軸から上昇する描画アニメーションになります。折れ線シリーズは y 軸の原点から描画するアニメーションになります。
アニメーションは Ignite UI for Blazor チャートで無効ですが、IsTransitionInEnabled
プロパティを true に設定することで有効にできます。そこから、TransitionInDuration
プロパティを設定してアニメーションが完了するまでの時間を決定し、TransitionInMode
でアニメーションのタイプを決定できます。
Blazor WebAssembly および Blazor Server 向けに最適化された 60 以上の高性能チャートを使用 とグラフを使用して、生データを魅力的な視覚化に変換し、最高の UX を実現します。
Blazor チャート アニメーションの例
以下の例は、アニメーションをデフォルトの TransitionInMode
("Auto") に設定した折れ線チャートを示しています。この例の一番上のドロップダウンとスライダーは、TransitionInMode
と TransitionInDuration
をそれぞれ変更できるため、サポートされるさまざまなアニメーションが異なる速度でどのように見えるかを確認できます。
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modules
namespace Infragistics.Samples
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbLegendModule),
typeof(IgbInputModule),
typeof(IgbPropertyEditorPanelModule),
typeof(IgbCategoryChartModule)
);
await builder.Build().RunAsync();
}
}
}
csusing System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Infragistics.Samples
{
public class EnergyRenewableInfo
{
public string Year { get; set; }
public int Europe { get; set; }
public int China { get; set; }
public int USA { get; set; }
}
public class EnergyRenewableData : List<EnergyRenewableInfo>
{
public EnergyRenewableData()
{
Add(new EnergyRenewableInfo() { Year = "2009", Europe = 31, China = 21, USA = 19 });
Add(new EnergyRenewableInfo() { Year = "2010", Europe = 43, China = 26, USA = 24 });
Add(new EnergyRenewableInfo() { Year = "2011", Europe = 66, China = 29, USA = 28 });
Add(new EnergyRenewableInfo() { Year = "2012", Europe = 69, China = 32, USA = 26 });
Add(new EnergyRenewableInfo() { Year = "2013", Europe = 58, China = 47, USA = 38 });
Add(new EnergyRenewableInfo() { Year = "2014", Europe = 40, China = 46, USA = 31 });
Add(new EnergyRenewableInfo() { Year = "2015", Europe = 78, China = 50, USA = 19 });
Add(new EnergyRenewableInfo() { Year = "2016", Europe = 13, China = 90, USA = 52 });
Add(new EnergyRenewableInfo() { Year = "2017", Europe = 78, China = 132, USA = 50 });
Add(new EnergyRenewableInfo() { Year = "2018", Europe = 40, China = 134, USA = 34 });
Add(new EnergyRenewableInfo() { Year = "2019", Europe = 80, China = 96, USA = 38 });
}
}
}
cs
@using IgniteUI.Blazor.Controls
<div class="container vertical">
<div class="options horizontal">
<span class="options-label">Transition Type </span>
<select @bind="@SelectedTransition">
<option>@CategoryTransitionInMode.AccordionFromBottom</option>
<option>@CategoryTransitionInMode.AccordionFromCategoryAxisMaximum</option>
<option>@CategoryTransitionInMode.AccordionFromCategoryAxisMinimum</option>
<option>@CategoryTransitionInMode.AccordionFromLeft</option>
<option>@CategoryTransitionInMode.AccordionFromRight</option>
<option>@CategoryTransitionInMode.AccordionFromTop</option>
<option>@CategoryTransitionInMode.AccordionFromValueAxisMaximum</option>
<option>@CategoryTransitionInMode.AccordionFromValueAxisMinimum</option>
<option>@CategoryTransitionInMode.Expand</option>
<option>@CategoryTransitionInMode.FromZero</option>
<option>@CategoryTransitionInMode.SweepFromBottom</option>
<option>@CategoryTransitionInMode.SweepFromCategoryAxisMaximum</option>
<option>@CategoryTransitionInMode.SweepFromCategoryAxisMinimum</option>
<option>@CategoryTransitionInMode.SweepFromCenter</option>
<option>@CategoryTransitionInMode.SweepFromLeft</option>
<option>@CategoryTransitionInMode.SweepFromRight</option>
<option>@CategoryTransitionInMode.SweepFromTop</option>
<option>@CategoryTransitionInMode.SweepFromValueAxisMaximum</option>
<option>@CategoryTransitionInMode.SweepFromValueAxisMinimum</option>
<option>@CategoryTransitionInMode.Auto</option>
</select>
<label class="options-value" style="width: 75px">@IntervalLabel</label>
<input class="options-slider" type="range" min="50" max="2000" step="50"
value=@TransitionInInterval @onchange="OnTransitionIntervalChange" />
<button @onclick="OnReloadChart">Reload Chart</button>
</div>
<div class="container vertical">
@if (Data != null)
{
<IgbCategoryChart Height="100%" Width="100%"
@ref="Chart"
DataSource="Data"
ChartType="CategoryChartType.Line"
IsTransitionInEnabled="true"
TransitionInMode="@SelectedTransition"
TransitionInDuration="@TransitionInInterval"
IsHorizontalZoomEnabled="false"
IsVerticalZoomEnabled="false"
YAxisTitle="TWh"
YAxisTitleLeftMargin="10"
YAxisTitleRightMargin="5"
YAxisLabelLeftMargin="0"
ComputedPlotAreaMarginMode=ComputedPlotAreaMarginMode.Series>
</IgbCategoryChart>
}
</div>
</div>
@code {
private int _transitionInterval = 1000; // milliseconds
private int TransitionInInterval
{
get { return _transitionInterval; }
set
{
_transitionInterval = value;
StateHasChanged();
}
}
private string IntervalLabel
{
get
{
return (_transitionInterval).ToString("0") + "ms";
}
}
private CategoryTransitionInMode _selectedTransition;
private CategoryTransitionInMode SelectedTransition
{
get { return _selectedTransition; }
set
{
_selectedTransition = value;
StateHasChanged();
}
}
private IgbCategoryChart _Chart;
private IgbCategoryChart Chart
{
get { return _Chart; }
set { _Chart = value;
StateHasChanged();
}
}
private List<EnergyRenewableInfo> Data = new EnergyRenewableData();
private void OnTransitionIntervalChange(ChangeEventArgs args)
{
this.TransitionInInterval = int.Parse(args.Value.ToString());
}
private void OnReloadChart()
{
this.Chart.ReplayTransitionIn();
}
}
razor/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/
css
このサンプルが気に入りましたか? 完全な Ignite UI for Blazorツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
その他のリソース
関連するチャートタイプの詳細については、以下のトピックを参照してください。
API リファレンス
以下は、上記のセクションで説明した API メンバーのリストです。