This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class AnimationBase
{
}
public class Animation : AnimationBase
{
private string type;
private double? cascade;
private double? delay;
public Animation()
{}
public Animation(string type,int? cascade,double? delay)
{
this.Type = type;
this.Cascade = cascade;
this.Delay = delay;
}
[JsonProperty("type")]
public string Type
{
get { return type; }
set { type = value; }
}
[JsonProperty("cascade")]
public double? Cascade
{
get { return cascade; }
set { cascade = value; }
}
[JsonProperty("delay")]
public double? Delay
{
get { return delay; }
set { delay = value; }
}
}
public class PieAnimation : AnimationBase
{
private string type;
private int? distance;
/// <summary>
/// used in pie animation
/// </summary>
/// <param name="type"></param>
/// <param name="distance"></param>
public PieAnimation(string type,int?distance)
{
this.type = type;
this.distance = distance;
}
[JsonProperty("type")]
public string Type
{
get { return type; }
set { type = value; }
}
[JsonProperty("distance")]
public int? Distance
{
get { return distance; }
set { distance = value; }
}
}
public class PieAnimationSeries:List<PieAnimation>
{}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class AnimationType
{
public const string Popup = "pop-up";
public const string Explode = "explode";
public const string MidSlide = "mid-slide";
public const string Drop = "drop";
public const string Fadein = "fade-in";
public const string Shrinkin = "shrink-in";
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class Area:AreaBase
{
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public abstract class AreaBase:Chart<double >
{
private int? width;
private double? dotsize;
private double? halosize;
private bool loop;
private string fillcolour;
private Animation onshow = new Animation();
protected AreaBase()
{
this.ChartType = "area";
}
[JsonProperty("fill")]
public string FillColor
{
get { return fillcolour; }
set { fillcolour = value; }
}
[JsonProperty("width")]
public virtual int? Width
{
set { this.width = value; }
get { return this.width; }
}
[JsonProperty("dot-size")]
public virtual double? DotSize
{
get { return dotsize; }
set { dotsize = value; }
}
[JsonProperty("loop")]
public bool Loop
{
get { return loop; }
set { loop = value; }
}
[JsonProperty("halo-size")]
public double? HaloSize
{
get { return halosize; }
set { halosize = value; }
}
[JsonProperty("on-show")]
public Animation OnShowAnimation
{
get { return onshow; }
set { onshow = value; }
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
[Obsolete("use Area instead")]
public class AreaHollow : AreaBase
{
public AreaHollow()
{
//this.ChartType = "area_hollow";
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
[Obsolete("use Area instead")]
public class AreaLine:AreaBase
{
public AreaLine()
{
// this.ChartType = "area_line";
}
}
}

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class Axis
{
private int? stroke;
private string colour;
private string gridColour;
private int? steps;
private int _3D;
private double? min;
private double? max;
private bool offset;
public Axis()
{
offset = true;
}
[JsonProperty("stroke")]
public int? Stroke
{
set { this.stroke = value; }
get { return this.stroke; }
}
[JsonProperty("colour")]
public string Colour
{
set { this.colour = value; }
get { return this.colour; }
}
[JsonProperty("grid-colour")]
public string GridColour
{
set { this.gridColour = value; }
get { return this.gridColour; }
}
[JsonProperty("steps")]
public int? Steps
{
set { steps = value; }
get { return this.steps; }
}
public void SetColors(string color,string gridcolor)
{
this.colour = color;
this.gridColour = gridcolor;
}
public void Set3D(int width)
{
this.Axis3D = width;
}
[JsonProperty("min")]
public double? Min
{
get { return min; }
set { this.min = value; }
}
[JsonProperty("max")]
public double? Max
{
get { return max; }
set { this.max = value; }
}
[JsonProperty("3d")]
public int Axis3D
{
get { return _3D; }
set { _3D = value; }
}
[JsonProperty("offset")]
public bool Offset
{
set { offset = value; }
get { return offset; }
}
public void SetRange(double? min, double? max)
{
Max = max;
Min = min;
}
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class AxisLabel
{
private string colour;
private string text;
private int size;
private string rotate;
private bool visible = true;
public AxisLabel()
{
this.visible = true;
size = 12;
}
public AxisLabel(string text)
{
this.text = text;
this.visible = true;
size = 12;
}
public static implicit operator AxisLabel(string text)
{
return new AxisLabel(text);
}
public AxisLabel(string text, string colour, int size, string rotate)
{
this.text = text;
this.colour = colour;
this.size = size;
this.rotate = rotate;
this.visible = true;
}
[JsonProperty("colour")]
public string Color
{
set { this.colour = value; }
get { return this.colour; }
}
[JsonProperty("text")]
public string Text
{
set { this.text = value; }
get { return this.text; }
}
[JsonProperty("size")]
public int Size
{
set { this.size = value; }
get { return this.size; }
}
[JsonProperty("rotate")]
public string Rotate
{
set { this.rotate = value; }
get { return this.rotate; }
}
[JsonIgnore]
public bool Vertical
{
set {
if(value)
this.rotate = "vertical";
}
}
[JsonProperty("visible")]
public bool Visible
{
set { this.visible = value; }
get { return this.visible; }
}
}
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class AxisLabels
{
private int? steps;
protected IList<object> labels;
private string colour;
private string rotate;
private int? fontsize;
private int? visiblesteps;
private string formatstring;
[JsonProperty("steps")]
public int? Steps
{
get
{
if (this.steps == null)
return null;
return this.steps;
}
set { this.steps = value; }
}
[JsonProperty("labels")]
[Obsolete("just for json generation,not used.Use SetLabels()")]
public IList<object> AxisLabelValues
{
get { return labels; }
set { this.labels = value; }
}
public virtual void SetLabels(IList<string> labelsvalue)
{
if (labels == null)
labels = new List<object>();
foreach (string s in labelsvalue)
{
labels.Add(s);
}
}
public void Add(AxisLabel label)
{
if (labels == null)
labels = new List<object>();
labels.Add(label);
}
[JsonProperty("colour")]
public string Color
{
set { this.colour = value; }
get { return this.colour; }
}
[JsonProperty("rotate")]
public string Rotate
{
set { this.rotate = value; }
get { return this.rotate; }
}
[JsonIgnore]
public bool Vertical
{
set
{
if (value)
this.rotate = "vertical";
}
}
[JsonProperty("size")]
public int? FontSize
{
get { return fontsize; }
set { fontsize = value; }
}
[JsonProperty("text")]
public string FormatString
{
get { return formatstring; }
set { formatstring = value; }
}
[JsonProperty("visible-steps")]
public int? VisibleSteps
{
get { return visiblesteps; }
set { visiblesteps = value; }
}
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class BarValue
{
protected double? bottom;
protected double? top;
protected string color;
protected string tip;
private string onclick;
public BarValue()
{
}
public BarValue(double top)
{
this.top = top;
}
public BarValue(double top,double bottom)
{
this.bottom = bottom;
this.top = top;
}
[JsonProperty("bottom")]
public double? Bottom
{
get { return bottom; }
set { bottom = value; }
}
[JsonProperty("top")]
public double? Top
{
get { return top; }
set { top = value; }
}
[JsonProperty("colour")]
public string Color
{
get { return color; }
set { color = value; }
}
[JsonProperty("tip")]
public string Tip
{
get { return tip; }
set { tip = value; }
}
[JsonProperty("on-click")]
public string OnClick
{
get { return onclick; }
set { onclick = value; }
}
}
public class Bar:BarBase
{
public Bar()
{
this.ChartType = "bar";
}
/// <summary>
///
/// </summary>
[JsonIgnore]
public string BarType
{
get { return this.ChartType; }
set { this.ChartType = value; }
}
public void Add(BarValue barValue)
{
this.Values.Add(barValue);
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class Bar3D:BarBase
{
public Bar3D()
{
this.ChartType = "bar_3d";
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public abstract class BarBase : Chart<double>
{
private Animation onshow = new Animation();
protected BarBase()
{
this.ChartType = "bar";
}
[JsonProperty("on-show")]
public Animation OnShowAnimation
{
get { return onshow; }
set { onshow = value; }
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class BarFilledValue:BarValue
{
private string outline_color;
public BarFilledValue():base()
{}
public BarFilledValue(double top, double bottom):base(top,bottom)
{
}
[JsonProperty("outline-colour")]
public string OutlineColor
{
get { return outline_color; }
set { outline_color = value; }
}
}
public class BarFilled : BarBase
{
public BarFilled()
{
this.ChartType = "bar_filled";
}
public void Add(BarFilledValue barFilledValue)
{
this.Values.Add(barFilledValue);
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class BarGlassValue:BarValue
{
public BarGlassValue(double top):base(top)
{
}
}
public class BarGlass : BarBase
{
public BarGlass()
{
this.ChartType = "bar_glass";
}
public void Add(BarGlassValue barGlassValue)
{
this.Values.Add(barGlassValue);
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class BarSketch:BarBase
{
private string outlinecolour;
private int? offset;
public BarSketch(string colour,string outlinecolor,int? offset)
{
this.ChartType = "bar_sketch";
this.Colour = colour;
this.outlinecolour = outlinecolor;
this.offset = offset;
}
[JsonProperty("offset")]
public int? Offset
{
get { return offset.Value; }
set { this.offset = value; }
}
[JsonProperty("outline-colour")]
public string OutlineColour
{
get { return outlinecolour; }
set { this.outlinecolour = value; }
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class BarStackValue
{
private string colour;
private double val;
public BarStackValue(double val,string color)
{
this.Colour = color;
this.Val = val;
}
public BarStackValue(double val)
{
this.Val = val;
}
public BarStackValue()
{
}
public static implicit operator BarStackValue(double val)
{
return new BarStackValue(val);
}
[JsonProperty("colour")]
public string Colour
{
get { return colour; }
set { colour = value; }
}
[JsonProperty("val")]
public double Val
{
get { return val; }
set { val = value; }
}
}
public class BarStack:BarBase
{
public BarStack()
{
this.ChartType = "bar_stack";
}
public void Add(BarStackValue barStackValue)
{
this.Values.Add(barStackValue);
}
public void AddStack(List<BarStackValue> barStackValues)
{
base.Values.Add(barStackValues);
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public static class BarType
{
public const string BAR = "bar";
public const string HBAR = "hbar";
public const string BAR_STACK = "bar_stack";
public const string BAR_SKETCH = "bar_sketch";
public const string BAR_GLASS = "bar_glass";
public const string BAR_CYLINDER = "bar_cylinder";
public const string BAR_CYLINDER_OUTLINE = "bar_cylinder_outline";
public const string BAR_DOME = "bar_dome";
public const string BAR_ROUND = "bar_round";
public const string BAR_ROUND_GLASS = "bar_round_glass";
public const string BAR_ROUND3D = "bar_round3d";
public const string BAR_FADE = "bar_fade";
public const string BAR_3D = "bar_3d";
public const string BAR_FILLED = "bar_filled";
public const string BAR_PLASTIC = "bar_plastic";
public const string BAR_PLASTIC_FLAT = "bar_plastic_flat";
public const string CANDLE = "candle";
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class CandleValue:BarValue
{
protected double? high;
protected double? low;
[JsonProperty("high")]
public double? High
{
get { return high; }
set { high = value; }
}
[JsonProperty("low")]
public double? Low
{
get { return low; }
set { low = value; }
}
public CandleValue()
{}
public CandleValue(double high,double top,double bottom,double low)
{
this.high = high;
this.top = top;
this.bottom = bottom;
this.low = low;
}
}
public class Candle:BarBase
{
public Candle()
{
this.ChartType = "candle";
}
public void Add(CandleValue candleValue)
{
this.values.Add(candleValue);
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class Chart<T> :ChartBase
{
public Chart()
{
this.values = new ArrayList();
FillAlpha = 0.35;
//fontsize = 20;
}
//public override double GetMaxValue()
//{
// if (values.Count == 0)
// return 0;
// double max = double.MinValue;
// Type valuetype = typeof(T);
// if (!valuetype.IsValueType)
// return 0;
// foreach (T d in values)
// {
// double temp = double.Parse(d.ToString());
// if (temp > max)
// max = temp;
// }
// return max;
//}
//public override double GetMinValue()
//{
// if (values.Count == 0)
// return 0;
// double min = double.MaxValue;
// Type valuetype = typeof (T);
// if (!valuetype.IsValueType)
// return 0;
// foreach (T d in values)
// {
// double temp = double.Parse(d.ToString());
// if(temp<min)
// min = temp;
// }
// return min;
//}
public void Add(T v)
{
this.values.Add(v);
}
}
}

View File

@@ -0,0 +1,143 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public abstract class ChartBase
{
private string type;
protected IList values;
private double fillalpha;
private double? alpha;
private double? fontsize;
private string colour;
private string text;
private string tooltip;
private DotStyle dotstyle;
private bool attachtorightaxis;
protected ChartBase()
{
this.values = new ArrayList();
FillAlpha = 0.35;
colour = "#CC3399";
attachtorightaxis = false;
}
public void AttachToRightAxis(bool attach)
{
attachtorightaxis = attach;
}
[JsonProperty("axis")]
[Description("use AttachToRight(),this property only for json generate.")]
public string AttachedAxis
{
get
{
if (attachtorightaxis)
return "right";
return null;
}
set
{
attachtorightaxis = string.Compare(value,"right",StringComparison.CurrentCultureIgnoreCase)==0;
}
}
[JsonProperty("colour")]
public string Colour
{
set { this.colour = value; }
get { return this.colour; }
}
public virtual int GetValueCount()
{
return values.Count;
}
[JsonProperty("tip")]
public virtual string Tooltip
{
set { this.tooltip = value; }
get { return this.tooltip; }
}
[JsonProperty("values")]
public virtual IList Values
{
set
{
// foreach (T t in value)
// {
// this.values.Add(t);
// }
this.values = value;
}
get { return this.values; }
}
[JsonProperty("font-size")]
[System.ComponentModel.DefaultValue(12.0)]
public double? FontSize
{
get { return fontsize; }
set { fontsize = value; }
}
[JsonProperty("text")]
public string Text
{
get { return text; }
set { text = value; }
}
[JsonProperty("fill-alpha")]
public double FillAlpha
{
get { return fillalpha; }
set { fillalpha = value; }
}
[JsonProperty("alpha")]
public double? Alpha
{
get { return alpha; }
set { alpha = value; }
}
[JsonProperty("type")]
public string ChartType
{
get { return type; }
set { type = value; }
}
[JsonProperty("dot-style")]
public DotStyle DotStyleType
{
get
{
if(dotstyle==null)
dotstyle=new DotStyle();
return dotstyle;
}
set
{
if(dotstyle==null)
dotstyle=new DotStyle();
dotstyle = value;
}
}
//public abstract Double GetMinValue();
//public abstract Double GetMaxValue();
public void Set_Key(string key, double font_size)
{
this.Text = key;
FontSize = font_size;
}
public void Add(object v)
{
this.values.Add(v);
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Design;
namespace OpenFlashChart
{
public class ChartControlDesigner : ControlDesigner
{
public override string GetDesignTimeHtml()
{
string errorDesignTimeHtml;
StringBuilder builder = new StringBuilder();
try
{
OpenFlashChartControl component = (OpenFlashChartControl)base.Component;
OpenFlashChartControl chart = component;
builder.AppendFormat("<div style='width:{0};height:{1};'>", chart.Width, chart.Height);
builder.Append("<span style=\"font-size:16px;position:absolute;\">Open Flash Chart Control</span>");
builder.Append("</div>");
errorDesignTimeHtml = this.CreatePlaceHolderDesignTimeHtml(builder.ToString());
}
catch (Exception e)
{
errorDesignTimeHtml = this.GetErrorDesignTimeHtml(e);
}
return errorDesignTimeHtml;
}
protected override string GetErrorDesignTimeHtml(Exception e)
{
string instruction = string.Format("Exception:{0}", e.Message );
return this.CreatePlaceHolderDesignTimeHtml(instruction);
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class ChartElement
{
private string text;
private string style;
[JsonProperty("text")]
public virtual string Text
{
set { this.text = value; }
get { return this.text; }
}
[JsonProperty("style")]
public string Style
{
set { style = value; }
get
{
if (style == null)
style = "{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
return this.style;
}
//"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
}
}
}

View File

@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class DotStyle
{
private string type;
private int? sides;
private double? alpha;
private bool? isHollow;
private string background_colour;
private double ? background_alpha;
private int? width;
private string tip;
private string colour;
private int? dotsize;
private string onclick;
private Animation onshow = new Animation();
[JsonProperty("on-show")]
public Animation OnShowAnimation
{
get { return onshow; }
set { onshow = value; }
}
[JsonProperty("type")]
public String Type
{
get{ return type;}
set { type = value; }
}
[JsonProperty("sides")]
public int? Sides
{
get { return sides; }
set { sides = value; }
}
[JsonProperty("alpha")]
public double? Alpha
{
get { return alpha; }
set { alpha = value; }
}
[JsonProperty("hollow")]
public bool? IsHollow
{
get { return isHollow; }
set { isHollow = value; }
}
[JsonProperty("background-colour")]
public string BackgroundColour
{
get { return background_colour; }
set { background_colour = value; }
}
[JsonProperty("background-alpha")]
public double? BackgroundAlpha
{
get { return background_alpha; }
set { background_alpha = value; }
}
[JsonProperty("width")]
public int? Width
{
get { return width; }
set { width = value; }
}
[JsonProperty("tip")]
public string Tip
{
get { return tip; }
set { tip = value; }
}
[JsonProperty("colour")]
public string Colour
{
get { return colour; }
set { colour = value; }
}
[JsonProperty("dot-size")]
public int? DotSize
{
get { return dotsize; }
set { dotsize = value; }
}
[JsonProperty("on-click")]
public string OnClick
{
get { return onclick; }
set { onclick = value; }
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
//trick ,use class as enum.
public static class DotType
{
public const string SOLID_DOT = "solid-dot";
public const string HOLLOW_DOT = "hollow-dot";
public const string ANCHOR = "anchor";
public const string STAR = "star";
public const string BOW = "bow";
public const string DOT = "dot";
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class HBarValue
{
private double left;
private double right;
private string tip;
public HBarValue(double left,double right)
{
this.Left = left;
this.Right = right;
}
public HBarValue(double left, double right,string tip)
{
this.Left = left;
this.Right = right;
this.tip = tip;
}
[JsonProperty("left")]
public double Left
{
get { return left; }
set { left = value; }
}
[JsonProperty("right")]
public double Right
{
get { return right; }
set { right = value; }
}
public string Tip
{
get { return tip; }
set { tip = value; }
}
}
public class HBar:BarBase
{
public HBar()
{
this.ChartType = "hbar";
}
public void Add(HBarValue hBarValue)
{
this.Values.Add(hBarValue);
}
}
}

View File

@@ -0,0 +1,43 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
namespace JsonFx.Json
{
/// <summary>
/// Allows classes to control their own JSON serialization
/// </summary>
public interface IJsonSerializable
{
void ReadJson(JsonReader reader);
void WriteJson(JsonWriter writer);
}
}

View File

@@ -0,0 +1,111 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
using System.Reflection;
using System.Xml.Serialization;
namespace JsonFx.Json
{
/// <summary>
/// Designates a property or field to not be serialized.
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple=false)]
public sealed class JsonIgnoreAttribute : Attribute
{
#region Methods
/// <summary>
/// Gets a value which indicates if should be ignored in Json serialization.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool IsJsonIgnore(object value)
{
if (value == null)
{
return false;
}
Type type = value.GetType();
ICustomAttributeProvider provider = null;
if (type.IsEnum)
{
provider = type.GetField(Enum.GetName(type, value));
}
else
{
provider = value as ICustomAttributeProvider;
}
if (provider == null)
{
throw new ArgumentException();
}
return provider.IsDefined(typeof(JsonIgnoreAttribute), true);
}
/// <summary>
/// Gets a value which indicates if should be ignored in Json serialization.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool IsXmlIgnore(object value)
{
if (value == null)
{
return false;
}
Type type = value.GetType();
ICustomAttributeProvider provider = null;
if (type.IsEnum)
{
provider = type.GetField(Enum.GetName(type, value));
}
else
{
provider = value as ICustomAttributeProvider;
}
if (provider == null)
{
throw new ArgumentException();
}
return provider.IsDefined(typeof(XmlIgnoreAttribute), true);
}
#endregion Methods
}
}

View File

@@ -0,0 +1,178 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
using System.Reflection;
using System.Xml.Serialization;
namespace JsonFx.Json
{
/// <summary>
/// Specifies the naming to use for a property or field when serializing
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple=false)]
public class JsonNameAttribute : Attribute
{
#region Fields
private string jsonName = null;
#endregion Fields
#region Init
/// <summary>
/// Ctor
/// </summary>
public JsonNameAttribute()
{
}
/// <summary>
/// Ctor
/// </summary>
/// <param name="jsonName"></param>
public JsonNameAttribute(string jsonName)
{
this.jsonName = JsonWriter.EnsureValidIdentifier(jsonName, false);
}
#endregion Init
#region Properties
/// <summary>
/// Gets and sets the name to be used in JSON
/// </summary>
public string Name
{
get { return this.jsonName; }
set { this.jsonName = JsonWriter.EnsureValidIdentifier(value, false); }
}
#endregion Properties
#region Methods
/// <summary>
/// Gets the name specified for use in Json serialization.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string GetJsonName(object value)
{
if (value == null)
{
return null;
}
Type type = value.GetType();
MemberInfo memberInfo = null;
if (type.IsEnum)
{
string name = Enum.GetName(type, value);
if (String.IsNullOrEmpty(name))
{
return null;
}
memberInfo = type.GetField(name);
}
else
{
memberInfo = value as MemberInfo;
}
if (memberInfo == null)
{
throw new ArgumentException();
}
if (!Attribute.IsDefined(memberInfo, typeof(JsonNameAttribute)))
{
return null;
}
JsonNameAttribute attribute = (JsonNameAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(JsonNameAttribute));
return attribute.Name;
}
///// <summary>
///// Gets the name specified for use in Json serialization.
///// </summary>
///// <param name="value"></param>
///// <returns></returns>
//public static string GetXmlName(object value)
//{
// if (value == null)
// {
// return null;
// }
// Type type = value.GetType();
// ICustomAttributeProvider memberInfo = null;
// if (type.IsEnum)
// {
// string name = Enum.GetName(type, value);
// if (String.IsNullOrEmpty(name))
// {
// return null;
// }
// memberInfo = type.GetField(name);
// }
// else
// {
// memberInfo = value as ICustomAttributeProvider;
// }
// if (memberInfo == null)
// {
// throw new ArgumentException();
// }
// XmlAttributes xmlAttributes = new XmlAttributes(memberInfo);
// if (xmlAttributes.XmlElements.Count == 1 &&
// !String.IsNullOrEmpty(xmlAttributes.XmlElements[0].ElementName))
// {
// return xmlAttributes.XmlElements[0].ElementName;
// }
// if (xmlAttributes.XmlAttribute != null &&
// !String.IsNullOrEmpty(xmlAttributes.XmlAttribute.AttributeName))
// {
// return xmlAttributes.XmlAttribute.AttributeName;
// }
// return null;
//}
#endregion Methods
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace JsonFx.Json
{
[AttributeUsage(AttributeTargets.All, AllowMultiple=false)]
public class JsonPropertyAttribute:JsonNameAttribute
{
public JsonPropertyAttribute():base()
{ }
public JsonPropertyAttribute(string jsonname):base(jsonname)
{
}
}
}

View File

@@ -0,0 +1,153 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
namespace JsonFx.Json
{
public class JsonSerializationException : InvalidOperationException
{
#region Init
public JsonSerializationException() : base() { }
public JsonSerializationException(string message) : base(message) { }
public JsonSerializationException(string message, Exception innerException) : base(message, innerException) { }
public JsonSerializationException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context)
{
}
#endregion Init
}
public class JsonDeserializationException : JsonSerializationException
{
#region Fields
private int index = -1;
#endregion Fields
#region Init
public JsonDeserializationException(string message, int index) : base(message)
{
this.index = index;
}
public JsonDeserializationException(string message, Exception innerException, int index)
: base(message, innerException)
{
this.index = index;
}
public JsonDeserializationException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context)
{
}
#endregion Init
#region Properties
/// <summary>
/// Gets the character position in the stream where the error occurred.
/// </summary>
public int Index
{
get { return this.index; }
}
#endregion Properties
#region Methods
/// <summary>
/// Helper method which converts the index into Line and Column numbers
/// </summary>
/// <param name="source"></param>
/// <param name="line"></param>
/// <param name="col"></param>
public void GetLineAndColumn(string source, out int line, out int col)
{
if (source == null)
{
throw new ArgumentNullException();
}
col = 1;
line = 1;
bool foundLF = false;
int i = Math.Min(this.index, source.Length);
for (; i>0; i--)
{
if (!foundLF)
{
col++;
}
if (source[i-1] == '\n')
{
line++;
foundLF = true;
}
}
}
#endregion Methods
}
public class JsonTypeCoersionException : ArgumentException
{
#region Init
public JsonTypeCoersionException() : base() { }
public JsonTypeCoersionException(string message) : base(message) { }
public JsonTypeCoersionException(string message, Exception innerException) : base(message, innerException) { }
public JsonTypeCoersionException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context)
{
}
#endregion Init
}
}

View File

@@ -0,0 +1,96 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
using System.Reflection;
namespace JsonFx.Json
{
/// <summary>
/// Specifies the name of the property which specifies if member should be serialized.
/// </summary>
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false)]
public class JsonSpecifiedPropertyAttribute : Attribute
{
#region Fields
private string specifiedProperty = null;
#endregion Fields
#region Init
/// <summary>
/// Ctor
/// </summary>
/// <param name="propertyName">the name of the property which controls serialization for this member</param>
public JsonSpecifiedPropertyAttribute(string propertyName)
{
this.specifiedProperty = propertyName;
}
#endregion Init
#region Properties
/// <summary>
/// Gets and sets the name of the property which
/// specifies if member should be serialized
/// </summary>
public string SpecifiedProperty
{
get { return this.specifiedProperty; }
set { this.specifiedProperty = value; }
}
#endregion Properties
#region Methods
/// <summary>
/// Gets the name specified for use in Json serialization.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string GetJsonSpecifiedProperty(MemberInfo memberInfo)
{
if (memberInfo == null ||
!Attribute.IsDefined(memberInfo, typeof(JsonSpecifiedPropertyAttribute)))
{
return null;
}
JsonSpecifiedPropertyAttribute attribute = (JsonSpecifiedPropertyAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(JsonSpecifiedPropertyAttribute));
return attribute.SpecifiedProperty;
}
#endregion Methods
}
}

View File

@@ -0,0 +1,57 @@
#region License
/*---------------------------------------------------------------------------------*\
Distributed under the terms of an MIT-style license:
The MIT License
Copyright (c) 2006-2009 Stephen M. McKamey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\*---------------------------------------------------------------------------------*/
#endregion License
using System;
namespace JsonFx.Json
{
/// <summary>
/// Parse Tokens
/// </summary>
internal enum JsonToken
{
End,
Undefined,
Null,
False,
True,
NaN,
PositiveInfinity,
NegativeInfinity,
Number,
String,
ArrayStart,
ArrayEnd,
ObjectStart,
ObjectEnd,
NameDelim,
ValueDelim
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class Legend:ChartElement
{
public Legend(string text)
{
base.Text = text;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class Line : LineBase
{
public Line()
{
this.ChartType = "line";
}
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class LineBase : Chart<LineDotValue>
{
private int width;
private int dotsize;
private int halosize;
private string onclick;
private bool loop;
private Animation onshow=new Animation();
public LineBase()
{
this.ChartType = "line";
this.DotStyleType.Type = DotType.SOLID_DOT;
}
public void SetOnClickFunction(string func)
{
this.DotStyleType.OnClick = func;
this.onclick = func;
}
public virtual string OnClick
{
set
{
SetOnClickFunction(value);
}
get { return this.onclick; }
}
[JsonProperty("width")]
public virtual int Width
{
set { this.width = value; }
get { return this.width; }
}
[JsonProperty("dot-size")]
public virtual int DotSize
{
get { return dotsize; }
set { dotsize = value; }
}
[JsonProperty("halo-size")]
public virtual int HaloSize
{
get { return halosize; }
set { halosize = value; }
}
[JsonProperty("loop")]
public bool Loop
{
get { return loop; }
set { loop = value; }
}
[JsonProperty("on-show")]
public Animation OnShowAnimation
{
get { return onshow; }
set { onshow = value; }
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class LineDot:LineBase
{
public LineDot()
{
this.DotStyleType.Type = DotType.DOT;
}
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class LineDotValue
{
private double? val;
private string tip;
private string color;
private int? sides;
private int? rotation;
private string type;
private bool? isHollow;
private int? dotsize;
public LineDotValue()
{ }
public LineDotValue(double val)
{
this.val = val;
}
public LineDotValue(double val, string tip, string color)
{
this.val = val;
this.tip = tip;
this.color = color;
}
public LineDotValue(double val, string color)
{
this.val = val;
this.color = color;
}
[JsonProperty("value")]
public double? Value
{
get { return val; }
set { val = value; }
}
[JsonProperty("tip")]
public string Tip
{
get { return tip; }
set { tip = value; }
}
[JsonProperty("colour")]
public string Color
{
get { return color; }
set { color = value; }
}
[JsonProperty("sides")]
public int? Sides
{
get { return sides; }
set { sides = value; }
}
[JsonProperty("rotation")]
public int? Rotation
{
get { return rotation; }
set { rotation = value; }
}
[JsonProperty("type")]
public string DotType
{
get { return type; }
set { type = value; }
}
[JsonProperty("hollow")]
public bool? IsHollow
{
get { return isHollow; }
set { isHollow = value; }
}
[JsonProperty("dot-size")]
public int? DotSize
{
get { return dotsize; }
set { dotsize = value; }
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class LineHollow:LineBase
{
public LineHollow()
{
//this.ChartType = "line_hollow";
this.DotStyleType.IsHollow = true;
this.DotStyleType.Type = DotType.HOLLOW_DOT;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class LineScatter:Scatter
{
public LineScatter()
{
this.ChartType = "scatter_line";
this.DotStyleType.Type = DotType.SOLID_DOT;
}
}
}

View File

@@ -0,0 +1,174 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using JsonFx.Json;
using OpenFlashChart;
namespace OpenFlashChart
{
public class OpenFlashChart
{
private Title title;
private IList<ChartBase> elements;
private XAxis x_axis;
private YAxis y_axis;
private YAxis y_axis_right;
private Legend x_legend;
private Legend y_legend;
private Legend y2_legend;
private string bgcolor;
private RadarAxis radar_axis;
private ToolTip tooltip;
private int? num_decimals;
private bool? is_fixed_num_decimals_forced;
private bool? is_decimal_separator_comma;
private bool? is_thousand_separator_disabled;
public OpenFlashChart()
{
title = new Title("Chart Title");
Elements = new List<ChartBase>();
//x_axis = new XAxis();
//y_axis= new YAxis();
//y_axis_right = new YAxis();
}
[JsonProperty("title")]
public Title Title
{
set { this.title = value; }
get { return this.title; }
}
[JsonProperty("x_axis")]
public XAxis X_Axis
{
get
{
if(x_axis==null)
x_axis= new XAxis();
return this.x_axis;
}
set{ this.x_axis = value;}
}
[JsonProperty("y_axis")]
public YAxis Y_Axis
{
get
{
if(y_axis==null)
y_axis= new YAxis();
return this.y_axis;
}
set { this.y_axis = value; }
}
[JsonProperty("y_axis_right")]
public YAxis Y_Axis_Right
{
get
{
return y_axis_right;
}
set { y_axis_right = value; }
}
[JsonProperty("elements")]
public IList<ChartBase> Elements
{
get { return elements; }
set { elements = value; }
}
public void AddElement(ChartBase chart)
{
this.elements.Add(chart);
//Y_Axis.SetRange(chart.GetMinValue(), chart.GetMaxValue());
// X_Axis.SetRange(0,chart.GetValueCount());
X_Axis.Steps = 1;
}
[JsonProperty("x_legend")]
public Legend X_Legend
{
get { return x_legend; }
set { x_legend = value; }
}
[JsonProperty("y_legend")]
public Legend Y_Legend
{
get { return y_legend; }
set { y_legend = value; }
}
[JsonProperty("y2_legend")]
public Legend Y_RightLegend
{
get { return y2_legend; }
set { y2_legend = value; }
}
[JsonProperty("bg_colour")]
public string Bgcolor
{
get { return bgcolor; }
set { bgcolor = value; }
}
[JsonProperty("tooltip")]
public ToolTip Tooltip
{
get { return tooltip; }
set { tooltip = value; }
}
[JsonProperty("radar_axis")]
public RadarAxis Radar_Axis
{
get
{
return this.radar_axis;
}
set { this.radar_axis = value; }
}
[JsonProperty("num_decimals")]
public int? NumDecimals
{
get { return num_decimals; }
set { num_decimals = value; }
}
[JsonProperty("is_fixed_num_decimals_forced")]
public bool? IsFixedNumDecimalsForced
{
get { return is_fixed_num_decimals_forced; }
set { is_fixed_num_decimals_forced = value; }
}
[JsonProperty("is_decimal_separator_comma")]
public bool? IsDecimalSeparatorComma
{
get { return is_decimal_separator_comma; }
set { is_decimal_separator_comma = value; }
}
[JsonProperty("is_thousand_separator_disabled")]
public bool? IsThousandSeparatorDisabled
{
get { return is_thousand_separator_disabled; }
set { is_thousand_separator_disabled = value; }
}
public override string ToString()
{
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
using (JsonWriter writer = new JsonWriter(sw))
{
writer.SkipNullValue = true;
writer.Write(this);
}
return sw.ToString();
}
public string ToPrettyString()
{
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
using (JsonWriter writer = new JsonWriter(sw))
{
writer.SkipNullValue = true;
writer.PrettyPrint = true;
writer.Write(this);
}
return sw.ToString();
}
}
}

View File

@@ -0,0 +1,231 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.Caching;
using System.Web.UI;
namespace OpenFlashChart
{
[Designer(typeof(ChartControlDesigner)), Description("Chart control for open flash chart"), ToolboxData("<{0}:OpenFlashChartControl runat=\"server\" ></{0}:OpenFlashChartControl>")]
public class OpenFlashChartControl : Control
{
private string width;
private string height;
private string externalSWFfile;
private string externalSWFObjectFile;
private string loadingmsg;
private OpenFlashChart chart;
private string chart_json;
private bool _enableCache;
/// <summary>
/// Used to hold internal chart
/// </summary>
public OpenFlashChart Chart
{
get
{
return chart;
}
set
{
chart = value;
chart_json = value.ToString();
ViewState["chart_json"] = chart_json;
}
}
private string ChartJson
{
get
{
if (ViewState["chart_json"] != null)
return ViewState["chart_json"].ToString();
return chart_json;
}
}
private string datafile;
[DefaultValue("600px")]
[Category("Appearance")]
[PersistenceMode(PersistenceMode.Attribute)]
public string Width
{
get
{
width = "600px";
if (this.ViewState["width"] != null)
{
width = this.ViewState["width"].ToString();
}
return width;
}
set
{
if (!value.EndsWith("%") && !value.EndsWith("px"))
value = value + "px";
this.ViewState["width"] = value;
width = value;
}
}
[DefaultValue("300px")]
[Category("Appearance")]
[PersistenceMode(PersistenceMode.Attribute)]
public string Height
{
get
{
height = "300px";
if (this.ViewState["height"] != null)
{
height = this.ViewState["height"].ToString();
}
return height;
}
set
{
if (!value.EndsWith("%") && !value.EndsWith("px"))
value = value + "px";
this.ViewState["height"] = value;
height = value;
}
}
[Category("Appearance")]
[PersistenceMode(PersistenceMode.Attribute)]
public string ExternalSWFfile
{
get
{
if (this.ViewState["externalswffile"] != null)
{
externalSWFfile = this.ViewState["externalswffile"].ToString();
}
if (!string.IsNullOrEmpty(externalSWFfile))
{
if (externalSWFfile.StartsWith("~"))
{
externalSWFfile = this.ResolveUrl(externalSWFfile);
}
}
return externalSWFfile;
}
set
{
this.ViewState["externalswffile"] = value.Trim();
externalSWFfile = value.Trim();
}
}
[Category("Appearance")]
[PersistenceMode(PersistenceMode.Attribute)]
public string ExternalSWFObjectFile
{
get
{
if (this.ViewState["externalswfobjectfile"] != null)
{
externalSWFObjectFile = this.ViewState["externalswfobjectfile"].ToString();
}
if (!string.IsNullOrEmpty(externalSWFObjectFile))
{
if (externalSWFObjectFile.StartsWith("~"))
{
externalSWFObjectFile = this.ResolveUrl(externalSWFObjectFile);
}
}
return externalSWFObjectFile;
}
set
{
this.ViewState["externalswfobjectfile"] = value.Trim();
externalSWFObjectFile = value.Trim();
}
}
public string DataFile
{
get
{
if (this.ViewState["datafile"] != null)
{
datafile = this.ViewState["datafile"].ToString();
}
if (!string.IsNullOrEmpty(datafile))
{
if (datafile.StartsWith("~"))
{
datafile = this.ResolveUrl(datafile);
}
}
return datafile;
}
set
{
this.ViewState["datafile"] = value;
datafile = value;
}
}
public string LoadingMsg
{
get { return loadingmsg; }
set { loadingmsg = value; }
}
public bool EnableCache
{
get { return _enableCache; }
set { _enableCache = value; }
}
protected override void OnInit(EventArgs e)
{
const string key = "swfobject";
string swfobjectfile = ExternalSWFObjectFile;
if (string.IsNullOrEmpty(ExternalSWFObjectFile))
swfobjectfile = Page.ClientScript.GetWebResourceUrl(this.GetType(), "OpenFlashChart.swfobject.js");
if (!this.Page.ClientScript.IsClientScriptBlockRegistered(key))
{
this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), key, "<script type=\"text/javascript\" src=\"" + swfobjectfile + "\"></script>");
}
base.OnInit(e);
}
public override void RenderControl(HtmlTextWriter writer)
{
StringBuilder builder = new StringBuilder();
if (string.IsNullOrEmpty(ExternalSWFfile))
ExternalSWFfile = Page.ClientScript.GetWebResourceUrl(this.GetType(), "OpenFlashChart.open-flash-chart.swf");
builder.AppendFormat("<div id=\"{0}\">", this.ClientID);
builder.AppendLine("</div>");
builder.AppendLine("<script type=\"text/javascript\">");
builder.AppendFormat("swfobject.embedSWF(\"{0}\", \"{1}\", \"{2}\", \"{3}\",\"9.0.0\", \"expressInstall.swf\",",
ExternalSWFfile, this.ClientID, Width, Height);
builder.Append("{\"data-file\":\"");
//if both chart,datafile exists ,chart win.
if (ChartJson != null)
{
if (!EnableCache)
Page.Cache.Remove(this.ClientID);
Page.Cache.Add(this.ClientID, ChartJson, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0),
CacheItemPriority.Normal, null);
builder.Append("ofc_handler.aspx?chartjson=" + this.ClientID + "%26ec=" + (EnableCache ? "1" : "0"));
}
else
builder.Append(HttpUtility.UrlEncode(DataFile));
builder.Append("\"");
if (!string.IsNullOrEmpty(loadingmsg))
{
builder.AppendFormat(",\"loading\":\"{0}\"", loadingmsg);
}
builder.Append("});");
builder.AppendLine("</script>");
writer.Write(builder.ToString());
base.RenderControl(writer);
}
}
}

View File

@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class PieValue
{
private double val;
private string text;
private string click;
public PieValue(double val)
{
this.val = val;
}
public static implicit operator PieValue(double val)
{
return new PieValue(val,"");
}
public PieValue(double val, string text)
{
this.val = val;
this.Text = text;
}
[JsonProperty("value")]
public double Value
{
get { return val; }
set { val = value; }
}
[JsonProperty("label")]
public string Text
{
get { return text; }
set { text = value; }
}
[JsonProperty("on-click")]
public string Click
{
get { return click; }
set { click = value; }
}
}
public class Pie : Chart<PieValue>
{
private int border;
private IEnumerable<String> colours;
private double alpha;
private PieAnimationSeries animate;
private double start_angle;
private bool? gradientfill;
private bool? nolabels;
public Pie()
{
this.ChartType = "pie";
this.border = 2;
this.colours = new string[] { "#d01f3c", "#356aa0", "#C79810" };
this.alpha = 0.6;
//this.animate = true;
//gradientfill = true;
}
[JsonProperty("colours")]
public IEnumerable<string> Colours
{
get { return this.colours; }
set
{
this.colours = value;
}
}
[JsonProperty("border")]
public int Border
{
get { return border; }
set { border = value; }
}
[JsonProperty("alpha")]
public double Alpha
{
get { return alpha; }
set
{
if (value < 0)
alpha = 0;
else if ((value >= 0) && (value <= 1))
alpha = value;
else if ((value > 1)&&(value<=100))
alpha = value/100;
else
alpha = 1.0;
}
}
[JsonProperty("animate")]
public PieAnimationSeries Animate
{
get { return animate; }
set { animate = value; }
}
[JsonProperty("start-angle")]
public double StartAngle
{
get { return start_angle; }
set { start_angle = value; }
}
[JsonProperty("gradient-fill")]
public bool? GradientFillMode
{
get { return gradientfill; }
set { gradientfill = value; }
}
[JsonProperty("no-labels")]
public bool? NoLabels
{
get { return nolabels; }
set { nolabels = value; }
}
}
}

View File

@@ -0,0 +1,40 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过下列属性集
// 控制。更改这些属性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("OpenFlashChart")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenFlashChart")]
[assembly: AssemblyCopyright("版权所有 (C) 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 属性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("8203eccb-dc12-4282-9531-a2c47f2120d1")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: System.Web.UI.WebResource("OpenFlashChart.swfobject.js", "text/javascript")]
[assembly: System.Web.UI.WebResource("OpenFlashChart.open-flash-chart.swf", "application/x-shockwave-flash")]

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class RadarAxis:XAxis
{
private XAxisLabels spokelabels;
public RadarAxis(double max)
{
base.Max = max;
}
public RadarAxis()
{
}
[JsonProperty("spoke-labels")]
public XAxisLabels SpokeLabels
{
get { return spokelabels; }
set { spokelabels = value; }
}
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class ScatterValue
{
private double x;
private double y;
private int? dotsize;
private string dottype;
private string onclick;
public ScatterValue(double x, double y)
{
this.x = x;
this.y = y;
}
public ScatterValue(double x, double y, int dotsize)
{
this.x = x;
this.y = y;
if (dotsize > 0)
this.dotsize = dotsize;
//this.dottype = DotType.HOLLOW_DOT;
}
[JsonProperty("x")]
public double X
{
get{return x;}
set{this.x=value;}
}
[JsonProperty("y")]
public double Y
{
get{return y;}
set{this.y=value;}
}
[JsonProperty("dot-size")]
public int DotSize
{
get{
if (dotsize == null)
return -1;
return dotsize.Value;}
set{this.dotsize=value;}
}
[JsonProperty("type")]
public string DotType
{
get { return dottype; }
set { dottype = value; }
}
[JsonProperty("on-click")]
public string OnClick
{
get { return onclick; }
set { onclick = value; }
}
}
public class Scatter:Chart<ScatterValue>
{
private int? dotsize;
public Scatter()
{
this.ChartType = "scatter";
}
public Scatter(string color,int? dotsize)
{
this.ChartType = "scatter";
this.Colour = color;
this.dotsize = dotsize;
DotStyleType.Type = DotType.SOLID_DOT;
}
[JsonProperty("dot-size")]
public int? DotSize
{
get { return this.dotsize; }
set { this.dotsize = value; }
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class Title : ChartElement
{
public Title(string text)
{
base.Text = text;
}
}
}

View File

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
//{
// shadow: true,
// rounded: 1,
// stroke: 2,
// colour: '#808080',
// background: '#f0f0f0',
// title: "color: #0000F0; font-weight: bold; font-size: 12;",
// body: "color: #000000; font-weight: normal; font-size: 12;",
// mouse: Tooltip.CLOSEST,
// text: "_default"
//}
public class ToolTip
{
string text="_default";
private bool shadow=true ;
private int rounded=1;
private int stroke = 2;
private string colour;//= "#808080";
private string background;//= "#f0f0f0";
private string titlestyle;// = "color: #0000F0; font-weight: bold; font-size: 12;";
private string bodystyle;//= "color: #000000; font-weight: normal; font-size: 12;";
private ToolTipStyle mousestyle;//= ToolTipStyle.CLOSEST;
public int mouse;
public ToolTip(string text)
{
this.text = text;
}
[JsonProperty("text")]
public String Text
{
get { return text; }
set { text = value; }
}
[JsonProperty("shadow")]
public bool Shadow
{
get { return shadow; }
set { shadow = value; }
}
[JsonProperty("rounded")]
public int Rounded
{
get { return rounded; }
set { rounded = value; }
}
[JsonProperty("stroke")]
public int Stroke
{
get { return stroke; }
set { stroke = value; }
}
[JsonProperty("colour")]
public string Colour
{
get { return colour; }
set { colour = value; }
}
[JsonProperty("background")]
public string BackgroundColor
{
get { return background; }
set { background = value; }
}
[JsonProperty("title")]
public string TitleStyle
{
get { return titlestyle; }
set { titlestyle = value; }
}
[JsonProperty("body")]
public string BodyStyle
{
get { return bodystyle; }
set { bodystyle = value; }
}
[JsonIgnore]
public ToolTipStyle MouseStyle
{
get { return mousestyle; }
set { mousestyle = value;
mouse = (int) value;
}
}
public void SetProximity()
{
mouse = 1;
}
public override string ToString()
{
return this.text;
}
}
public enum ToolTipStyle
{
CLOSEST=0,
FOLLOW=1,
NORMAL=2
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
namespace OpenFlashChart.WebHandler
{
public class ofcHandler: IHttpHandler
{
/// <summary>
/// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler" /> interface.
/// </summary>
/// <param name="context">An <see cref="T:System.Web.HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. </param>
public void ProcessRequest(HttpContext context)
{
using (TextWriter writer = new HtmlTextWriter(context.Response.Output))
{
string chartID = context.Request.QueryString["chartjson"];
if (chartID == null)
return;
string chartjson = (string)context.Cache[chartID];
context.Response.Clear();
context.Response.CacheControl = "no-cache";
writer.Write(chartjson);
}
}
/// <summary>
/// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler" /> instance.
/// </summary>
/// <returns>
/// true if the <see cref="T:System.Web.IHttpHandler" /> instance is reusable; otherwise, false.
/// </returns>
public bool IsReusable
{
get { return true;}
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class XAxis:Axis
{
private string tick_height;
private XAxisLabels labels;
[JsonProperty("tick-height")]
public string TickHeight
{
get { return tick_height; }
set { tick_height = value; }
}
[JsonProperty("labels")]
public XAxisLabels Labels
{
get
{
if (this.labels == null)
this.labels = new XAxisLabels();
return this.labels;
}
set { this.labels = value; }
}
public void SetLabels(IList<string> labelsvalue)
{
Labels.SetLabels(labelsvalue);
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class XAxisLabels:AxisLabels
{
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class YAxis:Axis
{
private int tick_length;
private YAxisLabels labels;
[JsonProperty("tick-length")]
public int TickLength
{
get { return tick_length; }
set { tick_length = value; }
}
public void SetRange(double min, double max, int step)
{
base.Max = max;
base.Min = min;
base.Steps = step;
}
[JsonProperty("labels")]
public YAxisLabels Labels
{
get
{
if (this.labels == null)
this.labels = new YAxisLabels();
return this.labels;
}
set { this.labels = value; }
}
public void SetLabels(IList<string> labelsvalue)
{
Labels.SetLabels(labelsvalue);
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace OpenFlashChart
{
public class YAxisLabel:AxisLabel
{
private int? y;
[JsonProperty("y")]
public int? Y
{
get { return y; }
set { y = value; }
}
public YAxisLabel(string text,int ypos):base(text)
{
y = ypos;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class YAxisLabels:AxisLabels
{
public override void SetLabels(IList<string> labelsvalue)
{
int pos = 0;
if (labels == null)
labels = new List<object>();
foreach (string s in labelsvalue)
{
labels.Add(s);
pos++;
}
}
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenFlashChart
{
public class YAxisRight:YAxis
{
}
}

File diff suppressed because one or more lines are too long