Jump to content
Software FX Community

sample crosstab


User (Legacy)

Recommended Posts

sorry about my last message, pressed the send button before completing my 

question.

I am writing a charting DLL for another application and I have the values

which only can be accessed by iterating through it.

Series SDate Value

1004 03-Jul-01 3.4

1004 03-Jul-01 23

1004D 03-Jul-01 10.4

1005 03-Jul-01 1.3

1005 03-Jul-01 11

1006 03-Jul-01 34.2

1006 03-Jul-01 23

1010 06-Jun-01 3

1010 06-Jun-01 4.8

1011 06-Jun-01 13

1011 06-Jun-01 2.9

1012 06-Jun-01 32

1012 06-Jun-01 2

1013 06-Jun-01 3.4

1013 06-Jun-01 3.2

1014 06-Jun-01 5.2

I am trying to plot each series in the chart. I am new to VB.Net and also

chartfx, I am completly lost in setting up chartFX for it. I saw that

chartfx crosstab option. How do I set it up? Can someone point me to right

sample?.

Current CODE

´cat is the array which has unique value

For Each cat In catArray

i = 0

NFChart1.Series(j).Text = cat

Do While Not pFeature Is Nothing

NFChart1.Data.X(j, i) = pFeature.Value(Xfield)

NFChart1.Data.Y(j, i) = pFeature.Value(Yfield)

If NFChart1.AxisX.Min > pFeature.Value(Xfield) Then

NFChart1.AxisX.Min = pFeature.Value(Xfield)

End If

pFeature = pFCursor.NextFeature

i = i + 1

Loop

j = j + 1

Next

"kumar" <kumar@newfields.com> wrote in message

news:EPVAYwA7GHA.3388@webserver3.softwarefx.com...

> Is there crosstab data graphing sample?.

> - kumar

>

Link to comment
Share on other sites

This doesn't look right. Where are these values coming from? A datasource ? 

arrays ? collections ? Can you please explain a little more about your data

structure.

The crosstab provider can organize your data by pivoting on two fields, one

used for the series and one for the X-Value, in your case you want to make

the "Series" field to be your ColumnHeading and your Date field to be your

RowHeading.

The following sample shows how to read from an object array, also check the

programmer's guide, there is a whole section there for CrossTab under

"Passing Data".

public class MyCrossTabData

{

private int m_series;

private DateTime m_date;

private double m_value;

public MyCrossTabData(int series, DateTime date, double value)

{

m_series = series;

m_date = date;

m_value = value;

}

public double Value

{

get { return m_value; }

set { m_value = value; }

}

public int Series {

get { return m_series; }

set { m_series = value; }

}

public DateTime Date {

get { return m_date; }

set { m_date = value; }

}

}

private void ReadData()

{

ArrayList myArray = new ArrayList();

myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,1),10));

myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,2),20));

myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,3),70));

myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,4),80));

myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,1),30));

myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,2),60));

myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,3),45));

myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,4),75));

myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,5),30));

chart1.DataSourceSettings.Fields.Add(new

FieldMap("Series",FieldUsage.ColumnHeading));

chart1.DataSourceSettings.Fields.Add(new

FieldMap("Date",FieldUsage.RowHeading));

chart1.DataSourceSettings.Fields.Add(new

FieldMap("Value",FieldUsage.Value));

CrosstabDataProvider crossTab = new CrosstabDataProvider(new

ListProvider(myArray));

crossTab.RowHeadingSettings = RowHeadingSettings.CompressedXValues;

chart1.DataSource = crossTab;

}

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

hi Francisco,

Thanks for you help

My data is from arcGIS datatable. I use feature cursor to iterate over each record. I have my complete code below. I got it working for the crosstab, but the value is showing as integers rather than double. I have attached the image below. How do I change to plot the values properly in double.

Is there a way I can change the crosstab grid to show me a cross tab with columns as dates Example

instead of this

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

8/10/02 9/18/02 8/9/04 10/27/04 3/30/05 6/20/05 10/4/05 2/7/06

809 0 1 0 0 0 0 0 0

8/10/02 9/18/02 1/30/03 6/17/03 8/1/03 10/31/03 1/29/04 3/29/04 8/10/04 8/11/04 10/27/04 10/27/04 3/29/05 6/21/05 10/5/05 2/7/06

812 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

9/18/02 8/11/04 10/27/04 3/29/05 6/21/05 10/4/05 2/7/06

816 0 0 0 0 0 0 0

2/1/01 6/5/01

CISTERNA 6 0 0

6/29/01

CISTERNA 7 0

I want it to be displayed like this

02/01/01 06/05/01 06/29/01 08/10/02 09/18/02 01/30/03 06/17/03 08/01/03 10/31/03 01/29/04 03/29/04 08/09/04 08/10/04 08/11/04 10/27/04 03/29/05 03/30/05 06/20/05 06/21/05 10/04/05 10/05/05 02/07/06

809 0.37 0.54 0.29 0.42 0.21 0.39 0.28 0.31

812 0 0 0 0 0 0.05 0.17 0.02 0 0 0 0.21 0 0 0

816 0 0.021 0.024 0 0.029 0.032 0.012

CISTERNA 6 0.47 0

CISTERNA 7 0.39

Thanks for your help.

- kumar

Current Code

Private Sub iterate_chart()

Dim Doc As IMxDocument

Dim pFLayer As IFeatureLayer

Dim pFCursor As IFeatureCursor

Dim QFilter As IQueryFilter

QFilter = Nothing

Doc = m_app.Document

pFLayer = m_colLayers.Item(CStr(cmbLayer.SelectedIndex))

pFCursor = pFLayer.Search(QFilter, False)

Dim xField As Integer

Dim yField As Integer

Dim catField As Integer

Dim pFClass As IFeatureClass

pFClass = pFLayer.FeatureClass

xField = pFClass.FindField(cmbXfield.SelectedItem.ToString)

yField = pFClass.FindField(cmbYfield.SelectedItem.ToString)

catField = pFClass.FindField(cmbCategory.SelectedItem.ToString)

pFeature = pFCursor.NextFeature

Dim myArray As ArrayList = New ArrayList

Do While Not pFeature Is Nothing

myArray.Add(New MyCrossTabData(pFeature.Value(catField), pFeature.Value(xField), pFeature.Value(yField)))

Loop

NFChart1.DataSourceSettings.Fields.Add(New FieldMap("catVal", FieldUsage.ColumnHeading))

NFChart1.DataSourceSettings.Fields.Add(New FieldMap("sdate", FieldUsage.RowHeading))

NFChart1.DataSourceSettings.Fields.Add(New FieldMap("value", FieldUsage.Value))

Dim crossTab As CrosstabDataProvider = New CrosstabDataProvider(New ListProvider(myArray))

crossTab.RowHeadingSettings = RowHeadingSettings.CompressedXValues

NFChart1.DataSource = crossTab

End Sub

End Class

Public Class MyCrossTabData

Private m_catVal As String

Private m_date As Date

Private m_value As Double

Public Sub New(ByVal catVal As String, ByVal sdate As date, ByVal value As Double)

m_catVal = catVal

m_date = sdate

m_value = value

End Sub

Public Property Value() As Double

Get

Return m_value

End Get

Set(ByVal value As Double)

m_value = value

End Set

End Property

Public Property catVal() As String

Get

Return m_catVal

End Get

Set(ByVal value As String)

m_catVal = value

End Set

End Property

Public Property sDate() As date

Get

Return m_date

End Get

Set(ByVal value As Date)

m_date = value

End Set

End Property

End Class

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message news:<I7D8LUH7GHA.3388@webserver3.softwarefx.com>...

> This doesn´t look right. Where are these values coming from? A datasource ?

> arrays ? collections ? Can you please explain a little more about your data

> structure.

>

> The crosstab provider can organize your data by pivoting on two fields, one

> used for the series and one for the X-Value, in your case you want to make

> the "Series" field to be your ColumnHeading and your Date field to be your

> RowHeading.

>

> The following sample shows how to read from an object array, also check the

> programmer´s guide, there is a whole section there for CrossTab under

> "Passing Data".

>

> public class MyCrossTabData

>

> {

>

> private int m_series;

>

> private DateTime m_date;

>

> private double m_value;

>

> public MyCrossTabData(int series, DateTime date, double value)

>

> {

>

> m_series = series;

>

> m_date = date;

>

> m_value = value;

>

> }

>

> public double Value

>

> {

>

> get { return m_value; }

>

> set { m_value = value; }

>

> }

>

>

>

> public int Series {

>

> get { return m_series; }

>

> set { m_series = value; }

>

> }

>

> public DateTime Date {

>

> get { return m_date; }

>

> set { m_date = value; }

>

> }

>

> }

>

> private void ReadData()

>

> {

>

> ArrayList myArray = new ArrayList();

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,1),10));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,2),20));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,3),70));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,4),80));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,1),30));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,2),60));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,3),45));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,4),75));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,5),30));

>

>

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Series",FieldUsage.ColumnHeading));

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Date",FieldUsage.RowHeading));

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Value",FieldUsage.Value));

>

> CrosstabDataProvider crossTab = new CrosstabDataProvider(new

> ListProvider(myArray));

>

> crossTab.RowHeadingSettings = RowHeadingSettings.CompressedXValues;

>

> chart1.DataSource = crossTab;

>

> }

>

>

> --

> Francisco Padron

> www.chartfx.com

>

>

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message news:I7D8LUH7GHA.3388@webserver3.softwarefx.com...

> This doesn´t look right. Where are these values coming from? A datasource ?

> arrays ? collections ? Can you please explain a little more about your data

> structure.

>

> The crosstab provider can organize your data by pivoting on two fields, one

> used for the series and one for the X-Value, in your case you want to make

> the "Series" field to be your ColumnHeading and your Date field to be your

> RowHeading.

>

> The following sample shows how to read from an object array, also check the

> programmer´s guide, there is a whole section there for CrossTab under

> "Passing Data".

>

> public class MyCrossTabData

>

> {

>

> private int m_series;

>

> private DateTime m_date;

>

> private double m_value;

>

> public MyCrossTabData(int series, DateTime date, double value)

>

> {

>

> m_series = series;

>

> m_date = date;

>

> m_value = value;

>

> }

>

> public double Value

>

> {

>

> get { return m_value; }

>

> set { m_value = value; }

>

> }

>

>

>

> public int Series {

>

> get { return m_series; }

>

> set { m_series = value; }

>

> }

>

> public DateTime Date {

>

> get { return m_date; }

>

> set { m_date = value; }

>

> }

>

> }

>

> private void ReadData()

>

> {

>

> ArrayList myArray = new ArrayList();

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,1),10));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,2),20));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,3),70));

>

> myArray.Add(new MyCrossTabData(1004,new DateTime(2006,1,4),80));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,1),30));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,2),60));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,3),45));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,4),75));

>

> myArray.Add(new MyCrossTabData(1005,new DateTime(2006,1,5),30));

>

>

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Series",FieldUsage.ColumnHeading));

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Date",FieldUsage.RowHeading));

>

> chart1.DataSourceSettings.Fields.Add(new

> FieldMap("Value",FieldUsage.Value));

>

> CrosstabDataProvider crossTab = new CrosstabDataProvider(new

> ListProvider(myArray));

>

> crossTab.RowHeadingSettings = RowHeadingSettings.CompressedXValues;

>

> chart1.DataSource = crossTab;

>

> }

>

>

> --

> Francisco Padron

> www.chartfx.com

>

>

Link to comment
Share on other sites

Yes almost there, except for one the arrangement of the table. Currently the table shows like this 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

8/10/02 9/18/02 8/9/04 10/27/04 3/30/05 6/20/05 10/4/05 2/7/06

809 0 1 0 0 0 0 0 0

8/10/02 9/18/02 1/30/03 6/17/03 8/1/03 10/31/03 1/29/04 3/29/04 8/10/04 8/11/04 10/27/04 10/27/04 3/29/05 6/21/05 10/5/05 2/7/06

812 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

9/18/02 8/11/04 10/27/04 3/29/05 6/21/05 10/4/05 2/7/06

816 0 0 0 0 0 0 0

2/1/01 6/5/01

CISTERNA 6 0 0

6/29/01

CISTERNA 7 0

I want to be displayed like this.

02/01/01 06/05/01 06/29/01 08/10/02 09/18/02 01/30/03 06/17/03 08/01/03 10/31/03 01/29/04 03/29/04 08/09/04 08/10/04 08/11/04 10/27/04 03/29/05 03/30/05 06/20/05 06/21/05 10/04/05 10/05/05 02/07/06

809 0.37 0.54 0.29 0.42 0.21 0.39 0.28 0.31

812 0 0 0 0 0 0.05 0.17 0.02 0 0 0 0.21 0 0 0

816 0 0.021 0.024 0 0.029 0.032 0.012

CISTERNA 6 0.47 0

CISTERNA 7 0.39

Thanks a lot for your help.

- kumar

Current Code

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message news:cRFwTiL7GHA.3388@webserver3.softwarefx.com...

You are almost there !

Add this:

chart.AxisY.LabelsFormat.Decimals = 2;

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

As you can see, the dates are NOT the same for all series so they need to be displayed separately.

You can hide the DataGrid header (1,2,3, ..) by doing:

chart.DataGrid.ShowHeader = false;

You are not going to get this chart with that datagrid, they simply don't match. The Datagrid you want would correspond to a chart with hidden values for lots of dates which would result in gaps in the line.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...