I am displaying Column Chart based on dynamic data. I want to set the Chart width 100%. But MS chart does not allow to set it. Please can you suggest me how to resolve this issue. Because I want to set Bar width same for all series.
Set your chart width to som larger number to allow clear rendering - say 1920px
Then add this bit of javascript to your page
setTimeout("document.getElementById('<%=Chart1.ClientID %>').style.width = '95%'", 500);
Related
I would like to ask you for one stuff. I have Chart, which could be resized. In init state everything looks ok. But when user resize chart, at axis X are ticks resized as well. But I need to stay in init state. I am looking for solution but I have not found.
Thanks in advance for your ideas.
Init
Resized
You can adjust size of MinorTickMark according to chart Height or chart Width.
Take a look at this project: https://www.codeproject.com/Tips/1036182/A-Powerful-Chart-Control
I am using the Microsoft Chart Control.
I am trying to adjust the height of the chart area programmatically. Depending on the rows. Because the Microsoft Chart control requires a height, which cannot be in percentages, nor Auto. Depending on the selected query, the chart can have 1 bar or it can have 100's. This is why I need to adjust the height because bigger data sets appear squished and not readable.
What I have tried is adding a counter heightCounter which is the number of bars on the chart.
int newHeight = (heightCounter * 10);
// Maximum height aloud on Chart Control
if (newHeight > 32767)
newHeight = 32767;
Chart1.Height = newHeight;
This sometimes works O.K. with smaller data sets
but when I have very large datasets the title looks very spaced out because the height is too large.
Is there a proper way to achieve this?
I think that the way you are approaching the problem is along the right lines, taking a count of the number of series' in the datasource in order to obtain a proportional height.
However, I would be inclined to declare the width of each bar as described here. This would give you more control than using a static multiplier such as the 10 you have.
I would also be inclined to set the height permanently as the calculated height, unless of course the minimum height is a desired feature.
Also, as a side note, isnt increasing by 10 for each quite significant? Have you tried halving that? If I remember rightly, the width of the bars will autmatically scale themselves (if not specifically declared by you).
I am using MS chart, basically a line chart.
I am also using label format to show numbers upto 2 decimal places using
chart2.ChartAreas[0].AxisY.LabelStyle.Format = "#,##0.00;(#,##0.00)";
and property IsStartedFromZero is set to false.
This works for most of the cases.
But if i plot using value (.1,.1,.09) or (.25,.25.22), it shows duplicate values in Y-axis scale. This happens due to formatting of label.
In excel,there is option of setting major unit under format axis option, charts are properly created in excel if Major unit is set to 0.01 (fixed)
how can this be set in microsoft chart, i want to create the same using MS chart.
Tried chart2.ChartAreas[0].AxisY.Interval = .01, but this doesn't works.
Any other suggestion to fix this.
How can I set the width of an asp:chart to be 100% the width of the page?
The chart width attribute does not like percentages.
Another solution would be to check the current resolution, how to get that from .net?
You can try using the Request.Browser.ScreenPixelsWidth property.
Hi I am using Ms chart control in winforms application for displaying values according to dates
I need to change the x-axis label values(Dates) direction horizantal to vertical
I have searched so many properties but i did not find any solution for this.
Any one help me on this problem
Many Thanks ....
As I understand your question - you are asking how to rotate the chart label to display vertically.
You can rotate the x-axis label as follows:
chart1.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
This assumes you have associated your series with the first chart area, which is the default without modification when using the Winforms designer.
The following images shows how the chart would look before the code above is applied, the second image shows how it appears after the code is applied.
Let me know if this is not what you are trying to do and I will post an updated answer.
Before rotation
After Rotation
Edit: Another answer added after my initial post mentions in certain situations it may be important to set chartArea1.AxisX.IsLabelAutoFit = false;
If you have not already done so, get the chart samples from microsoft:
http://archive.msdn.microsoft.com/mschart
Then check the section on Labels
Chart Features > Labels
To answer your question directly, set the angle in LabelStyle, and don't forget to disable autofit
chartArea1.AxisX.IsLabelAutoFit = false;
chartArea1.AxisX.LabelStyle.Angle = 90;