0
私のxamarinフォームアプリケーションでは、Oxyplot棒グラフを使用しています。 Here is the code、これは水平バーの条件で私の仕事です、どのように垂直グラフを作成することは可能ですか?棒グラフのための他のプラグインはありますか?Xamarin Formsの縦棒グラフの作成方法
私のxamarinフォームアプリケーションでは、Oxyplot棒グラフを使用しています。 Here is the code、これは水平バーの条件で私の仕事です、どのように垂直グラフを作成することは可能ですか?棒グラフのための他のプラグインはありますか?Xamarin Formsの縦棒グラフの作成方法
キーはとColumnItem
のオブジェクトを使用することです。これは、垂直方向のバーを持つ棒グラフとしてレンダリングする必要があります。新しいContentPage
を作成して下のコードを貼り付けると、実際にそれを見ることができます。私はコードサンプルの下にiOSでどのように見えるかを詳しく説明した画像を添付しました。
public partial class DemoPage : ContentPage
{
public DemoPage()
{
InitializeComponent();
var model = new PlotModel { Title = "Cake Type Popularity" };
// generate a random percentage distribution between the 5
//cake-types (see axis below)
var rand = new Random();
double[] cakePopularity = new double[5];
for (int i = 0; i < 5; ++i)
{
cakePopularity[i] = rand.NextDouble();
}
var sum = cakePopularity.Sum();
var barSeries = new ColumnSeries
{
ItemsSource = new List<ColumnItem>(new[]
{
new ColumnItem{ Value = (cakePopularity[0]/sum * 100) },
new ColumnItem{ Value = (cakePopularity[1]/sum * 100) },
new ColumnItem{ Value = (cakePopularity[2]/sum * 100) },
new ColumnItem{ Value = (cakePopularity[3]/sum * 100) },
new ColumnItem{ Value = (cakePopularity[4]/sum * 100) }
}),
LabelPlacement = LabelPlacement.Inside,
LabelFormatString = "{0:.00}%"
};
model.Series.Add(barSeries);
model.Axes.Add(new CategoryAxis
{
Position = AxisPosition.Bottom,
Key = "CakeAxis",
ItemsSource = new[]
{
"A",
"B",
"C",
"D",
"E"
}
});
var grid = new Grid();
grid.Children.Add(new PlotView
{
Model = model,
VerticalOptions = LayoutOptions.Center,
HeightRequest = 200,
HorizontalOptions = LayoutOptions.Fill,
});
Content = grid;
}
}
これは、このようなグラフ描画する必要があります。
これはバーの組み合わせを使用して行うことができます。 Aの3つのバー、Bの3つのバーなど? – Ph0b0x
いいえアイデアtbh、私はOxyplotのドキュメントがそれを明確にできるはずだと思います。 –
私は、 "IsStacked"プロパティやスタックグループの使い方を知りました。 – Ph0b0x