Author |
Topic  |
|
sherry
China
2 Posts |
Posted - 05 Jul 2011 : 20:50:47
|
I want to add a button to control the legend visible and invisible, is there a control for adding this to a chart view ? And also i want to locate this button to the left-bottom position. |
|
quinncurtis
1164 Posts |
Posted - 05 Jul 2011 : 21:34:44
|
Our ChartView window is derived from the .Net UserControl class, and as such you can place standard .Net controls in it. See our example program MultipleAxes.MultiAxes chart, and all of the example in FormControlExamples. For a single button it would looks something like:
private System.Windows.Forms.Button button1; . . . this.button1 = new System.Windows.Forms.Button(); this.button1.Location = new System.Drawing.Point(448, 480); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(96, 40); this.button1.Text = "25"; this.button1.Click += new System.EventHandler(this.button1_Click);
this.Controls.Add(button1);
You do have to specify the exact size, and the exact position of the button in device coordinates.
|
 |
|
sherry
China
2 Posts |
Posted - 06 Jul 2011 : 00:58:30
|
Thanks, another problem is how to locate the button to the left-bottom position dynamically in Cartesian Coordinates, see the code:
var coordinates = new CartesianCoordinates(ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE); Coordinates.SetGraphBorderInsets(0.3, 0.05, 0.2, 0.2);
There are multiple axes like MultipleAxes sample, how to locate the button below the mutiple axes no matter what the size of the chartview is. |
 |
|
quinncurtis
1164 Posts |
Posted - 06 Jul 2011 : 08:19:39
|
Unfortunately, the buttons are just the standard .Net variety, and do not know anything about the coordinate systems of our charts, and must be placed using device coordinates. As in all .Net forms, placement of controls is absolute. They are not going to reposition themselves when the parent resizes. In general, if you are going to add .Net Buttons and other controls to our ChartView windows, we recommend that you make the charts a fixed size, not resizeable, so the controls will maintain the same relative position in the chart.
We overcame this by adding some additional classes to our QCRTGraph (http://www.quinn-curtis.com/QCRTGraphProdPage.htm) product. There, we have subclasses of the Button and Scrollbar controls which can be placed in a ChartView windows using our coordinate systems. When a graph resizes, the controls reposition and resize in proportion to the size of the parent. You can download a demo for that product here: http://quinn-curtis.com/DownloadSoftware/QCRTGraphDemoR2.zip. |
 |
|
|
Topic  |
|
|
|