Show gridline in chart - c#

I have a c# chart control that shows dates along the horizontal (x) axis. I want to show gridlines only on thosex axis points that represent the start of the month. How may I do this.

I guess you mean mscharts so it could be
chartArea.AxisX.MinorGrid.Enabled = false;
The ones corresponding to the datapoints is the MajorGrid which can also be toggled similarly.
you can also do the same for the Y axis too.

Related

add space between .net chart and lable

How can I move the labes down?
I would like to add some space between the chart and the labels. It is possible?
I'm using System.Web.UI.DataVisualization.Charting.Chart
Like in this edited in mspaint:
This answer will be under the assumption that you are using CustomLabels on the X-axis:
It is possible, but I am not aware of such a setting. But I can offer a pragmatic solution (i.e. a bit of a hack): Namely you reenable the gridtickmarks on the X-axis, but set Color to Transparent, after that you can adjust the distance to the axis by using MajorTickMark.Size (default 1), the tick marks will not be visible:
chart.ChartAreas[0].AxisX.MajorTickMark.Enabled = true;
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = Color.Transparent;
chart.ChartAreas[0].AxisX.MajorTickMark.Size = 1;
// You can increase MajorTickMark.Size to increase distance to the axis
And incase someone want to have both visible tickmarks and labels on an axis:
Look into using DataPoint.AxisLabel in your series rather than using CustomLabels on the X-axis. DataPoint.AxisLabel will add a label on the axis for each datapoint. The axis-labels will then have the same distance to the axis as normal interval labels. There is a trick to it, that if the first and last data point in a series have an AxisLabel set the axis interval numbers will be hidden and leave only the axis labels.

Can we draw Tertiary Y Axis with the use of chart control

I want to draw a graph which has 2 different Y axis with one X Axis. Can we take different Y axis for different series? In first series I want candlestick graph and in second column chart, both charts should be in same chart area and should not be mixed with each other.
For example you can see the picture below
A ChartArea can have two x-axes and two y-axes.
The secondary axes are called
chartArea.AxisX2
and
chartArea.AxisY2
Enable them like this:
chartArea.AxisY2.Enabled = AxisEnabled.True;
Now you can style them as usual..
You can relate a Series to one of the Axes by setting the AxisType like this:
yourSeries.YAxisType = AxisType.Secondary;
Talking about axes: It is worth knowing that you can move them relative to each other by setting their Crossing; see here for an example..

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..!

vs2010 chart. How to group Y axis value

I have a bar chart. My X-axis are Names and my Y axis are age values. The default bar chart is set to intervals but I want a range (a yes and no chart). I want to make a Y axis displaying something like "under 13", "13-21","+21" and graphing it correctly. How do I do that? I been researching this for a while.
I just need to learn how to do this. But my real project is similar.

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