.NET Framework Developer Center >
.NET Development Forums
>
Chart Controls for .NET Framework
>
multiple chartareas problem
multiple chartareas problem
- I can't add more than 3 vertical chartares , is there a property i can bypass this limitation?
http://i41.tinypic.com/2zix4cy.gif
Answers
- There is no limitations on the number of chart areas. After the third chart area, chart will automatically arrange all chart areas in 2 columns. You can override this behavior by providing custom ChartArea.Position.
Alex.
http://blogs.msdn.com/alexgor- Marked As Answer byAlex GorevMSFT, OwnerTuesday, February 03, 2009 1:52 AM
All Replies
- There is no limitations on the number of chart areas. After the third chart area, chart will automatically arrange all chart areas in 2 columns. You can override this behavior by providing custom ChartArea.Position.
Alex.
http://blogs.msdn.com/alexgor- Marked As Answer byAlex GorevMSFT, OwnerTuesday, February 03, 2009 1:52 AM
- Alex,
my question is same only, but i don't want chartarea on 2nd column all chartareas on single column vertical full width with scrollbar.
i got scrollbar but in my case after writing 3 chartareas vertically it overwrites on first chart area. and could not see all chartarea.
can you help me resolve this problem ?
Hems - He already gave you the answer. You need to set the chartarea positions by hand. So for instance, four vertical graphs would each have height of 25%, the Y's would follow at 25% increments, and they would all be 100% wide from 0% of the X axis.
I believe Alex and I have done everything EXCEPT write the code for you.
Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now. - Hi
i have try doing so, by setting chartArea.Position.Auto = false;
and by custom assigning the position x, y it expects parameter in Float value (Elementposition) , and not by percentage, otherway around i calculated percentage and given the value as float to Y axis for height, like if i have 5 chartareas 100/5, increase by 20 to every Y axis, by doing this chartareas did not appear on chart control. and as chartareas X & Y is bound to 100 only is there a way to override the behaviour to increase the size?
if i increase the size of chart control it is not adding new chartarea, but it is streaching the existing chartareas, ultimate result expected is to get all chartareas vertically, irrespective the number of chartareas.
Hems - Try this example. The positioning works just fine.
Private Sub ExampleForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Init chart Chart1.ChartAreas.Clear() Chart1.Legends.Clear() Chart1.Series.Clear() Dim numberOfAreas As Integer = 7 'These are all percentages Dim posX, posY, width, height As Single For i As Integer = 0 To numberOfAreas - 1 'ChartArea dimensions posX = 0 posY = i * (100 / numberOfAreas) width = 65 height = (100 / numberOfAreas) 'Create a chartarea Chart1.ChartAreas.Add("AREA" & i) Chart1.ChartAreas("AREA" & i).Position = New ElementPosition(posX, posY, width, height) 'Create legend Chart1.Legends.Add("LEGEND" & i) Chart1.Legends("LEGEND" & i).DockedToChartArea = "AREA" & i Chart1.Legends("LEGEND" & i).IsDockedInsideChartArea = False 'Create a series Chart1.Series.Add("SERIES" & i) Chart1.Series("SERIES" & i).ChartArea = "AREA" & i Chart1.Series("SERIES" & i).Legend = "LEGEND" & i Chart1.Series("SERIES" & i).LegendText = String.Format("X={0:0.#} Y={1:0.#} W={2:0.#} H={3:0.#}", posX, posY, width, height) 'Add data to series Chart1.Series("SERIES" & i).Points.AddXY(1, 50) Chart1.Series("SERIES" & i).Points.AddXY(2, 25) Chart1.Series("SERIES" & i).Points.AddXY(3, 70) Chart1.Series("SERIES" & i).Points.AddXY(4, 20) Next End Sub
- Thanks sipla, i have try this, is there any limitations of having number of chartareas in single chart control on single column?, coz what happen is when i give 100 its giving all chartareas on vertical same column and if it crosses 100 it is not showing proper, for that what i have done is giving the fix height of chart control is 1000 and every time in loop when chartareas is added i am increasing the chart control's height by the height of chartarea, but still the chart control is not showing more than 100 chart.
Hems


