Center axis on barchart using visifire - c#

I am currently working with visifire on a c# charting project.
I want to create a bar chart to show percental increase as green bars and decreases as red bars. The Axis / 0 point line should always remain at the same position.
The problem is, that the axis currently moves all around the screen depending on the values that are shown. (see the image below)
I already tried to center it with axismaximum and axisminimum set to fix values, but that doesn't work.
The way i want it to be is like this.
or this
Are there any remaining visifire cracks out there, that can understand the problem and help?

One workaround for this is finding the maximum value (absolute value, using Math.Abs) from the series, then adding its counter value to the beginning of series.
For example, if the maximum absolute value is -80%, then add a +80%. In this way, the axis can be centred.
You can use a special colour (Transparent?) for the first bar, or use other control to cover it so user will only see the real data.

Using data bindings, this should do the trick.
MinValue = -MaxValue
<vc:Chart.AxesY >
<vc:Axis AxisMaximum="{Binding MinValue}" AxisMinimum="{Binding MaxValue}" Enabled="False" AxisType="Primary" >
</vc:Axis>
</vc:Chart.AxesY>
Otherwise this is the same without databinding
<vc:Chart.AxesY >
<vc:Axis AxisMaximum="70" AxisMinimum="-70" Enabled="False" AxisType="Primary" >
</vc:Axis>
</vc:Chart.AxesY>

Related

c# - create Horiz. scrollbar on chart when data is plotted off-screen

I have a line chart, which, after enough data points have been plotted to it, the data will exceed what is visible on screen (so that the chart is only showing the most recent data). When this occurs, I would like a scroll bar to be filled for the X axis, allowing the user to use the scroll bar to view such previous data.
How do I go about doing this? I don't want the user to be able to drag or zoom on the chart itself, just to solely use the scroll bar to navigate along the chart.
I've looked at this article: https://msdn.microsoft.com/en-us/library/dd456730.aspx but it doesn't help & the scrollbars do not appear.
Without seeing the relevant parts of your code it is hard to pin down your problems.
Here is one strange statement:
after enough data points have been plotted to it, the data will exceed
what is visible on screen (so that the chart is only showing the most recent data).
Now this can only happen after you have set the AxisX.Maximum because by default the chart control will squeeze the area more and more while you add points.
But when you have set a maximum of what can be shown, no scrollbar can work or even been shown. Sounds logical, right?
So either don't set it in the first place or clear it when the number of points exceeds what you want to show. To clear it use NaN :
chart1.ChartAreas[0].AxisX.Maximum = Double.NaN;
Or, of course, set it to the last point you want to be shown!
After looking at what you mustn't do let's see what you need to do to show the scrollbar:
First you enable it:
chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
Next you tell it to show only the scrolling handle and not the zoom-reset button:
chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
See MSDN on ScrollBarButtonStyles for the various things the scrollbar can show/do!
And to make sure the user can't zoom set this:
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false;
And finally set the current range to show:
chart1.ChartAreas[0].AxisX.ScaleView.Size = 111; // show 111 DataPoints
Now the scrollbar should show.
It is a good idea to study the AxisScaleView class as it has a couple of helpful properties..
Depending on the data type of your X-Values you may also need to set the ScaleView.MinSizeType to whatever suits your data:
chart1.ChartAreas[0].AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Number;

Teechart Linear Gauge Duplication of axis title for multiple gauges on single chart

I am evaluating Teechart.Net (v4.13.12.13) for Xamarin Android (v4.12) to determine suitability for a project that requires the use of gauges to present data and I've come across a few issues that I haven't been able to figure out:
I would like to add a number of linear gauges to a chart, each with a unique title, but it seems the axis title assigned to the last gauge that was added to the chart is applied to all gauges in the chart. Am I setting the wrong property (LinearGauge.Axis.Title.Text) or is there some other way to assign unique titles to the linear gauges. The other apparent option would be to add a separate chart for each gauge, but that doesn't seem right. In the image below, I need to show two distinct temperatures but both are labelled the same.
I created a circular gauge and enabled the embedded numeric gauge. However, no matter what I try I cannot get any text displayed in the numeric gauge. It is drawn inside the gauge, but no text. I've set CircularGauge.NumericGauge.Chart.AutoRepaint to true, then false and manually repainted, all without success. Is this a bug? I tried the same code with Teechart.Net for Winforms and it works OK so I'm having doubts about the Teechart release for Xamarin.
Any help will be greatly appreciated.
I would like to add a number of linear gauges to a chart, each with a
unique title, but it seems the axis title assigned to the last gauge
that was added to the chart is applied to all gauges in the chart. Am
I setting the wrong property (LinearGauge.Axis.Title.Text) or is there
some other way to assign unique titles to the linear gauges. The other
apparent option would be to add a separate chart for each gauge, but
that doesn't seem right. In the image below, I need to show two
distinct temperatures but both are labelled the same.
This is by design. Gauges use standard chart axes (left and bottom). Each chart has one set of axes and hence the title is being overwritten. Adding separate charts would be the recommendation.
I created a circular gauge and enabled the embedded numeric gauge.
However, no matter what I try I cannot get any text displayed in the
numeric gauge. It is drawn inside the gauge, but no text. I've set
CircularGauge.NumericGauge.Chart.AutoRepaint to true, then false and
manually repainted, all without success. Is this a bug? I tried the
same code with Teechart.Net for Winforms and it works OK so I'm having
doubts about the Teechart release for Xamarin.
Using the code below doesn't plot text in the NumericGauge in WinForms either. Can you please modify it so that we can reproduce the problem here?
CircularGauge circularGauge1 = new CircularGauge(tChart1.Chart);
circularGauge1.NumericGauge.Visible = true;
Thanks in advance.

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

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.

VISIBLOX, WPF: Getting chart points to scroll horizontally?

I'm using the Visiblox WPF API and am having trouble getting the chart points in my line chart to scroll horizontally. Instead of scrolling, the points are get squashed together, in which, this isn't particularly a problem, except that I expect to have 100s of data points on the chart. I have looked throughout the examples available on the Visiblox website, but couldn't find what I was looking for. Ive attached an example screenshot.
Any ideas?
Thanks for your help,
Sparky
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches: 1) when you add the last point, remove the first one which will effectively move the visible window one point over or 2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified
I just had something like this recently. Everytime I'd add a point to the cart I'd run a little section of code that would check the amount of time (my x-axis dimension) that had passed since 0. I also set up a range of data I always wanted to see. I always wanted to show 120 seconds of data on the graph. So I had something like this:
private void adjustXasis(int timeCount)
{
if(timeCount>desiredRange)
{
chart.axis.Xaxis.minimum=timeCount-desiredRange;
chart.axis.Xaxis.maximum=timeCount;
}
else //two minutes not reached yet
{
chart.axis.Xaxis.minimum=0;
chart.axis.Xaxis.maximum=desiredRange;
}
}
I don't have VS in front of me and I know that syntax for the axis min/max is wrong but you get the idea.
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches:
1) when you add the last point, remove the first one which will effectively move the visible window one point over or
2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified

Categories

Resources