public async Task GetImageLinkFromOptions_Works()
		{
			var client = new HighchartsClient(_highchartsServer);

			var options = new
			{
				xAxis = new
				{
					categories = new[] { "Jan", "Feb", "Mar" }
				},
				series = new[]
				{
					new { data = new[] {29.9, 71.5, 106.4} }
				}
			};

			var res = await client.GetChartImageLinkFromOptionsAsync(JsonConvert.SerializeObject(options));

			Assert.IsNotNull(res);
			Console.WriteLine(res);
		}
Beispiel #2
0
        public async Task GetImageLinkFromOptions_Works()
        {
            var client = new HighchartsClient(_highchartsServer);

            var options = new
            {
                xAxis = new
                {
                    categories = new[] { "Jan", "Feb", "Mar" }
                },
                series = new[]
                {
                    new { data = new[] { 29.9, 71.5, 106.4 } }
                }
            };

            var res = await client.GetChartImageLinkFromOptionsAsync(JsonConvert.SerializeObject(options));

            Assert.IsNotNull(res);
            Console.WriteLine(res);
        }
Beispiel #3
0
        private string ProcessHighChartImageFromExportServer(HighCharts highCharts, string ChartTitle = "Chart Title")
        {
            try
            {
                var    chartImageName = string.Format(@"{0}.jpeg", Guid.NewGuid());
                string outputFile     = HttpContext.Server.MapPath("~/ReportResource/" + chartImageName);
                var    client         = new HighchartsClient("http://export.highcharts.com/");

                var infile = JsonConvert.SerializeObject(highCharts.options, Formatting.Indented, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
                JObject jo = new JObject();
                jo = JObject.Parse(infile);

                string title = @"{""text"":" + '"' + ChartTitle + '"' + "}";
                jo.Add("title", JObject.Parse(title));
                JObject header = (JObject)jo.SelectToken("chart");

                header.Property("marginRight").Remove();
                header.Property("marginLeft").Remove();
                //jo.Property("marginLeft").Remove();
                infile = jo.ToString();
                //System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/Phantom/jsondata.json"), infile);
                Thread.Sleep(14000);
                var res = client.GetChartImageLinkFromOptionsAsync(infile).Result;

                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFile(new Uri(res), outputFile);
                }
                //logger.Error(chartImageName + " Image Generated!");
                return(chartImageName);
            }
            catch (Exception ex)
            {
                //logger.Error(ex.InnerException + "Process Image--");
                throw;
            }
        }
Beispiel #4
0
    private async Task <Texture2D> DownloadHighchartsAsTexture(string data)
    {
        //Init have to be done there and not in Start function due to the fact that the LIB object doesn't exisst as Game Object (so, Start is never called)
        if (HighchartsClient == null && HighchartsSettings == null)
        {
            HighchartsSettings               = new HighchartsSetting();
            HighchartsSettings.IsAsyncCall   = true;
            HighchartsSettings.ServerAddress = HighchartsUrl;
            HighchartsClient = new HighchartsClient(HighchartsSettings);
            print("Highcharts init in Requea lib done");
        }
        Texture2D tex = new Texture2D(4, 4, TextureFormat.DXT1, false);

        try
        {
            string link = await HighchartsClient.GetChartImageLinkFromOptionsAsync(data);

            print(link);

            using (WWW www = new WWW(link))
            {
                while (!www.isDone)
                {
                    //Wait... I know it's an horrific solution but the only one working after 50+ different test. No waiter, getter, or observable allowed on Unity classes, and cannot make yield work correctly their
                }

                www.LoadImageIntoTexture(tex);
            }
        }
        catch (Exception e)
        {
            print("exception in api highchart call :" + e.Message);
        }

        return(tex);
    }