binqing Posted February 25, 2008 Report Posted February 25, 2008 Hi, all I am trying to plot few group of data on axis Y and secondary axis Y with time as axis X. The data to be plotted on axis Y are ranging from 0 - 1000, but the data to be plotted on axis Y2 are ranging from 1000 - 1500. At the same time I want to set two constant lines, and their values are around 1000, but the difference between them is very small. For example, the first constant line is 1335, and the second is 1340. Here is my questions: Can I set the max and min of axis Y and axis Y2 separately? In the code I set them separately, for example, axis Y ranges from 0 - 1200, and axis from 1000 - 1500. But after I run it, axis Y2 still shows the range from 0 - 15000. When the axis Y2 ranges from 0 - 1500, these two constant lines are almost merged together, and very hard to see them unless I zoomed great extends. The titles of these two constant lines are overlapped with each other. Is there any way to shift them and let them not overlap? a question that is a little bit off this topic: When I try to insert an image, there is a text box called "Image URL". What kind of format input is expected? Like http://www.fakeURL.com/image/image1.jpg or "C:\FloodExercise\Adobe\image1.jpg". I tried several times to attach a screenshot, but in vain. It would be so much appreciated if any one can give a reply, and some sample code would be better.
Frank Posted February 26, 2008 Report Posted February 26, 2008 > Can I set the max and min of axis Y and axis Y2 separately? In ... Definitely. What could be happening is that you are not assigning your series to each axis BEFORE setting the data to the chart. You may want to try this with a simple chart and if you continue to have problems post the code you are using and will gladly point you in the right direction. > When the axis Y2 ranges from 0 - 1500, these two constant lines are almost merged together ... There isn't really much that can be done here. You can align the text of each one to a different side (Near and Far) to avoid overlapping of the text. > a question that is a little bit off this topic: When I try to insert an image ... You are trying to insert an image where. What API/UI are you referring to here?
binqing Posted February 26, 2008 Author Report Posted February 26, 2008 Frank, Thanks so much for your such quick reply. For the first two items I can not test now. But I will definitely try it in office tomorrow, and post the related code if I do need some more help. I am going to elaborate in a little bit detail of what I mean about inserting an image: When you are writing a new post, there is a group of buttons just above the text area. There are such buttons as B for bold, I for italic, U for underline, list bullet, and so on. Among them there is a button on which there is a little tree image. when you hover the mouse over it, the intelli-text shows something like "Insert/edit image". So I am assuming this should be the button to insert an image. After you click this button there pops up another window. Inside this newly popped-up window there is a text box called "Image URL". My question is: What format of input is expected for this text box? like http://www.fakesite.com/images/image1.jpg or "C:\Dam\image1.jgp". I have tried the second option, it doesnot work. If the first option is right, it will be unconvenient for users to use. We have a lot of restriction to access such site. Hope this clarifies my previous post. Thanks again.
binqing Posted February 26, 2008 Author Report Posted February 26, 2008 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. 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 settingthis.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 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(); }
binqing Posted February 27, 2008 Author Report Posted February 27, 2008 Frank In the following module, if I donot plot the stage values, the min and max of Asix_Y2 shows correctly. Does this help to find the problem? Thanks 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 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(); }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.