rms2219 Posted January 5, 2010 Report Share Posted January 5, 2010 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. Quote Link to comment Share on other sites More sharing options...
juanZ Posted January 5, 2010 Report Share Posted January 5, 2010 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. Quote Link to comment Share on other sites More sharing options...
rms2219 Posted January 5, 2010 Author Report Share Posted January 5, 2010 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. Quote Link to comment Share on other sites More sharing options...
juanZ Posted January 5, 2010 Report Share Posted January 5, 2010 Before assgning the data, please set this property. chart1.AxisY.DataFormat.Decimals = 2; Let me know about your findings. Quote Link to comment Share on other sites More sharing options...
rms2219 Posted January 6, 2010 Author Report Share Posted January 6, 2010 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? Quote Link to comment Share on other sites More sharing options...
juanZ Posted January 6, 2010 Report Share Posted January 6, 2010 Hi, Try to set the format to the axis labels now. Like this: chart1.AxisX.LabelsFormat.Format = AxisFormat.Date; (only Date and no DateTime) Quote Link to comment Share on other sites More sharing options...
rms2219 Posted January 6, 2010 Author Report Share Posted January 6, 2010 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"; Quote Link to comment Share on other sites More sharing options...
juanZ Posted January 7, 2010 Report Share Posted January 7, 2010 Can you please post the code you are using to attach your dataset to chart datasource? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.