/// <summary> /// /// </summary> /// <param name="tbl"></param> /// <param name="cfg"></param> /// <returns></returns> public LineBase CreateLine(DataTable tbl, LineDataConfig cfg, string xAxisFieldName) { LineBase line1 = CreateLine(); line1.Colour = cfg.Color; // line name and font size // line1.Set_Key(cfg.Name, cfg.FontSize); //line1.Tooltip = "my tip #val#"; //line1.Tooltip = "x_label #value#"; foreach (DataRow row in tbl.Rows) { double value = 0; object valueObject = row[cfg.DataFieldName]; if (valueObject != DBNull.Value) { value = Convert.ToDouble(valueObject); } DateTime dt = Convert.ToDateTime(row[xAxisFieldName]); string tip = string.Format("{0}\n{1}\n{2}\n", cfg.Name, dt, value); LineDotValue ldValue = new LineDotValue(value, tip, cfg.Color); line1.Add(ldValue); } return(line1); }
/// <summary> /// /// </summary> /// <returns></returns> internal OpenFlashChart.ChartBase CreateElement() { LineBase line1 = CreateLine(); _linebase = line1; // color // // line name and font size // line1.Set_Key(this.Key, this.KeyFontSize); //line1.Tooltip = "my tip #val#"; //line1.Tooltip = "x_label #value#"; DataTable tbl = this.DataSource as DataTable; foreach (DataRow row in tbl.Rows) { double value = Convert.ToDouble(row[this.DataFieldName]); DateTime dt = Convert.ToDateTime(row[this.DTFieldName]); string tip = string.Format("{0}\n{1}", value, dt); LineDotValue ldValue = new LineDotValue(value, tip, "#0000ff"); line1.Add(ldValue); } return(line1); }
protected void Page_Load(object sender, EventArgs e) { OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart(); ArrayList data1 = new ArrayList(); Random rand = new Random(DateTime.Now.Millisecond); for (double i = 0; i < 12; i++) { int temp = rand.Next(30); if (temp > 20) { data1.Add(new LineDotValue(temp, "your tip", "#fe0fe0")); } else { data1.Add(temp); } } LineDotValue dotValue1 = new LineDotValue(rand.Next(30)); dotValue1.Sides = 3; dotValue1.DotType = DotType.HOLLOW_DOT; data1.Add(dotValue1); LineDotValue dotValue2 = new LineDotValue(rand.Next(30)); dotValue2.IsHollow = true; dotValue2.DotType = DotType.STAR; data1.Add(dotValue2); LineDotValue dotValue3 = new LineDotValue(rand.Next(30)); dotValue3.Sides = 4; dotValue3.DotType = DotType.DOT; data1.Add(dotValue3); OpenFlashChart.LineHollow line1 = new LineHollow(); line1.Values = data1; line1.HaloSize = 0; line1.Width = 2; line1.DotSize = 5; line1.Tooltip = "提示:#val#"; chart.AddElement(line1); chart.Title = new Title("line演示"); chart.Y_Axis.SetRange(0, 35, 5); chart.Tooltip = new ToolTip("全局提示:#val#"); chart.Tooltip.Shadow = true; chart.Tooltip.Colour = "#e43456"; chart.Tooltip.MouseStyle = ToolTipStyle.CLOSEST; Response.Clear(); Response.CacheControl = "no-cache"; Response.Write(chart.ToPrettyString()); Response.End(); }
/// <summary> /// /// </summary> /// <returns></returns> private bool IsAllZeroLine(LineBase line) { foreach (object obj in line.Values) { LineDotValue ldv = obj as LineDotValue; if (ldv.Value != 0) { return(false); } } return(true); }
/// <summary> /// /// </summary> /// <param name="list"></param> public void Find(IList list) { foreach (object obj in list) { LineDotValue ldv = obj as LineDotValue; double value = (double)ldv.Value; // min // if (_hasMin) { if (value < _min) { _min = value; } } else { _min = value; _hasMin = true; } // // if (_hasMax) { if (value > _max) { _max = value; } } else { _max = value; _hasMax = true; } } }