private IList <ConfiguredDatasource> getDatasources() { DataTable dt; var datasources = new List <ConfiguredDatasource>(); dt = _db.Ds_GetPageDatasourceList(_urlId, true); foreach (DataRow currRow in dt.Rows) { var cd = new ConfiguredDatasource(); cd.Id = (int)currRow["Id"]; cd.Name = (string)currRow["DisplayName"]; datasources.Add(cd); } return(datasources); }
private static string getDatapointTooltip(ConfiguredDatasource cd, DateTime timestamp, double value) { return (cd.DisplayNameWithUrl + ",<br />" + cd.DatasourceType.Description + ",<br />Timestamp: " + timestamp + ",<br />Value: " + value); }
public string Generate(int configuredDatasourceId, int?subTypeId, DateTime start, DateTime end) { DataTable rawData; byte[] image; ThumbnailChart chart; rawData = _db.QueryRawData(start, end, configuredDatasourceId, subTypeId); //using (chart = new ThumbnailChart()) //{ Bitmap b; DateTime[] timestamps; double?[] values, timestamps2; double slope, yIntercept; bool reverse; ConfiguredDatasource cds = _db.ORManager.Get <ConfiguredDatasource>(configuredDatasourceId); reverse = cds.DatasourceType.Reversed; processRawData(rawData, out timestamps, out values); //LineChart lc = new LineChart(175, 100, LineChartType.SingleDataSet); // float[] chartVals = new float[values.Length]; //for (int i = 0; i < values.Length; i++) // if(values[i] != null) // chartVals[i] = (float)values[i].Value; //lc.SetData(chartVals); double?min, max; YTech.General.Charting.ChartMath.GetDataBounds(values, out min, out max); if (min == null) { return("http://chart.apis.google.com/chart?cht=lxy&chs=175x100"); } string dataString = GetDataString(timestamps, values, min.Value - 2); Color backgroundColor = getChartBackground(timestamps, values, reverse); string bgHex = ColorToGoogleHex(backgroundColor); return (string.Format("http://chart.apis.google.com/chart?cht=lxy&chs=175x100&chd=t:{0}|{1}&chds=0,100,{1},{2}&chf=bg,s,{3}&chco=000000", dataString, min.Value - 1, max.Value + 1, bgHex)); /* * timestamps2 = new double?[timestamps.Length]; * for (int i = 0; i < timestamps.Length; i++) * if (values[i] != null) timestamps2[i] = timestamps[i].ToOADate(); * MathFunctions.TrendFunction(values, timestamps2, out slope, out yIntercept); * if (double.IsNaN(slope)) slope = 0; * if (reverse) slope *= -1; * alpha = (int) ((Math.Abs(Math.Atan(slope))/(Math.PI/2))*191.0) + 64; * * chart.InverseScale = reverse; * chart.Height = 100; * chart.Width = 175; * * chart.Timestamps = timestamps; * chart.YValues = values; * if (slope == 0) * chart.BackgroundColor = Color.White; * else if (slope > 0) * chart.BackgroundColor = Color.FromArgb(alpha, Color.Green); * else * chart.BackgroundColor = Color.FromArgb(alpha, Color.Red); * b = chart.GenerateBitmap(); * image = ImageUtilities.BitmapToBytes(b, ImageFormat.Png); * } * * return image; */ //return lc.GetUrl(); }