binqing Posted February 27, 2008 Report Share Posted February 27, 2008 Hi, Frank this is the continuation of the previous question in post: http://community.softwarefx.com/forums/p/8774/20477.aspx#20477 Frank,I did try again, and it seems I do need some extra help for this. I am still using ChartFX 5.1 - the oldest version. I did not find any property, like Near or Far, to realign the text of the title of these two constant lines. So it this property available in ChartFX 5.1 or not.The following is the code for plotting the graph. I put all my questions in the inline comments, making it easier for you to read. After the data is plotted, I see the zoom tool only affect the data on Axis_Y, but the data on Axis_Y2 do not change at all. How can I make the data on Axis_Y2 also have conparative changes? ----------------------------------------------------------------------- private void DisplayChart(Array selectedDam) {string damName = ""; double crest = 0.0;double spillway = 0.0; double[,] outFlow;damName = "Adobe Dam"; crest = 1405.5 ;spillway = 1400.5; outFlow = GetOutFlow(selectedDam); InitChart(damName); SetAxis(outFlow, crest); DrawOutFlow(outFlow, crest, spillway); } private void InitChart(string damName) { string chartTitle = ""; chartTitle = "The Predicted Outflow of " + damName; //Initialization of general setting this.chartOutFlow.set_Title(ChartfxLib.CfxTitle.CHART_TOPTIT, chartTitle);//Initialization of the ConstantLine setting this.chartOutFlow.OpenDataEx(ChartfxLib.CfxCod.COD_CONSTANTS, 2, 0); //Dam Elevaltion//here I intend to plot the crest on AXIS_Y2 this.chartOutFlow.ConstantLine[0].Axis = ChartfxLib.CfxAxisIndex.AXIS_Y2; this.chartOutFlow.ConstantLine[0].Label = "Dam Elelvation"; this.chartOutFlow.ConstantLine[0].LineColor = (uint)ColorTranslator.ToOle(Color.Brown); this.chartOutFlow.ConstantLine[0].LineStyle = ChartfxLib.CfxLineStyle.CHART_SOLID; this.chartOutFlow.ConstantLine[0].LineWidth = 1; //Spillway Elevation//Here I intend to plot the spillway on AXIS_Y2 this.chartOutFlow.ConstantLine[1].Axis = ChartfxLib.CfxAxisIndex.AXIS_Y2; this.chartOutFlow.ConstantLine[1].Label = "Spillway Elevation"; this.chartOutFlow.ConstantLine[1].LineColor = (uint)ColorTranslator.ToOle(Color.DarkSlateBlue); this.chartOutFlow.ConstantLine[1].LineStyle = ChartfxLib.CfxLineStyle.CHART_SOLID; this.chartOutFlow.ConstantLine[1].LineWidth = 1;this.chartOutFlow.CloseData(ChartfxLib.CfxCod.COD_CONSTANTS); } private void SetAxis(double[,] outFlow, double crest) { int length = 0; double AxisYMin = 0.0; double AxisYMax = 0.0; double AxisY2Min = 0.0; double AxisY2Max = 0.0; double flowMax = 0.0; //this is used to set the max on AXIS_Ydouble stageMax = 0.0; DateTime begTime; DateTime endTime; length = outFlow.GetLength(0); flowMax = 1002; stageMax = 1402.5; //the Axis X is set to the starting and ending time of the selected time period. begTime = new DateTime(2008, 1, 27, 0, 0, 0); endTime = new DateTime(2008, 1, 29, 0, 0, 0); //the Axis Y is set to be the maximum out flow, and the Axis Y2 is set to be the elevation of the damAxisYMin = 0.0; AxisYMax = flowMax + 10.0; AxisY2Min = 1000.0; AxisY2Max = crest + 200.0; //the crest of the elevation of the dam, this is used to set the max on AXIS_Y2 //Initialization of the Axis object setting this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Title = "Time Interval (minute)"; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Format = ChartfxLib.CfxFormat.AF_TIME; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].AutoScale = true; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Min = begTime.ToOADate(); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Max = endTime.ToOADate(); //this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].STEP = 5; //How can i set the step and minor step for time serial on AXIS_X?//this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].MinorStep = 1; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Decimals = 0; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].TextColor = (uint)ColorTranslator.ToOle(Color.Blue); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].Grid = false; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].GridWidth = 1;this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].LabelAngle = 45; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Title = "Predicted Outflow (cfs)"; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Format = ChartfxLib.CfxFormat.AF_NUMBER; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].AutoScale = true; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Min = AxisYMin; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Max = AxisYMax; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Decimals = 1; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].TextColor = (uint)ColorTranslator.ToOle(Color.Blue); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].Grid = true;this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].GridWidth = 1; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].Title = "Crest & Spillway Elevation (ft)"; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].Format = ChartfxLib.CfxFormat.AF_NUMBER; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].AutoScale = true; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].Min = AxisY2Min; //I assign the min and max for the AXIS_Y2 here, but it does not affect! this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].Max = AxisY2Max; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].Decimals = 0; this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].TextColor = (uint)ColorTranslator.ToOle(Color.Blue);this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].GridWidth = 1; this.chartOutFlow.OpenDataEx(ChartfxLib.CfxCod.COD_COLORS, 4, 0); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].GridColor = (uint)ColorTranslator.ToOle(Color.Blue); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y].GridColor = (uint)ColorTranslator.ToOle(Color.Blue); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].GridColor = (uint)ColorTranslator.ToOle(Color.Blue);this.chartOutFlow.CloseData(ChartfxLib.CfxCod.COD_COLORS); } private void DrawOutFlow(double[,] outFlow, double crest, double spillway) { int count = 0; int nseries = 0;string timeLabel = ""; count = outFlow.GetLength(0);nseries = this.chartOutFlow.NSeries; //plot the crest and spillway elevations this.chartOutFlow.OpenDataEx(ChartfxLib.CfxCod.COD_CONSTANTS, 2, 0); this.chartOutFlow.ConstantLine[0].Value = crest; this.chartOutFlow.ConstantLine[1].Value = spillway; this.chartOutFlow.CloseData(ChartfxLib.CfxCod.COD_CONSTANTS); //plot the outflow datathis.chartOutFlow.OpenDataEx(ChartfxLib.CfxCod.COD_XVALUES, nseries, count); this.chartOutFlow.OpenDataEx(ChartfxLib.CfxCod.COD_VALUES, nseries, count);for (int i=0; i<count; i++) { //set the Axis X labelstimeLabel = outFlow[i, 2].ToString() + ":" + outFlow[i, 3].ToString(); this.chartOutFlow.Axis[ChartfxLib.CfxAxisIndex.AXIS_X].set_Label(i, timeLabel); //set the outflow values this.chartOutFlow.Series[0].set_Xvalue(i, i+1); this.chartOutFlow.Series[0].set_Yvalue(i, outFlow[i, 5]); //set the stage values//If I comment out the following four lines of code, that is, do not plot the stage values //the min and max of the Axis_Y2 will show right, that is, 1000 - 1400 or similar. this.chartOutFlow.Series[1].set_Xvalue(i, i+1);// I intend to plot this data in AXIS_Y2 this.chartOutFlow.Series[1].YAxis = ChartfxLib.CfxAxisIndex.AXIS_Y2;this.chartOutFlow.Series[1].set_Yvalue(i, outFlow[i, 7]); } this.chartOutFlow.CloseData(ChartfxLib.CfxCod.COD_XVALUES); this.chartOutFlow.CloseData(ChartfxLib.CfxCod.COD_VALUES);this.chartOutFlow.RecalcScale(); } Quote Link to comment Share on other sites More sharing options...
binqing Posted February 28, 2008 Author Report Share Posted February 28, 2008 Frank I finally found the culprit! By default, ForceZero property is set to be true for all the Y axis, so if you want to set the min of the axis_Y to be a non-zero value you need to specifically reset the ForceZero property to be false and then the value you want it to be can show up. For example, this .myChart.Axis[ChartfxLib.CfxAxisIndex.AXIS_Y2].ForceZero = false;But my question about Zoom and Step is still there. If I want to plot time on Axis_X at 15 minute interval, how should I set the Step and MinorStep? I plot two groups of data on Axis_Y and Axis_Y2 separately. When I use the zoom tool, it only affect the data in Axis_Y, and the data on Axis_Y2 remain unaffected. How can I handle this? Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.