App: allow users to dynamically create their own charts.

Posted by: seesee on 8 September 2017, 1:47 pm EST

  • Posted 8 September 2017, 1:47 pm EST

    Hello I am working on a project that allow users to create their own charts using farpoint.

     It is something like a wizard that allow users to create 1 dimension and 2 dimension charts just by click and merging like in an excel sheet.

     is there any good example with regards to storing the data for retrieval and validating the charts users have created.

     Seesee

     

  • Replied 8 September 2017, 1:47 pm EST

    Seesee,


    There are not any examples showing how to work with charting in the Spread control.

  • Replied 8 September 2017, 1:47 pm EST

    Stay tuned.....

  • Replied 8 September 2017, 1:47 pm EST

    you mean after so long in the market this has not be done before?

    or there is just no available example online?
  • Replied 8 September 2017, 1:47 pm EST

    Hello,


    There are not any samples that I am aware of. When Kevin stated to stay tune, he was talking about the release of version 5 coming soon. In this version, we will have charting integrated with the FarPoint Spread.


    For now, there are many ways you can get the data you want out of the Spread to give to another charting control. I demoed a sample using a selected range from the Spread as a DataSource for another 3rd party chart product using the SpreadDataView object.


          MyChart newChart = new MyChart();
          SheetView sheetView = fpSpread1.ActiveSheet;
          CellRange cellRange = sheetView != null ? sheetView.GetSelection(0) : null;
          if( cellRange != null )
          {
           FarPoint.Win.Spread.Data.DefaultSpreadDataViewMapper mapper = new FarPoint.Win.Spread.Data.DefaultSpreadDataViewMapper();
           FarPoint.Win.Spread.Data.SpreadDataView spreadDataView = new FarPoint.Win.Spread.Data.SpreadDataView(fpSpread1, sheetView.SheetName);
           Type type;
           object value;


           for (int c = cellRange.Column; c < cellRange.Column + cellRange.ColumnCount; c++)
           {
            type = null;
            for (int r = cellRange.Row; r < cellRange.Row + cellRange.RowCount; r++)
            {
             value = sheetView.GetValue(r, c);
             if (type == null && value != null)
              type = value.GetType();
             else if (type != null && value != null && !type.Equals(value.GetType()))
             {
              type = typeof(string);
              break;
             }
            }
            if (type == null)
             type = typeof(string);
            spreadDataView.Columns.Add(new FarPoint.Win.Spread.Data.SpreadDataColumn(sheetView.GetColumnLabel(0, c), type));
           }
           mapper.CellRange = cellRange;
           spreadDataView.Mapper = mapper;
           newChart.DataSource = spreadDataView;
           newChart.Name = "Chart" + (++nChart).ToString();
           Controls.Add(newChart);
           newChart.SetBounds(0, 0, 200, 100);
           newChart.Visible = true;
           sheetView.AddControl(newChart);
           fpSpread1.AllowChildControlDesign = true;
          }
         }

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels