Welcome to the Xceed Community | Help
Community Search  

Chart and multi data source

Page 1 of 2 (22 items)   1 2 Next >
Sort Posts: Previous Next
  •  11-02-2008, 9:22 AM Post no. 16559

    Chart and multi data source

    Hi

    I have a list of dataview as the datasource of the chart.

    this is my code

    'bind data to the chart
    Dim arrCollumns As String() = {"Value", "DateTime"} 'first column is number the second is datetime. 
    ' disable automatic labels
    chart.Axis(StandardAxis.PrimaryX).ScaleMode = AxisScaleMode.DateTime
    chart.Axis(StandardAxis.PrimaryX).ValueFormatting.Format = ValueFormat.Date
    chart.Axis(StandardAxis.PrimaryX).StaggerTexts = True 

    For i As Integer = 0 To List.Count - 1
    Dim dv As DataView = List.Item(i).View
    Dim line As LineSeries = CType(chart.Series.Add(SeriesType.Line), LineSeries)
    Dim arrSeries As New DataSeriesCollection
    arrSeries.Add(line.Values)
    arrSeries.Add(line.Labels)
    arrSeries.FillFromDataView(dv, arrCollumns)
    Next

    Chrt.Refresh()

    The chart display correctly

    1.on the Axis I saw dates from 1899 to 1900 if I disable the automin\automax and set the  DateTimeScale.Max\Min the chart is disappear.

    2.Is there any way to give each line in the chart a different color automatically without set the LineBorder.Color property.

    3.In the mouse down event I can know the X,Y how can I know the data values in this location.

    10x Nadav

  •  11-03-2008, 3:20 PM Post no. 16597 in reply to 16559

    Re: Chart and multi data source

    1- You need to set the line series to use the XValues :

            line.UseXValues = true;

    2- No.  The only solution I see is to use a random number and use it to generate a random color :

            Random random = new Random();

            line.LineBorder.Color = Color.FromArgb( random.Next() )

    3- Use the HitTest method :

            HitTestResult hit = chartControl1.HitTest( e.X, e.Y );

            LineSeries tempSerieHit = hit.Series as LineSeries;

            if( tempSerieHit != null )

            {

                int dataPoint = hit.DataPointIndex;

            }

    Note that a good source of code, in order to find out how to do different things with the Chart, is our Chart Explorer.  Go to the Start Menu -> All Programs -> Xceed Components -> Our components in action! -> Xceed Chart Explorer for .NET.

    For example, you can go to All Examples -> Interactivity -> Mouse Events.  You can look at the code by clicking on the "C# Code" tab.  You will also find the complete source code of the explorer here :

    Under XP :

        C:\Program Files\Xceed Components\Xceed Chart for .NET and ASP.NET <version>\Samples

    Under Vista :

        C:\Xceed Component Samples\Xceed Chart for .NET <version>\Samples under Vista.


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-05-2008, 3:23 AM Post no. 16652 in reply to 16597

    Re: Chart and multi data source

    Hi.

    Thanks for your answers.

    When I use the  line.UseXValues = true the drawing chart is empty.What can I do?

    10x Nadav

  •  11-05-2008, 3:25 PM Post no. 16679 in reply to 16652

    Re: Chart and multi data source

    You need to use the XValues series instead of the Label series when setting the DataSeriesCollection :

    arrSeries.Add(line.XValues) instead of arrSeries.Add(line.Labels)

    However, this will work only if the dates in the DB are of OADate type, because this is the only DateTime type accepted by the chart.  If this is not the case, you will need to feed the data manually to the chart, getting the data from the DB, then transforming each date value using the OADate() method on DateTime.


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-06-2008, 2:22 AM Post no. 16691 in reply to 16679

    Re: Chart and multi data source

    Hi.

    thanks for your replay but on the Axis I saw dates from 1899 to 1900 .

    ?

  •  11-06-2008, 2:23 PM Post no. 16713 in reply to 16691

    Re: Chart and multi data source

    Can you paste the code snippet you are now using, along with a sample of the values you use to feed the chart?

    Are you still binding the chart to the DB?  If so, what type is use for the date column?

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-09-2008, 4:22 AM Post no. 16744 in reply to 16713

    Re: Chart and multi data source

    The type of the column is double.

    here is my code:

    Dim chart As Xceed.Chart.Core.Chart = Chrt.Charts(0)
    Try

    'bind data to the chart
    Dim arrCollumns As String() = {fldOMLogValue, fldOMLogDateTime & "Number"}

    ' disable automatic labels
    chart.Axis(StandardAxis.PrimaryX).ScaleMode = AxisScaleMode.DateTime
    chart.Axis(StandardAxis.PrimaryX).ValueFormatting.Format = ValueFormat.Date
    chart.Axis(StandardAxis.PrimaryX).StaggerTexts = True

     

    For i As Integer = 0 To List.Count - 1
    Dim dv As DataView = List.Item(i).View
    dv.RowFilter = IIF_Generic(btnIgnoreZeroValues.Checked, RowFilter, Nothing)
    Dim line As LineSeries = CType(chart.Series.Add(SeriesType.Line), LineSeries)
    Dim arrSeries As New DataSeriesCollection

    arrSeries.Add(line.Values)
    arrSeries.Add(line.XValues)
    arrSeries.FillFromDataView(dv, arrCollumns)
    line.LineBorder.Color = GetLineColor(i + 1)
    line.LineBorder.Width = 3
    line.Name = List(i).OMName & "( " & List(i).ServerName & " )"
    line.DataLabels.Mode = DataLabelsMode.None
    Next
    Chrt.Refresh()
    Catch ex As Exception
    AG.HandleException(ex)
    End Try

     

    I'll try to send you a demo project.

    Thanks Nadav

  •  11-10-2008, 12:21 PM Post no. 16763 in reply to 16744

    Re: Chart and multi data source

    If you are saying that the date column data type in your DataView is a double, this will not work.  Again, the values used on this axis when the ScaleMode is set to DateTime mus be of OADate type.

    LineSeries line = ( LineSeries )chart.Series.Add( SeriesType.Line );

    line.UseXValues = true;

    chart.Axis( StandardAxis.PrimaryX ).ScaleMode = AxisScaleMode.DateTime;

    line.AddXY( 25, new DateTime( 2008, 1, 1 ).ToOADate() );

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-11-2008, 2:36 AM Post no. 16775 in reply to 16763

    Re: Chart and multi data source

    1.The datatype of OAdate is double.

    2.I'm trying to avoid using the addXY I want to use the FillFromDataView.

  •  11-11-2008, 12:50 PM Post no. 16790 in reply to 16775

    Re: Chart and multi data source

    This should work, but the values in the date column must be proper double values. How did you build these values?  Do you have a few date values from your double column you could paste here? 


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-12-2008, 5:28 AM Post no. 16804 in reply to 16790

    Re: Chart and multi data source

    Here are the values 

    Y      X 

    2       39441.5021875

    4        39441.6130439815

    3        39441.7710648148

    2        39474.724375

    1       39475.5376851852

    Tthanks Nadav

  •  11-12-2008, 2:39 PM Post no. 16831 in reply to 16804

    Re: Chart and multi data source

    These values work fine here in a DB.  I'm not sure what could be the problem.  Here is the code I'm using to do this :

    Chart chart =  chartControl1.Charts[ 0 ];

    LineSeries line = ( LineSeries )chart.Series.Add( SeriesType.Line );

    chart.Axis( StandardAxis.PrimaryX ).ScaleMode = AxisScaleMode.DateTime;

    chart.Axis( StandardAxis.PrimaryX ).ValueFormatting.Format = ValueFormat.Date;

    chart.Axis( StandardAxis.PrimaryX ).StaggerLevels = 3;

    chart.Axis( StandardAxis.PrimaryX ).StaggerTexts = true;

    line.UseXValues = true;

    DataSeriesCollection seriesCollection = line.GetDataSeries( DataSeriesMask.Values | DataSeriesMask.XValues, DataSeriesMask.None, false );

    string[] columnsCollection = { "EmployeeID", "BirthOADate" };

    OleDbConnection myConnection = new OleDbConnection( @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ProgramData\Xceed Software\Sample Data\Northwind - Copy.mdb" );

    OleDbCommand myCommand = new OleDbCommand( "select * from Employees", myConnection );

    myCommand.Connection.Open();

    OleDbDataReader myReader = myCommand.ExecuteReader( CommandBehavior.CloseConnection );

    seriesCollection.FillFromDataReader( myReader, columnsCollection ); 

     

    I suggest you try the same code to see if it works on your side.  If it does, then integrate line by line the other things you are setting in your current project, until you get the behavior where it does not work, so as to identify the source of the problem.

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-16-2008, 10:06 AM Post no. 16913 in reply to 16831

    Re: Chart and multi data source

    Thanks.

    I have some more questions.

    1.Is there any option in linelabels to avoid some of the values for example the values are 4,5,0,0,3,0,6,7,0 and I want to show only the labels only when the value > 0.(Ignore this question I use the subset)

    2.Is there any way to assign to the line datalabel into the Axis label ..

    3.I want to write the dates to the Axis  and ignore the data(usexvalues = false)

    Thanks Nadav.

  •  11-17-2008, 12:05 PM Post no. 16941 in reply to 16913

    Re: Chart and multi data source

    2- Don't understand your question. 

    3- Simply use your DateTime values and add them to the Labels collection of the axis.

    e.g.:

    DateTime dateTime = DateTime.FromOADate( 39441.6130439815 );

    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( dateTime.ToString() );

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-25-2008, 3:14 AM Post no. 17137 in reply to 16941

    Re: Chart and multi data source

    What I can do in case I want to use the barseries the barseries inherits from series and he dosen't support the usexvalues.
Page 1 of 2 (22 items)   1 2 Next >
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.