To explain my question I drew an image, here it is:
So I have a Chart that has a bar graph and a line chart, 2 in 1. I am trying to displaly it in asp.net just the way i drew it on here. This means the A box on the image has a set of values which reflect the line graph, and C box on the image has a set of values that define the bar graph values.
What I want to ask is how do I set two different sets of values on a single chart. I know I can use series to draw multiple graphs and by having series defined as different types I can change if its a bar graph or a ilne chart, however I don't know how to add 2 range of values on the side.
As for the the box B, what I wish to ask is how do I set these values so that they are showing different dates, I was able to do it using a line of code shown bellow, however that line of code sets every value to same, and I need them to reflect different values such as range of dates in this example on the image.
Code that I tried is: Chart1.Series["Series1"].AxisLabel = "Test";
Help is most appreciated!
Cheers!
Ok so i'm going to leave this question up for those that come into similar problem.
This is how you set column A and column c
Chart1.Series[0].YAxisType = AxisType.Primary;
Chart1.Series[1].YAxisType = AxisType.Secondary;
Chart1.ChartAreas[0].AxisY.Maximum = 500;
Chart1.ChartAreas[0].AxisY2.Maximum = 7000;
Your grid lines might get messed up so if you want to disable them use
Chart1.ChartAreas[0].AxisY2.MajorGrid.Enabled = false;
And just as a bonus if you want to set intervals on each Y axis you can do that with
Chart1.ChartAreas[0].AxisY.Interval = 50;
I still haven't figured out how to do part B that I mentioned, so if you know the answer then please share.
Cheers!
Related
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;
I have a problem fitting my chart:
How can I adjust or manipulate the y-axis numbers to start from where I want it?
Secondly, is there a way (properties) which may help me display this graph friendly? As we can see all x-axis name aren't displayed and maybe a space b/w grey and blue bars?
Any help to how to display charts friendly is welcome
You can set the Interval of each Axis:
yourChart.ChartAreas[0].AxisY.Interval = 17;
And you can make it start at any Offset:
yourChart.ChartAreas[0].AxisY.IntervalOffset = 11;
As for the X-Axis Labels it is hard to tell without knowing your code..
..but basically the same options apply here too:
yourChart.ChartAreas[0].AxisX.Interval = 1;
To control the widths of the columns you set their custom property PixelPointWidth but adding a gap is not possible.
All solutions I found are hacks and the best one is to add a dummy Series between the real data series:
chart1.Series[0]["PixelPointWidth"] = "33";
chart1.Series["gap"]["PixelPointWidth"] = "33";
chart1.Series[2]["PixelPointWidth"] = "33";
Fill it with the same number of DataPoints with an X-Value of 0!
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.
Apologies for not able to find a more suitable title for my issue here. I am using MS Chart control in my project to plot real-time values from a source that generates 4 values per second. X axis is time at which the value is generated and the Y axis the value itself. I am dynamically adding a new series for each variable. All the variables are manually added by the user one-by-one and then a series will be created for it.
Basic part seems to be working except the chart is plotting values from different series at different time even though the values are generated at same time. Following image shows the exact issue:
As you can see, the list in bottom is a list of values I am plotting. It shows values and the time they are generated at (hh:mm:ss.ms)
When I plot these values, which is shown in the chart area, this is what I get. See the location of the latest values (marked by red arrows) for all the series. The latest value is at different time even though they all are generated at the same time. Every series seem to have a separate X axis. I expected the latest Y values should be plotted at the same X value and that should be shown at the extreme right of the chart. More like the bottom most series is being shown. That is the very first series created. Every time only the series that is created first works fine and the following series lags for some reason.
Chart, share X axis between different series looks like similar issue to mine but is not answered.
Chart Multiple series different length generate duplicate x axis seems to be the exact issue I am having but the difference is - I am plotting a real-time graph. I can't loop through every series after adding a new data point to mark whether a point is empty or not. That will be a lot of overhead. Some Googling suggested use of InsertEmptyPoints() to every series to match all the X axis. MS Chart sample code also explains using this method but I am not sure where/when to use this method. If I use it after creating a series but before adding a data point - the code crashes. I have tried something like this:
_chart.Series.Add(series);
_chart.DataManipulator.InsertEmptyPoints(250, IntervalType.Milliseconds, name);
Am I doing something wrong here? Thanks for any help offered.
I got this working by adding empty points. I filled every series with max possible data points to begin with. Say I want to show 100 data points in every series before I start deleting the oldest (Points[0]) data point so that my chart will look like it's moving from right to left. In that case I will add 100 empty points while creating every series using:
for (int i = 0; i < 100; i++)
{
series.Points.AddXY(i.ToString(), double.NaN);
series.Points[i].AxisLabel = " ";
}
Then, while adding real data just do it normal way:
_chart.Series[index].Points.AddXY(time, YValue);
// delete more than max. points.
if (_chart.Series[index].Points.Count > MaxTrendPoints - 10) // -10 is adjustment. Got it by trial and error.
_chart.Series[index].Points.RemoveAt(0);
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