Jump to content
Software FX Community

pixel3cs

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by pixel3cs

  1. I have tried all of this but the problem still exists. Look what i am trying to do.

    public partial class LineChartControl : UserControl   {   public LineChartControl(DataTable dataTable)   {   InitializeComponent();   for (int r = 0; r < dataTable.Rows.Count; r++)   {   ChartFX.WPF.SeriesAttributes series = new ChartFX.WPF.SeriesAttributes();   series.BindingPath = "NumericData";   series.AxisX = new ChartFX.WPF.Axis();   series.AxisY = new ChartFX.WPF.Axis();   chart.Series.Add(series);   }     chart.ItemsSource = dataTable.Rows;   // dataTable.Rows[0].NumericData is an array of Double elements   }   } 

    So one line for each row and not for a column. The DataTable is not the one from System.Data, is own defined, but implements the IEnumerable interface.

    Is there another way to program the graph to draw each row as a line and not use SeriesAttributes?

  2.   ChartFX.WPF.Chart chart = new ChartFX.WPF.Chart();   chart.Gallery = ChartFX.WPF.Gallery.Line;   chart.PointCount = dataTable.NumericDataLength;   ChartFX.WPF.SeriesAttributes series = new ChartFX.WPF.SeriesAttributes();   series.BindingPath = "NumericData";   series.Marker.Size = dataTable.NumericDataLength;    

            chart.Series.Add(series);// error, object not set to an instance of an object, why?

      chart.ItemsSource = dataTable;   grid.Children.Add(chart);

     

    I am using this in XBAP but should be no problem. Please help. 

  3. I use this code to initialize a Chart. If i don't add the chart as a control will compile and run ok, but if i try to put the chart as a control in my app this code will thrown an exception saying "Object not set to an instance of an object". What i am doing wrong? This is because my chart control is not initialized correct. Please help.

      if (clvi.LabelContent == "Histogram" && tablesListBox.SelectedIndex >= 0)
      {  
      // get the selected table
      DataTable selectedDataTable = tablesListBox.Items[tablesListBox.SelectedIndex] as DataTable;

      // create the chart control
      ChartFX.WPF.Chart chart = new ChartFX.WPF.Chart();
      chart.ItemsSource = null;
      chart.Series.Clear();
      chart.AxesY.Clear();
      chart.MultiPanes = true;

      // calculate the histogram data
      Histogram histogram = new Histogram(selectedDataTable, Properties.Settings.Default.HistogramBars);
     
      // add the histogram data to the chart
      //DataTemplate seriesTemplate = (DataTemplate)FindResource("NewBar2");
      for (int seriesIndex = 0; seriesIndex < histogram.Charts.Length; seriesIndex++)
      {
      ChartFX.WPF.Axis axisY = new ChartFX.WPF.Axis();
      chart.AxesY.Add(axisY);
      axisY.LabelFormat.Decimals = 2;

      ChartFX.WPF.SeriesAttributes series = new ChartFX.WPF.SeriesAttributes();
      series.Template = new DataTemplate();
      series.BindingPath = "Charts";
      series.AxisY = axisY;
      chart.Series.Add(series);
      }
      chart.ItemsSource = histogram.Charts;

      // add the chart to the tab control
      ti.Content = chart;//if i comment this line the error will not be thrown
      }

     

×
×
  • Create New...