Jump to content
Software FX Community

How to output X-Axis values of data points as well when using copy to clipboard as Text option


Xiaonan Ji
 Share

Recommended Posts

Icame across a problem of exporting the text-only information of thechart to clipboard.The application has several two dimensional points. I use the following way to set the points in the chart://Get X Axis,Axis xAxis;//Get Y Axis,Axis yAxis;foreach(point p in pointList){   xAxis[seriseNo, pointNo] = point.X;   yAxis[seriseNo, pointNo] = point.Y;}Ididn't manually assign any labels to x axis since the points were notevenly distributed on x axis. In this case, labels on x axis wereautomally generated.When I tried to copy the text of the chart to clipboard, it didn'toutput the points' x-axis values. That is, in the output, there wasonly one column about points' y-axis values.If I manually setthe x-axis labels for each point in another case, in the text-output,x-axis values were included. That is, there were two columns forpoints' x-axis and y-axis values.My question is, if I don't manually assign any x-axis labels, isthere a way to output points' x-axis values as well? Any relaventsolution is welcomed as well.

Link to comment
Share on other sites

By default, X-Values are exported into the clipboard if they are present.

This can be turned off using the ExtraStyles property (ChartStyles.ExportXValues flag).

Please check your code and look for this property, you may be inadvertently clearing this flag.

If you are unable to locate this, please include a VS project that reproduces the problem.

Link to comment
Share on other sites

ExtraStyles property (ChartStyles.ExportXValues flag)

 

 Yes, it seems that this works for me. I set currentChart.ExtraStyle = currentChart.ExtraStyle | ChartStyles.ExportXValues; and it gives me the x-values.

In the graph, I have three series, with the same number of points on each series. The points in the same position on series have the same x-value. By using the above method, in the clipboard, for each serie, it produces a column of x-values. That is, three columns of the same set of x-values. Any way to let it only produce one single set of x-values? The final result should be similar to using labels. That is, if using labels, only one column of labels is output as the first column.

 Many thanks for the first solution and looking forward for the second one.

 Regards

 Xiaonan

Link to comment
Share on other sites

X-Values may be shared or independent to each series, this depends on how you set them. Labels on the other hand are always shared (they belong to the X-Axis not to each series). This allows a lot of flexibility for X/Y charts.

If you are setting the data through the data API, you should only set the X-Value for the first series and they will be shared. For performance reasons, we do not check that all series are identical.

Additionally, you can set:

chart.Data.X.Shared = true;

If you are databinding, make sure only one field is used for X-Values.

Link to comment
Share on other sites

I made sure chart.Data.X.Shared is always true and I only set X-values for the first series but the output still has multiple x-value columns.

Another interesting thing is, the x-values are two-digit decimals but the copy out text has one-digit decimals instead. So a x-value of 0.75 is output as 0.8. In the chart, the x-axis labels(automatically generated by chart fx) are also one-digit decimals. In chart it is totally OK but once the text values are output, 0.8 can be misleading.

 Sorry for these following-up questions.

 Many thanks

 

Link to comment
Share on other sites

 OK, I figured out the decimal output problem was that I didn't set the format for the axis. Now it is OK.

 I tried to set x-values for points in the first series. Since the upper bound of the confidence bound (series 3) should have a YFrom set to be the lower bound of the confidence bound (series 2), I set YFrom for points of series 3. This seems to me should not affect the share of the x-values and I tracked that the shared property remains true. But in the clipboard, it exported multiple columns. But when I remove the setting of YFrom for points of series 3, there is only one x-value column in the output.

 Thanks.

Link to comment
Share on other sites

 For simplicity reason, I just attach a small piece of code as following:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace ChartFXPractice{   public partial class Form1 : Form   {     public Form1()     {       InitializeComponent();     }     private void Form1_Load(object sender, EventArgs e)     {       chart1.Data.Series = 2;       chart1.Data.Points = 5;       Dictionary<int, int> line1 = new Dictionary<int, int>();       line1.Add(1, 3);       line1.Add(3, 4);       line1.Add(5, 22);       line1.Add(12, 32);       line1.Add(33, 4);       Dictionary<int, int> line2 = new Dictionary<int, int>();       line2.Add(1, 3);       line2.Add(3,5);       line2.Add(5, 8);       line2.Add(12,13);       line2.Add(33,44);       chart1.Data.X.Shared = true;             int p = 0;       foreach (KeyValuePair<int, int> pair in line1) {         chart1.Data.X[0, p] = pair.Key;         chart1.Data.Y[0, p] = pair.Value;         p++;       }       p = 0;       foreach (KeyValuePair<int, int> pair in line2) {         //chart1.Data.X[1, p] = pair.Key;         chart1.Data.Y[1, p] = pair.Value;         p++;       }       chart1.ToolBar.Visible = true;     }   }}

 There are two series, with same number of points, with same x-values. So I only set the x-values for the first series but comment out the setting of x-values for the second series. And I set the Shared property to true at the beginning. But in the clipboard output, I get:

1   3   1   33   4   3   55   22   5   812   32 12   1333   4 33   44

 What I expect is:

1       3       33 4 55 22 812 32 1333 4 44

 Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...