Home > Net >  C # chart table design
C # chart table design

Time:04-15

To achieve below effect, mainly is the Y axis of the format, the x axis as the time, in the Y axis x to the normal range, such as 20, such as volatility is 0.5, sd is 20.5 1, 2 sd is 21, so on,
The current problem, integral is not much, hope to give some directions;
1, Y axis itself for various values, how to present the effect of the
2, the X axis is date, on this, how to present the effect;



Now to reach the effect of:







The background code:
 private void LoadForm () 
{

Chart1. Series. The Clear ();

ChartHelper. AddSeries (chart1, "Line chart", SeriesChartType Line, Color, Red, the Color, Red);
ChartHelper. SetTitle (chart1 "line chart", the new Font (" Microsoft Black ", 12), Docking. The Bottom, Color. Black);
ChartHelper. SetStyle (chart1, Color Transparent, Color. White);
ChartHelper. SetLegend (chart1, Docking. Top, StringAlignment Center, Color, Transparent, Color, Black);
ChartHelper. SetXY move (chart1, "date", "value", StringAlignment. Far, Color, Black, Color, Black, AxisArrowStyle. None, 1, 2);
//grid this is
ChartHelper. SetMajorGrid (chart1, Color. Gray, 1, 0.5, ChartDashStyle. The Dash, ChartDashStyle. NotSet);

//marked points set
Chart1. Series [0]. MarkerSize=8;//marker point size
Chart1. Series [0]. MarkerStyle=MarkerStyle. Circle;//markers in type
//hint
Chart1. Series [0]. The ToolTip="line: # SER \ nx: # VALX \ ny: # VALY";

//Y axis. The maximum and the minimum
Chart1. ChartAreas [0]. AxisY. Maximum=22;
Chart1. ChartAreas [0]. AxisY. Minimum=18;
Chart1. ChartAreas [0]. AxisY. ArrowStyle=AxisArrowStyle. None;//arrow style
//the value binding
"Line chart" chart1. Series []. Points. DataBind (listDemo. AsEnumerable (), "StartDate", "ValueInt", "");

//set the line
Double Max=20;
StripLine stripMax=new StripLine ();
//stripMax. Text=the string. Format (" biggest:} {0: F, "Max);//display text
StripMax. The Font=new Font (" tahoma ", 20);//text font
StripMax. BackColor=Color. FromArgb (208, 109, 106);//background color
StripMax. Interval=0;//interval
StripMax. IntervalOffset=Max;//offset
StripMax. StripWidth=0.01;//line width
//stripMax ForeColor=Color. White;//the foreground
//stripMax TextAlignment=StringAlignment. Near;//text alignment
//

Chart1. ChartAreas [0]. AxisY. StripLines. Add (stripMax);//added to the ChartAreas
StripMax=new StripLine ();
StripMax. IntervalOffset=Max + 0.5;
Chart1. ChartAreas [0]. AxisY. StripLines. Add (stripMax);//added to the ChartAreas


}
List ListDemo=new List (a);
Private void InitData ()
{
List Y=new List () {19, 18.5, 19.5, 20, 20.5, 21, 21.5};
The Random Random=new Random ();
For (int I=0; I & lt; 12. I++)
{
The Demo Demo=new Demo ();
Int index=random. Next (y.C mount ());
The demo. ValueInt=y [index];
Demo. StartDate=DateTime. Now. AddDays (I);
If (I==3)
{
The demo. ValueInt=1;

}
ListDemo. Add (demo);
}

//bind data
}

  •  Tags:  
  • C#
  • Related