| | |
| | | //using UIKit; |
| | | //using Foundation; |
| | | //using Shared.IO; |
| | | //using CoreFoundation; |
| | | //using System.Collections.Generic; |
| | | //using System; |
| | | //using System.Runtime; |
| | | using UIKit; |
| | | using Foundation; |
| | | using Shared.IO; |
| | | using CoreFoundation; |
| | | using System.Collections.Generic; |
| | | using System; |
| | | using System.Runtime; |
| | | |
| | | //namespace Shared |
| | | //{ |
| | | // /// <summary> |
| | | // /// Button 按键 |
| | | // /// </summary> |
| | | // public class MyEchartsView : View |
| | | // { |
| | | // JsonData jsonData = new JsonData { }; |
| | | // UIWebView uIWebView; |
| | | // public MyEchartsView() |
| | | // { |
| | | // uIWebView = new UIWebView { }; |
| | | // uiView = uIWebView; |
| | | // uIWebView.ScrollView.Bounces = false; |
| | | // uIWebView.ScrollView.ScrollEnabled = false; |
| | | // var filePath = NSBundle.MainBundle.PathForResource("echarts", "html"); |
| | | // var url = new NSUrl(filePath); |
| | | // var request = new NSUrlRequest(url); |
| | | // uIWebView.LoadRequest(request); |
| | | // uIWebView.LoadFinished += (sender, e) => { |
| | | // uIWebView.EvaluateJavascript($"loadEcharts({Newtonsoft.Json.JsonConvert.SerializeObject(jsonData)},'undefined')"); |
| | | // }; |
| | | // } |
| | | // public void Show(string title, string[] xArray, object[] yArray) |
| | | // { |
| | | // jsonData.Title = title; |
| | | // jsonData.XArray = xArray; |
| | | // jsonData.YArray = yArray; |
| | | // uIWebView.EvaluateJavascript($"loadEcharts({Newtonsoft.Json.JsonConvert.SerializeObject(jsonData)},'undefined')"); |
| | | // } |
| | | // ///Users/hdl/MyFiles/My/Xamarin/MyApp/Library/Shared.IOS/UI/MyEchartsView.cs(30,30): Error CS0012: The type 'Attribute' is defined in an assembly that is not referenced.You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. (CS0012) (Shared.IOS) |
| | | // ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | // ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | // ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | // public string Unit |
| | | // { |
| | | // get |
| | | // { |
| | | // return jsonData.Unit; |
| | | // } |
| | | // set |
| | | // { |
| | | // jsonData.Unit = value; |
| | | // } |
| | | // } |
| | | namespace Shared |
| | | { |
| | | /// <summary> |
| | | /// Button 按键 |
| | | /// </summary> |
| | | public class MyEchartsView : View |
| | | { |
| | | JsonData jsonData = new JsonData { }; |
| | | UIWebView uIWebView; |
| | | public MyEchartsView() |
| | | { |
| | | uIWebView = new UIWebView { }; |
| | | uiView = uIWebView; |
| | | uIWebView.ScrollView.Bounces = false; |
| | | uIWebView.ScrollView.ScrollEnabled = false; |
| | | var filePath = NSBundle.MainBundle.PathForResource("echarts", "html"); |
| | | var url = new NSUrl(filePath); |
| | | var request = new NSUrlRequest(url); |
| | | uIWebView.LoadRequest(request); |
| | | uIWebView.LoadFinished += (sender, e) => { |
| | | uIWebView.EvaluateJavascript($"loadEcharts({Newtonsoft.Json.JsonConvert.SerializeObject(jsonData)},'undefined')"); |
| | | }; |
| | | } |
| | | public void Show(string title, string[] xArray, object[] yArray) |
| | | { |
| | | jsonData.Title = title; |
| | | jsonData.XArray = xArray; |
| | | jsonData.YArray = yArray; |
| | | uIWebView.EvaluateJavascript($"loadEcharts({Newtonsoft.Json.JsonConvert.SerializeObject(jsonData)},'undefined')"); |
| | | } |
| | | ///Users/hdl/MyFiles/My/Xamarin/MyApp/Library/Shared.IOS/UI/MyEchartsView.cs(30,30): Error CS0012: The type 'Attribute' is defined in an assembly that is not referenced.You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. (CS0012) (Shared.IOS) |
| | | ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | ///Users/hdl/MyFiles/My/Xamarin/MyApp/Demo/IOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Reflection.Emit.ILGenerator System.Reflection.Emit.DynamicMethod::GetILGenerator()', referenced from the method 'Newtonsoft.Json.Serialization.ObjectConstructor`1<System.Object> Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory::CreateParameterizedConstructor(System.Reflection.MethodBase)' in 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (MT2101) (Demo.IOS) |
| | | public string Unit |
| | | { |
| | | get |
| | | { |
| | | return jsonData.Unit; |
| | | } |
| | | set |
| | | { |
| | | jsonData.Unit = value; |
| | | } |
| | | } |
| | | |
| | | |
| | | // [Serializable] |
| | | // class JsonData |
| | | // { |
| | | // /// <summary> |
| | | // /// 标题内容 |
| | | // /// </summary> |
| | | // /// <value>The title.</value> |
| | | // [Newtonsoft.Json.JsonIgnore] |
| | | // public string Title |
| | | // { |
| | | // get |
| | | // { |
| | | // return title["text"].ToString(); |
| | | // } |
| | | // set |
| | | // { |
| | | // title["text"] = value; |
| | | // } |
| | | // } |
| | | // [Newtonsoft.Json.JsonProperty] |
| | | // readonly Dictionary<string, object> title = new Dictionary<string, object> { ["text"] = "" }; |
| | | // [Newtonsoft.Json.JsonProperty] |
| | | // readonly Dictionary<string, object> tooltip = new Dictionary<string, object> { ["trigger"] = "axis" }; |
| | | // /// <summary> |
| | | // /// X轴坐标点 |
| | | // /// </summary> |
| | | // /// <value>The XA rray.</value> |
| | | // [Newtonsoft.Json.JsonIgnore] |
| | | // public string[] XArray |
| | | // { |
| | | // get |
| | | // { |
| | | // return (xAxis[0] as Dictionary<string, object>)["data"] as string[]; |
| | | // } |
| | | // set |
| | | // { |
| | | // (xAxis[0] as Dictionary<string, object>)["data"] = value; |
| | | // } |
| | | // } |
| | | // [Newtonsoft.Json.JsonProperty] |
| | | // readonly List<object> xAxis = new List<object> { new Dictionary<string, object> { ["type"] = "category", ["boundaryGap"] = false, ["data"] = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } } }; |
| | | // [Newtonsoft.Json.JsonIgnore] |
| | | // public string Unit |
| | | // { |
| | | // get |
| | | // { |
| | | // return ((yAxis[0] as Dictionary<string, object>)["axisLabel"] as Dictionary<string, object>)["formatter"].ToString().Substring("{value}".Length); |
| | | // } |
| | | // set |
| | | // { |
| | | // ((yAxis[0] as Dictionary<string, object>)["axisLabel"] as Dictionary<string, object>)["formatter"] = "{value}" + value; |
| | | // } |
| | | // } |
| | | // [Newtonsoft.Json.JsonProperty] |
| | | // readonly List<object> yAxis = new List<object> { new Dictionary<string, object> { ["type"] = "value", ["axisLabel"] = new Dictionary<string, object> { ["formatter"] = "{value}" } } }; |
| | | // /// <summary> |
| | | // /// Y轴坐标点 |
| | | // /// </summary> |
| | | // /// <value>The YA rray.</value> |
| | | // [Newtonsoft.Json.JsonIgnore] |
| | | // public object[] YArray |
| | | // { |
| | | // get |
| | | // { |
| | | // return (series[0] as Dictionary<string, object>)["data"] as object[]; |
| | | // } |
| | | // set |
| | | // { |
| | | // (series[0] as Dictionary<string, object>)["data"] = value; |
| | | // } |
| | | // } |
| | | // [Newtonsoft.Json.JsonProperty] |
| | | // readonly List<object> series = new List<object> { new Dictionary<string, object> { ["name"] = "Value", ["type"] = "line", ["data"] = new object[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, ["markPoint"] = new Dictionary<string, object> { ["data"] = new List<object> { new Dictionary<string, object> { ["type"] = "max", ["name"] = "Max" }, new Dictionary<string, object> { ["type"] = "min", ["name"] = "Min" } } }, ["markLine"] = new Dictionary<string, object> { ["data"] = new List<object> { new Dictionary<string, object> { ["type"] = "average", ["name"] = "Average" } } } } }; |
| | | // } |
| | | // } |
| | | //} |
| | | [Serializable] |
| | | class JsonData |
| | | { |
| | | /// <summary> |
| | | /// 标题内容 |
| | | /// </summary> |
| | | /// <value>The title.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string Title |
| | | { |
| | | get |
| | | { |
| | | return title["text"].ToString(); |
| | | } |
| | | set |
| | | { |
| | | title["text"] = value; |
| | | } |
| | | } |
| | | [Newtonsoft.Json.JsonProperty] |
| | | readonly Dictionary<string, object> title = new Dictionary<string, object> { ["text"] = "" }; |
| | | [Newtonsoft.Json.JsonProperty] |
| | | readonly Dictionary<string, object> tooltip = new Dictionary<string, object> { ["trigger"] = "axis" }; |
| | | /// <summary> |
| | | /// X轴坐标点 |
| | | /// </summary> |
| | | /// <value>The XA rray.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string[] XArray |
| | | { |
| | | get |
| | | { |
| | | return (xAxis[0] as Dictionary<string, object>)["data"] as string[]; |
| | | } |
| | | set |
| | | { |
| | | (xAxis[0] as Dictionary<string, object>)["data"] = value; |
| | | } |
| | | } |
| | | [Newtonsoft.Json.JsonProperty] |
| | | readonly List<object> xAxis = new List<object> { new Dictionary<string, object> { ["type"] = "category", ["boundaryGap"] = false, ["data"] = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } } }; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string Unit |
| | | { |
| | | get |
| | | { |
| | | return ((yAxis[0] as Dictionary<string, object>)["axisLabel"] as Dictionary<string, object>)["formatter"].ToString().Substring("{value}".Length); |
| | | } |
| | | set |
| | | { |
| | | ((yAxis[0] as Dictionary<string, object>)["axisLabel"] as Dictionary<string, object>)["formatter"] = "{value}" + value; |
| | | } |
| | | } |
| | | [Newtonsoft.Json.JsonProperty] |
| | | readonly List<object> yAxis = new List<object> { new Dictionary<string, object> { ["type"] = "value", ["axisLabel"] = new Dictionary<string, object> { ["formatter"] = "{value}" } } }; |
| | | /// <summary> |
| | | /// Y轴坐标点 |
| | | /// </summary> |
| | | /// <value>The YA rray.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public object[] YArray |
| | | { |
| | | get |
| | | { |
| | | return (series[0] as Dictionary<string, object>)["data"] as object[]; |
| | | } |
| | | set |
| | | { |
| | | (series[0] as Dictionary<string, object>)["data"] = value; |
| | | } |
| | | } |
| | | [Newtonsoft.Json.JsonProperty] |
| | | readonly List<object> series = new List<object> { new Dictionary<string, object> { ["name"] = "Value", ["type"] = "line", ["data"] = new object[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, ["markPoint"] = new Dictionary<string, object> { ["data"] = new List<object> { new Dictionary<string, object> { ["type"] = "max", ["name"] = "Max" }, new Dictionary<string, object> { ["type"] = "min", ["name"] = "Min" } } }, ["markLine"] = new Dictionary<string, object> { ["data"] = new List<object> { new Dictionary<string, object> { ["type"] = "average", ["name"] = "Average" } } } } }; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |