기본 코스 (4) OxyPlot 프레임 워크의 개발을 차트 자 마린
도 OxyPlotAndroidDemo 라인 XamaminAndroid 그린
[실시 예 1-1 : OxyPlotAndroidDemo는도 라인은 다음에 그려진. 다음과 같이 구체적인 단계는 다음과 같습니다
(1) 열기 Xamarin.Android 프로젝트.
OxyPlot.Xamarin.Android에 추가 (2)가 조립 프로젝트에 포함된다.
(3) 개방 activity_main.axml 파일, 사용 PlotView 레이아웃. 다음과 같이 코드입니다 :
<XML 버전 = "1.0"인코딩 = "UTF-8"?> <RelativeLayout의 용의 xmlns : 로이드 = "http://schemas.android.com/apk/res/android" 의 xmlns : 앱 = "HTTP : // 스키마 .android.com / APK / 고해상도 오토 " 의 xmlns : 도구 ="http://schemas.android.com/tools " 안드로이드 : layout_width ="match_parent " 안드로이드 : layout_height ="match_parent "> <OxyPlot.Xamarin.Android. PlotView는 안드로이드 : 자료 = "@ + ID / plot_view" 로이드 : layout_width = "match_parent" 로이드 : layout_height = "match_parent"/> </ RelativeLayout의>
(4) 파일 열기 MainActivity.cs 즉, 차트 및 표시 모드가 설정되어,이 문서의 나머지 단계를 달성한다. 다음과 같이 코드입니다 :
Android.App을 사용함; Android.OS을 사용함; Android.Support.V7.App을 사용함; Android.Runtime을 사용함; Android.Widget을 사용함; OxyPlot.Xamarin.Android 사용함; OxyPlot을 사용함; OxyPlot.Axes을 사용함; OxyPlot.Series을 사용함; 네임 스페이스 OxyPlotAndroidDemo { [활동 (라벨 = "스타일 / AppTheme @" "@ 문자열 / APP_NAME"테마 = MainLauncher = TRUE)] 공용 클래스 MainActivity : AppCompatActivity { 보호 재정의 무효 한 OnCreate (번들 savedInstanceState) { base.OnCreate (savedInstanceState) ; //은 "기본"레이아웃 리소스에서 우리의보기를 설정 된 setContentView은 (는 Resource.Layout.activity_main) PlotView findViewById를보기가 = <PlotView> (Resource.Id.plot_view) view.Model CreatePlotModel = (); // 설정된 표시 모드 } // 그 그래프 개인 PlotModel CreatePlotModel () { // 차트 패턴 만들기 새로운 새로운 PlotModel = var에 plotModel을 { 제목 = "OxyPLOT 데모" ;} // 축 추가 , plotModel.Axes.Add (새 새 AxisPosition.Bottom 위치] = {}는의 LinearAxis를) {= plotModel.Axes.Add를 (새 새로운 기능의 LinearAxis 위치] AxisPosition.Left, 최대 = 10, 최소 = 0}); //创建数据列 var에 시리즈 1 = 새로운 LineSeries의 { 제목 = "데이터", MarkerType = MarkerType.Circle, MarkerSize = 4, MarkerStroke = OxyColors.White }; //添加数据点 series1.Points.Add (새 DataPoint에 (0.0, 6.0)); series1.Points.Add (새 DataPoint에 (1.4, 2.1)); series1.Points.Add (새 DataPoint에 (2.0, 4.2)); series1.Points.Add (새 DataPoint에 (3.3, 2.3)); series1.Points.Add (새 DataPoint에 (4.7, 7.4)); series1.Points.Add (새 DataPoint에 (6.0, 6.2)); series1.Points.Add (새 새로 만들기 DataPoint에 (8.9, 8.9)); // 추가 데이터 열 (시리즈 1의) plotModel.Series.Add, 반환 plotModel; } } }
프로그램을 실행 그래프도 1.1에 도시.
도 플랫폼 1.1 Xamarin.Android도 효과