Fit as much on the x axis as possible in chart control - c#

I have a chart that has times on X axes. How can I remove the gaps in between the points on the X axes? I think that it might be called interval or scale or something but I'm not sure where in the properties I can find it.

I assume that you are using Microsoft Chart controls and you are trying to fit the "time" labels within the XAxis length.
You can set the LabeAutoFitStyle property of the ChartArea's XAxis as fitted for your requirement. See this MSDN link for different LabelAutoFitStyles.
chart1.ChartAreas[ChartName].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep45;
If you want to change the intervals and number of intervals used in display, use AxisX.Interval and AxisX.IntervalAutoMode property.

Related

C# Chart date type x axis is not hiding empty point

Basically my C# chart control has a datetime type x axis.
I am plotting 2 different time period, but do not want the empty points to even show up in the x axis.
Is it possible to change a certain property of the chart control to hide the period of time which does not have point.
I implemented something similar to your problem, here is what I used (C#), it may help:
Chart4.DataManipulator.InsertEmptyPoints(1, System.Web.UI.DataVisualization.Charting.IntervalType.Number, Chart4.Series["s3"]);
Chart4.DataManipulator.InsertEmptyPoints(1, System.Web.UI.DataVisualization.Charting.IntervalType.Number, Chart4.Series["s2"]);
Chart4.Series["s3"].EmptyPointStyle.Color = System.Drawing.Color.Transparent;
Chart4.Series["s2"].EmptyPointStyle.Color = System.Drawing.Color.DarkGreen;
You can specify the intervalType.Days in place of number..
datamanipulator.ignoreemptypoints = true;
from this article on grouping:
http://msdn.microsoft.com/en-us/library/dd489213.aspx
If you don't want the x-axis to be scaled to the x-values simply set the/all series to be indexed:
foreach (Series s in chart1.Series) s.IsXValueIndexed = true;
Now each DataPoint will sit at its index position instead of its x-value position. Note that this also mean that you need to make sure all Series aligned, read all have a DataPoint at the same indices, be it a real one or an Empty one or else the will shift..!

Asp.Net ReportViewer Line Chart background

I pass a dataset to my report, which renders a line chart showing a sprint burn down chart. One of the fiends in the dataset is 'PeriodType', which can be either 'Planning, 'Burning' or 'Retrospective'.
The chart shows dates along x axis, and the y axis holds hours.
What I would like to do, is grey the background, where the x axis has a value that is not a 'Burning' period. So the object that is used to create the chart, as mentioned, has a type field I can use.
Is there a way to change the background colour of the x 'columns' based on the flag? Some sort of conditional background colouring? I have searched, but can't seem to find such a handy thing.
Yes, that is possible.
Open the Properties pane, in the BackgroundColor or Color (whichever is relevant) property of the chart, enter an IFF statement like:
=IIF(Str(Fields!PeriodType.Value) <> "Burning", "Gray", "SomeOtherColor")
Hope that helps

using logarithmic scale in Ms chart control

Im trying to create a chart the has a base 10 logarithmic scale for the x axis with a range from 1 to 1000. I seem to be able create the axis during design time but whenever the form is loaded I get an error message saying "Chart Area Axes - A logarithmic scale cannot be used for this axis.
Is this a limitation on the MSChart control? why am I not able to create a log scale on the X Axis?
It is because for a logarithm scale, the values must be greater than zero. Charting.CHart treats empty chart as being consisting of zeros (I know it is weird). This error can be very difficulty to debug. Therefore, it mean that the graph cannot be EMPTY if any of the axis is a logarithm scale. What I normally do is set the axis as linear and the change it immediately after plot on the graph (and checking no zeros or negative values on the logarithm scale). Also, remember to change the axis to linear before clearing the axis and plotting. Hope this helps someone.
I propose to use SuppressExceptions property which allows to ignore some exceptions, also that one connected with zeros in axis with logarithmic scale. I think this is the best solution for that situation instead manipulating data.
chart.SuppressExceptions = true;
It's not just about zeroes but also about having your values in the right datatype. Suppose you're populating the chart with values form a DataTable. If you haven't specified the type, .NET will automatically assume they are strings and thus not be able to plot a logarithmic scale.
incomplete specification of the datatable:
PP = New DataTable
PP.Columns.Add("X-value")
PP.Columns.Add("Y-value")
complete specification:
PP = New DataTable
PP.Columns.Add("X-value", Type.GetType("System.Double"))
PP.Columns.Add("Y-value", Type.GetType("System.Double"))
In the first example the exception will be thrown. In the second it won't.
Not all chart types support logarithmic scales; try changing the chart type e.g. to Line Chart.
Chart types: http://msdn.microsoft.com/en-us/library/dd489233.aspx
ChartType property: http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.series.charttype.aspx

how to change default values of axis to user values

I have created multiple Y-axis in chart and individual scales for each axis by default. Now if user(i) wants to change those default values. I have created one form with textbox for entering scale min and max values.
I have attached an image please have a loot at the image.
now i want to get that text box value and assign to min and max scale of each axis.
Can anyone have the idea how to do it . please help me.
You can modify axis scales using SetMinMax method, for example:
tChart1.Axes.Custom[0].SetMinMax(min, max);
For more information about axis settins please read tutorial 4. Tutorials can be found at TeeChart's program group. For multiple custom axis you may be interested in reading this question.

Microsoft Chart Controls: Label multiple y values and variable y axis?

I am currently using Microsoft Chart Controls to generate a box plot chart. I have enabled the IsValueShownAsLabel property of the chart's series, but only the first y-value(lower whisker) value is being labeled. Is there a way to enable the labeling of all y-values in the chart?
Also, is there a way to get a different axis for each data point? The different data points of the chart are not related when it comes to value ranges, so many data points with small y-values are difficult to read on the chart. I have currently enabled scrolling as a workaround, but am not satisfied with the result. I would instead like to have a different y-axis for each data point, so that the y-values for each data point take up the full height of the chart, with the min and max whisker values serving as the y-axis minimum and maximum points. Is this possible?
To get different axis you will need to look into the properties under ScaleBreakStyle under AxisY
Set something like
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = true;
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.BreakLineStyle = Charting.BreakLineStyle.Wave;
// set this to an even lower value if required
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.CollapsibleSpaceThreshold = 15;
Not sure on how to get multiple values but can you try setting those values specifically to the labels in these format #VALY1,#VALY2 depending on the number of Y values available.

Categories

Resources