Scaling values on the selected axis - c#

I have a chart using Syncfusion LineSeries.
I would like to scale the data on the X axis. Only the same values in the graph (the data on the axis label should be the same as it is now)
In short, the visible graph should be horizontally downloaded (e.g. scaled down 10 times)
Can it be done?
Just dividing the value by 10 does not change anything when the chart continues to fill the chart completely.
Image

We would like to suggest the following chart axis features.
Maximum property used for setting the maximum value for the axis range
Minimum property is used for setting the minimum value for the axis range.
EnableAutoIntervalOnZooming property is used to maintain the interval even it is in zooming state only if we set the interval to the axis. Default value of this property is true. While zooming based on the auto range padding the interval will be calculated.
For more details, please refer below UG,
https://help.syncfusion.com/wpf/charts/axis
Note: I am working in Syncfusion.

Related

How to keep PointWidth fixed and add scrollbar in Range bar Chart

I have a gantt chart contrains tasks.
I declared the PointWidth as 0.25
GanttChart.Series["Tasks"]["PointWidth"] = "0.25";
this works good when I have few tasks but whenever I have more tasks the pointWidth (range) becomes smaller and smaller!
I want to keep it 0.25 and to put scrollbar when there are many tasks.
The CustomProperty PointWidth is in percent of the visible axis.
So with one point the bar or column is really fat and the more data points you add the thinner they will get.
If you want to keep a fixed width while changing the number of data points you need to use PixelPointWidth instead.
Note however that by default now the bars/columns get closer and closer to each other until the overlap.
To give them enough room and show scollbars instead, you need to enable the built-in zooming mechanism as MSChart will not use normal Scrollbars.
This should help:
Series s = chart1.Series[0];
s.SetCustomProperty("PixelPointWidth", "12"); // 12 pixels
var ca = chart1.ChartAreas[0];
ca.AxisX.ScrollBar.Enabled = true;
ca.AxisX.ScaleView.Size = 30; // show a value range of 30
chart1.Refresh(); // usally not needed, but we change a custom property
Note that the ScaleView.Size is in data values. This is the 3rd of the three coordinate system in the chart: percentages, pixels and values! Very powerful and rather tricky..

WinForms Chart control - Show labels between ticks

By default the WinForms Chart control shows labels centrally below the ticks.
Is there any way to change that so that the labels are shown between the ticks instead, as per this image:
I think the only way to do this would be to use custom labels. That means taking over the job of adding the labels from the control and doing it manually yourself, which may or may not be suitable in your case.
The "Labeling Axes Using Custom Labels" section of the MSDN documentation describes this in more detail:
Use custom labels to provide custom text for axes. Custom labels are
implemented using the CustomLabels collection property. If you use
custom labels, the chart area does not display axis labels from data
points.
When using CustomLabel objects, you must set the ToPosition and
FromPosition properties of each CustomLabel object, and these
properties must specify the width of the label's text area. Do not
assign the same value to both of these properties because they
represent a range. To position a custom label directly beneath a data
point and its associated tick mark, set the FromPosition property to
the value of that data point's axis minus half of the tick mark
interval, and set the ToPosition property to the value of that data
point's axis plus half of the tick mark interval. For example, if an
axis has an interval of 1 (1, 2, 3,…), and you want to use a custom
label at X=2, then set the ToPosition and FromPosition properties to
1.5 and 2.5, respectively.
The RowIndex property specifies on which row the custom label is
displayed. If a custom label is used in the first label row, the chart
area does not display any labels from the axis scale. The only labels
permitted in the second row and beyond are custom labels.
In your case you don't want the labels to be directly below the tick mark, so in the example in the quoted text above you'd set your position ToPosition to 2 and your FromPosition to 3.
Looking at your specific graph, if the x-axis values are DateTimes, you'll need to check if the To/From Positions will work with DateTimes. If not, you may need to convert the values to serial numbers (you could use e.g. DateTime.ToOADate() to do this) before using them for the x-axis. That won't effect what's displayed as you will be replacing those labels with your own ones anyway, which you can then format as you wish.
The regular Labels will always show with the DataPoints. But you can show the tick marks between.
Depending on the datatype and Interval you can set an MajorTickMark.IntervalOffset:
chart1.ChartAreas[0].AxisX.MajorTickMark.IntervalOffset =
chart1.ChartAreas[0].AxisX.Interval / 2f;
Note: For this to work you need to set the Interval. By default it is set to 0.0, so you need to set it to some other value! Most of the tome a value of 1 will be fine.
The harder altenative would be to use CustomLabels for that.. Much more work for the same result. Not really recommended. You can see an example here

Chart control - Gap between first X value and Y-axis

I'm using a line chart to plot some values, where the x-axis has a set of strings and the y-axis has a double value between 0 and 1. Everything works correctly except there is a gap between the first x value and the y-axis
the image shows.
In this question the solution is setting the x-axis maximum and minimum value. However, I can't seem to do it in this case as the values are strings and not doubles / dates.
Given that you are using strings, this may or may not help. Try setting the IsXValueIndexed property of your underlying series to be false.
See this MSDN article for reference:
http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.series.isxvalueindexed(v=vs.110).aspx
To remove the margin you need to set
chart.ChartAreas[0].AxisX.IsMarginVisible = false;

How to change drawing line size in TeeChart

I am working with TeeChart fro .net, I would like to increase the size of drawing line in the chart. presently it is drawing very thin line which is not visible for all people. How to increase size of drawing line in TeeChart.
I have attached a simple chart image from my application. I would like to draw the line with more or equal size to axis lines. presently it seems drawing line size less that axis line size. I mean i want to draw line more thick.
2) How to assign axis scale more reliably, i mean presently if i have axis minimum and maximum values from 0 to 6, then it is showing on the axis like 0,2,4,6. I would like to see like 0,1,2,3,4,5,6 like that i mean with 1 scale increment. Please help me with the above two things.
1) How to increase drawing line size?
2) How to assign scale of axis more convenient?
The chart's features mention support for Csharp .NET charting control.
http://www.steema.com/teechart/net
Microsoft has pages with information about the chart controls:
http://msdn.microsoft.com/en-us/library/dd456632.aspx
Looks like you will find how to do the things you want there.
1) How to increase drawing line size?
You can set Line or FastLine Pen.Width like this:
line1.LinePen.Width = tChart1.Axes.Left.AxisPen.Width;
2) How to assign scale of axis more convenient?
TeeChart will automatically set axis scales to the minimum increment possible provided labels don't overlap. To get a fixed axis increment you should set axis Increment property. Labels won't be allowed to overlap though.
tChart1.Axes.Bottom.Increment = 1;
For more information on axis settings please read tutorial 4. Tutorials can be found at TeeChart's program group.

How to print labels on both sides of a rangebar in WinForms MS Chart using C#

How can i add labels for each and every yvalue in series of a rangebarchart ?
You all know that for plotting rangebartype series ,we need two yvalues as yvalue[0] and yvalue[1] .Here I need to add data labels to each of those yvalues( which means both at yvalue[0] and yvalue[1]).how can i implement that?can anybody suggest me?please!!
The label should look like as below for a rangebar(to be displayed on both sides of a rangebar).
Label1 ███████████████ Label2
Label███████████████████ Label
There is no built-in way to do this in MS Chart. However, there is an ugly little workaround that will give you the display that you want.
For each datapoint (rangebar) that you want to display, you will need to create 2 datapoints that lie on top of one another. As an example:
DataPoint0: X=1 Y=5,10
DataPoint1: X=1 Y=10,5
These two datapoints lie right on top of one another, except one is displayed left-to-right and the other is displayed right-to-left.
For each DataPoint, under CustomProperties, there is the BarLabelStyle property. Set this to 'Outside' for both of the datapoints. Normally, this will display the label to the right of the range bar, but for DataPoint1, with the reversed Y values, the label is now placed to the left of the range bar. So, set your label for DataPoint0 to 10 (max value), and for DataPoint1 set the label to 5 (min value).
This will then look just like one range bar with the min value on the left and the max value on the right.
Caution: If either end of the range bar is too close to the edge of your graph, MS Chart, in its infinite wisdom, will force the label to be displayed inside the range bar. To overcome this, you can actually add a third number to the Y values of the DataPoint object. This third value is not displayed, but if it is larger than the largest Y value in your data series, it will force the chart to rescale to accommodate this larger value, so your labels are not forced inside the range bars. You could probably handle this another way with setting properties of the ChartArea also.

Categories