Jump to content
Software FX Community

Formatting Axis and Data


rms2219

Recommended Posts

Hello...

I have installed the Chart FX 7 trial version and I have a few questions:

1) My data source is a SQL database table with two columns (one is sql data type "date" and the other is sql data type "decimal(18, 4)"). The dates will be along the X-Axis and the values will be along the Y. An example entry I have in the database is: [2010-06-01, 133615.0000]. Now, I format my x-axis (date axis) like this:

newChart.AxisX.DataFormat.Format = ChartFX.WebForms.AxisFormat.DateTime;

newChart.AxisX.DataFormat.CustomFormat = "MMMM";

newChart.AxisX.LabelsFormat.Format = ChartFX.WebForms.AxisFormat.DateTime;

newChart.AxisX.LabelsFormat.CustomFormat = "MMMM";

because all I want is the date, but for whatever reason, when I do

newChart.Data.Labels.Add(row.ItemArray[0].ToString()); (where row is a DataRow in a DataView.Table, and the string being added gets turned to "2010-06-01

12:00:00 AM")

I get the whole string. I shouldn't need to trim the time off of the string before adding it to the newChart.Data.Labels should I?

2) When adding values to my Y-axis, why does it only accept doubles? In the following code:

for (int i = 0; i < newChart.Data.Points; ++i)

{

for (int j = 0; j < newChart.Data.Series; ++j)

{

// SOMETIMES THIS IS A PERCENTAGE, RIGHT NOW THE PERCENTAGE IS BEING ROUNDED

// THIS NEEDS TO NOT HAPPEN!!!

newChart.Data.Y[j, i] = Convert.ToDouble(values);

}

}

sometimes values will be something like .5678 which should be displayed as 56.78%, but instead is being rounded to 57%. How do I fix this? I am using the Convert.ToDouble because newChart.Data.Y[j,i] won't accept anything but a double.

Link to comment
Share on other sites

 Hi,

regarding your questions, well first the DataFormat.Format property sets the format, but it will not change datasource information. The Format is like a mask for the data showed however if you want to retrieve the values, you will get the whole value. Then, Chart FX 7 component is a X/Y based chart that will plot numerical values across two axis: the X and the Y one. The X can be labels (strings - categorical), numbers or dates (numerical), and the Y axis is defined by the type of data defined for the Chart. The chart at the end, is a graphical representation of numbers, so only numbers are accepted as data for each series.

I saw you posted some code, that is incomplete... maybe you want to re post it again so I can give it a check.

Juan Z.

Link to comment
Share on other sites

Can you please tell me why the Y-Axis is rounding the values I give it?

The line of code I am using to insert values for Y data is:

newChart.Data.Y[j, i] = Convert.ToDouble(values);

For example, if values is .5678, when it is assigned to Y, it is rounded up to 57. It NEEDS to be 56.78.

Link to comment
Share on other sites

It worked perfectly, that's exactly what I wanted. Now, addressing the first issue I had, about the dates. I have attached an imaged image of one of my charts. You'll notice on the X-Axis, that there is a time shown, along with the date. In my database, a sample date would be 01-01-2010 (and NO time). I use ASP's SqlDataSource to connect to my database and I use a DataView to hold the results of my SELECT query

String.Format("SELECT [Date], [Value] FROM [KPIDetails] WHERE [KPICategory] = '{0}'", item.Text);)

Now, for some reason, at this point, the date also includes the time (the DataView added the time in on the query). How would I display this on the X-Axis with no time if the string I'm assigning to the Label includes the time. Do I have to manually trim the time off of the string before assigning?

Link to comment
Share on other sites

Ya I have that already...this is what I have:

newChart.AxisX.DataFormat.Format = ChartFX.WebForms.AxisFormat.Date;

newChart.AxisX.DataFormat.CustomFormat = "MMMM";

newChart.AxisX.LabelsFormat.Format = ChartFX.WebForms.AxisFormat.Date;

newChart.AxisX.LabelsFormat.CustomFormat = "MMMM";

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.

×
×
  • Create New...