Home Forums WinForms controls Xceed Chart for WinForms its regarding date and time

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18651 |

    How can i assign a datetime values for x-axis for a chart control
    Hey guys can any one of u

    Imported from legacy forums. Posted by chandra (had 10082 views)

    User (Old forums)
    Member
    Post count: 23064

    You can do something like this :

    chart = chartControl1.Charts[ 0 ];
    chart.Axis( StandardAxis.PrimaryX ).ScaleMode = AxisScaleMode.Numeric;
    chart.Axis( StandardAxis.PrimaryX ).NumericScale.AutoLabels = false;
    //do this for every date you want to add
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “2005-10” );

    Imported from legacy forums. Posted by André (had 483 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for reply
    I want to bring the data from database
    I dont want to enter the value
    thanks

    Imported from legacy forums. Posted by chandra (had 563 views)

    User (Old forums)
    Member
    Post count: 23064

    You will still need to feed it manually to the chart, that is, you will have to get the values from the database yourself, and feed them in a loop as I previously shown :

    //do this for every date you want to add
    for 0 to n
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( <string date from database> );

    Imported from legacy forums. Posted by André (had 568 views)

    User (Old forums)
    Member
    Post count: 23064

    What if there are thousands of points? I don’t want a label for each point on the x-axis.
    Also, what formatting can we apply to the date-time display?

    Imported from legacy forums. Posted by JD (had 521 views)

    User (Old forums)
    Member
    Post count: 23064

    You can set the AutoLabels property to false, so you don’t have a label at every point. you can use it along with then CustomStep and CustomSteps properties :

    Chart.Axis(StandardAxis.PrimaryX).ScaleMode = AxisScaleMode.DateTime;
    Chart.Axis(StandardAxis.PrimaryX).DateTimeScale.AutoLabels = false;

    You can set the formating through the ValueFormatting property, to Date, LongDate, or DateTime :

    Chart.Axis(StandardAxis.PrimaryX).ValueFormatting.Format = ValueFormat.Date

    Imported from legacy forums. Posted by André (had 600 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks – I still don’t understand why the previous reply says to add the datetime as a string, and not as a DateTime.ToOADate(). Could you explain?
    Regards

    Imported from legacy forums. Posted by JD (had 277 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m not sure I understand your request. When adding X values to a DateTime scale (not labels on the axis), you need to use the ToOADate() method.

    e.g. :

    <i>
    for (int i = 0; i < 6; i++)
    {
    TimeSpan span = TimeSpan.FromDays(rnd.Next(7, 30));
    dt += span;
    m_Line.XValues.Add(dt.ToOADate());
    }
    </i>

    Imported from legacy forums. Posted by André (had 403 views)

    User (Old forums)
    Member
    Post count: 23064

    Where exactly do you place the code. I’m currently using a Visual Studio 2003 asp.net web application project. There are 2 possible tabs to put it in. Either an aspx(Which gets me to things like chart editor) or aspx.cs(where the code is).

    I’ve looked in the aspx.cs especially in the generated code areas and cannot figure out where it should go.

    Imported from legacy forums. Posted by sgekberg (had 704 views)

    User (Old forums)
    Member
    Post count: 23064

    You place it in the WebForm1.aspx.cs (or whatever name you gave it) file, at the beginning.

    Look at this <a href=”http://doc.xceedsoft.com/products/chartNet/doc/sources/buildingwebapplications_getting_started.htm”>topic</a&gt; in our online help documentation for more information.

    You can also look at the code of the Chart sample explorer, that you will fine in the installation directory, normally here :

    C:\Program Files\Xceed Components\Xceed Chart for .NET and ASP.NET 4.0\Samples\VS.NET 2003\CSharp\Web Forms\Xceed Chart Explorer

    Imported from legacy forums. Posted by André (had 601 views)

    User (Old forums)
    Member
    Post count: 23064

    hi,
    I am using the code below for PrimaryX axis and it works fine but I want to use it for SecondaryX however it does’nt work. Is there a reason for that or am I doing something wrong?

    chart.Axis(StandardAxis.SecondaryX).ScaleMode = AxisScaleMode.Numeric;
    chart.Axis(StandardAxis.SecondaryX).NumericScale.AutoLabels = false;

    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-04”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-05”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-06”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-07”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-08”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-09”);
    chart.Axis(StandardAxis.SecondaryX).Labels.Add(“2005-10”);

    Imported from legacy forums. Posted by Serkan (had 449 views)

    User (Old forums)
    Member
    Post count: 23064

    It is probably hidden by the PrimaryX axis. Try to offset it by using the PositionOffset property, e.g. :

    chart.Axis( StandardAxis.SecondaryX ).PositionOffset = -10;

    There is also the PredefinedPosition property that could help.

    Imported from legacy forums. Posted by André (had 290 views)

    User (Old forums)
    Member
    Post count: 23064

    No this is not the situation. My secondaryX axis placed on top of the chart. Are there any comments??

    Imported from legacy forums. Posted by Serkan (had 618 views)

    User (Old forums)
    Member
    Post count: 23064

    I looked at http://doc.xceedsoft.com/products/chartNet/doc/index.htm?page=sources/buildingwebapplications_getting_started.htm
    and followed everything except the
    14. Configure the temporary directory. For details, see the temporary file and persistent server topics in the Server Configuration book.

    and I’m currently getting the following namespace errors. Here are a few of them:
    \c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(33): The name ‘chart’ does not exist in the class or namespace ‘Bug2.WebForm1’
    c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(39): The name ‘pie’ does not exist in the class or namespace ‘Bug2.WebForm1’
    c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(34): The type or namespace name ‘chart’ could not be found (are you missing a using directive or an assembly reference?)
    c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(35): The type or namespace name ‘chart’ could not be found (are you missing a using directive or an assembly reference?)
    c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(30): The type or namespace name ‘Chart’ could not be found (are you missing a using directive or an assembly reference?)
    c:\inetpub\wwwroot\Bug2\WebForm1.aspx.cs(49): The type or namespace name ‘pie’ could not

    I added all the references like it said including the usings at the beginning of the file; however, I’m not sure exactly what is causing the errors.

    Imported from legacy forums. Posted by sgekberg (had 446 views)

    User (Old forums)
    Member
    Post count: 23064

    For Pavos :

    Did you set the following ?
    <i>
    chart.Axis( StandardAxis.SecondaryX ).Visible = true;
    chart.Axis( StandardAxis.SecondaryX ).PredefinedPosition = AxisPredefinedPosition.FrontTop;
    </i>
    You also need to set the series to use the axis
    <i>
    LineSeries.DisplayOnAxis( StandardAxis.PrimaryX, false);
    LineSeries.DisplayOnAxis( StandardAxis.SecondaryX, true );
    </i>

    For sgekberg :

    Can you send a request to <a href=”mailto:support@xceedsoft.com”>support</a> so we can look at your specific problem, for what is in the getting started page works fine (I tested it myself).

    Imported from legacy forums. Posted by André (had 10533 views)

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.