私はXamarin.Formsアプリケーションで作業しています。ここでは、スクリーンショットに添付されている棒グラフを実装します。 Xamarin.Formsにはそのようなコントロールはありません。そのためにOxyPlotのnugetパッケージを使用していますが、問題は、oxyplotのバーが水平であり、グリッド線のオプションがグラフプロット内にないことです。バーグラフのためのオープンソースライブラリがありますので、私はそれを使用することができます。 Xamarin Forms棒グラフ用OxyPlot
答えて
OxyPlot
で行うことができます。ColumnSeries
です。
XAML:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App2"
xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"
x:Class="App2.MainPage">
<ContentPage.BindingContext>
<local:MyViewModel></local:MyViewModel>
</ContentPage.BindingContext>
<oxy:PlotView Model="{Binding Model}"/>
</ContentPage>
ビューモデル:このMCVE試してみてください
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Axes;
public class MyViewModel
{
public PlotModel Model { get; set; }
public MyViewModel()
{
CategoryAxis xaxis = new CategoryAxis();
xaxis.Position = AxisPosition.Bottom;
xaxis.MajorGridlineStyle = LineStyle.Solid;
xaxis.MinorGridlineStyle = LineStyle.Dot;
xaxis.Labels.Add("Mon, 4/24");
xaxis.Labels.Add("Tue, 4/25");
xaxis.Labels.Add("Wed, 4/26");
xaxis.Labels.Add("Thu, 4/27");
LinearAxis yaxis = new LinearAxis();
yaxis.Position = AxisPosition.Left;
yaxis.MajorGridlineStyle = LineStyle.Dot;
xaxis.MinorGridlineStyle = LineStyle.Dot;
ColumnSeries s1 = new ColumnSeries();
s1.IsStacked = true;
s1.Items.Add(new ColumnItem(20));
s1.Items.Add(new ColumnItem(60));
s1.Items.Add(new ColumnItem(40));
s1.Items.Add(new ColumnItem(50));
ColumnSeries s2 = new ColumnSeries();
s2.IsStacked = true;
s2.Items.Add(new ColumnItem(50));
s2.Items.Add(new ColumnItem(30));
s2.Items.Add(new ColumnItem(10));
s2.Items.Add(new ColumnItem(20));
Model = new PlotModel();
Model.Title = "Xamarin Oxyplot Sample";
Model.Background = OxyColors.Gray;
Model.Axes.Add(xaxis);
Model.Axes.Add(yaxis);
Model.Series.Add(s1);
Model.Series.Add(s2);
}
}
ありがとう@jstreet、それは働いたが、私がスタックレイアウト内でそれを使用しているとき、グラフは見えません。また、heightrequestプロパティとwidthrequestプロパティは変更を反映していません。 –
新しい問題が発生した場合は、新しい質問を投稿してください!そして、常に、私たちにあなたの**コード**を示すだけでなく、写真を! – jsanalytics
私は、それがXamarin.iOSとXamarin.Androidのバインディングを持っている、あなたはXamarin.Forms上のグラフを表示するには、カスタムレンダラを行う必要があります。この優れたオープンソースのライブラリを使用しているが、それは高度にカスタマイズされています
アンドロイド: https://github.com/PhilJay/MPAndroidChart
のiOS: https://github.com/danielgindi/Charts
Xamarinアンドロイド: https://github.com/Flash3001/MPAndroidChart.Xamarin
XamarinのiOS: https://github.com/Flash3001/iOSCharts.Xamarin
彼らはNuGetパッケージとしてご利用いただけます。
- 1. Xamarin Formsの縦棒グラフの作成方法
- 2. Xamarinフォームの棒グラフ
- 3. Xamarin Forms、Prism Forms&IoC
- 4. iOS向けXamarinの横棒グラフ
- 5. Chart.js棒グラフの棒グラフ
- 6. ggplot2棒グラフの棒グラフ
- 7. CorePlot棒グラフの棒グラフ
- 8. xamarin forms appサブヘッダ
- 9. Sendgrid Xamarin Forms
- 10. Xamarin Forms - Control Fusion
- 11. Xamarin Forms - Plugins.BLE - MvvmCross.Plugins.BLE
- 12. Xamarin Forms Collapsable StackLayout
- 13. Xamarin Forms xam.plugins.pushnotifications issue
- 14. Xamarin Forms Bindable Grid
- 15. Xamarin Forms - UWPフォント
- 16. Xamarin Formsカスタムナビゲーショントランジション
- 17. Xamarin Forms SQLite
- 18. Xamarin Forms Webviewナビゲートイベント
- 19. Xamarin Forms Animationオーバーロードバグ?
- 20. Xamarin Forms/Prismカスタムポップアップ
- 21. Xamarin Forms Webview local
- 22. Xamarin Forms MasterDetailPage MasterBounds
- 23. Xamarin Forms RelativeLayout
- 24. xamarin forms get call
- 25. Xamarin Forms Android GCループ
- 26. PushModalAsync from MasterDetailPage、Xamarin Forms
- 27. Xamarin Forms for Windowsデスクトップアプリ?
- 28. Xamarin Forms UWPのストライプ
- 29. Xamarin Formsローカリゼーションとmvvm
- 30. xamarin forms Android.Support.v4 23.3.0.0 missing
あなたはSyncfusion Xamarinのコントロールを確認することができますが、それがオープンソースではないのですが、それは、Aがありますコミュニティライセンスhttps://www.syncfusion.com/products/xamarin 。 –