I need to plot the 4 to 5 different values with different annotations ( Triangular , Square ) on the chart. I need to plot the different values for different X axis values. Multiple values cannot be plotted for same point.
For example : I have numbers 30 to 50 as my X Values. Also, I have multiple Y values. I need to plot the value Y on x-30 and next value of Y on x-32. Basically, the requirement is Y values should be plotted at the fixed point of X and not sequentially.
When am adding the data to the collection, I should be adding both X and Y Values so that data is plotted exactly at point required.
Is there any collection where both X and Y values can be added to the collection ?
Please let me know how to fix the Y axis range to specific values ??
You can specify the x and y coordinates of individual points, and you can use multiple layers, one for each symbol shape.
By default, ChartDirector will automatically configure the axis scale based on your data values. However, if you want to specify the scale with your own code, you can use Axis.setLinearScale. For example, in C++, it is like:
// From -8 to 8, with a label every 2 units.
c->yAxis()->setLinearScale(-8, 8, 2);
If you need further help, please let me know of your programming langauge.
2. Depending on exact what you want, there are several methods to add space around the border of the plot area:
(a) Use Axis.setIndent. This will add 0.5 units to the end points of the axis. This is most useful if the data points are at integral (x, y) values. For example:
// extend scale by 0.5 units
(b) Use Axis.setMargin. This will add a number of pixels at the end point of the axis. For example:
// 15 pixels margin at either end points
(c) Use Axis.setAutoScale. This will extend the axis scale to ensure at least some percentage at the axis end points have no data. This only applies if the axis is auto-scaled by ChartDirector. For example:
// Extend axis scale so that at least 5% empty space at either end points.
c.xAxis().setAutoScale(0.05, 0.05, 0);
By deafault, ChartDirector will extend the scale at the next labelled position. For example, it may extend the scale from (5, 6, 7, 8, 9) to (4, 5, 6, 7, 8, 9, 10), but not to (4.778, 5, 6, 7, 8, 9, 9.222) if 4.67 and 9.33 are non-labelled positions. This means the actual extension can be more than 5%. You can use Axis.setRounding to disable extending to the next labelled position like:
In the above, the code also applies to the y-axis.
3. I am not sure what are "X" Data points. Do you mean data points ? The following is an example in which the symbol sizes are set by another array. You can see the circle symbols are of different sizes.
Regarding 3rd question, am adding the external images for the data points. Since the image is very big, it is consuming more space in the chart. I want to reduce the image size so that it fits perfectly for the exact X Value.
There are many methods to do what you need. For example:
(a) You can use Axis.addMark for the x-axis to add a vertical mark line. You can set the line color to a y-zone color so that the line open appears between two y-values (such as between y = -4 to y = 2). The code is like:
// Transparent below -4 and above 2. So only visible for -4 <=y <= 2.
int lineColor = c.yZoneColor(-4, Chart.Transparent, c.yZoneColor(2, 0xff0000, Chart.Transparent));
// Add the mark line at x = 30, only visible for -4 <= y <= 2.
(b) Another method is to simply add a line layer with two data points for the vertical line. You can use multiple lines layers for multiple vertical lines.
I tried with first approach and it worked. Now, am trying to take the image of chart in .png format. I have been using Microsoft API's. I can only see the legends and not the chart plotting area. I need to take the image of full chart.
I tried with makechart API. But the image does not have the plotting area. I can only see the legends but the not the data being drawn in the chart. I have attached the image for your reference. Please let me know what could possible the issue.,
One possibility is that there is no data to plot. For example, if you add scatter layers with no data (the data arrays are null or the array size is 0), there will still be legend entries, but the plot area will display nothing.
Consider the Scatter Chart sample code that comes with ChartDirector:
then the scatter chart will be produced as a PNG image.
However, if you set the data arrays to arrays of zero size:
dataX0 = new double;
dataX1 = new double;
dataY0 = new double;
dataY1 = new double;
then the chart image will contain the legend entries, but the plot area will contain nothing.
If you need further help, is it possible to provide an example that I can run to help me diagnose the problem? For example, you can modify the "Scatter Chart" sample code until the problem occurs, and then attach the modified code in your message.
Thanks. Issue is fixed now. Can we set in the y axis that the minor ticks are not displayed. In the attached image, I would like show just the values like 0,100,200. Values should be displayed in hundreds only. This condition should be applied only when value is beyond 100 or -100.
In the attached image , 23 values are added for X axis. I have requirement that only 20 data points should be shown. Hence X axis should have only 20 values. As you can see in the image for some x values there is no data and it should be shown.
If i use the setLinearScale API , I should specify the min and max range. Instead, Can i add the values explicitly. ? I have tried the setlabels(string) and setlabels(double). Both does not work. I want to show the X Values in sequence but not the continuous values.