Applying Chart Filters Using Essential XlsIO

 

Excel 2013 provides a rich set of charting capabilities such as chart recommendations, combo charts, and chart polishing. With chart polishing, Microsoft has provided quick access to common operations like adding or removing various chart elements, chart styles, and chart filters.

Chart filters allow you to easily add or remove categories and series from a chart. Sometimes extraneous data is accidentally included in a chart; chart filters can be used to present only the relevant content.

clip_image002

Figure 1 - Chart filtering option in MS Excel 2013

In our Essential Studio 2012, Volume 4 release, we added a chart filter option in Essential XlsIO. This filter can be applied to chart categories and series by setting the IsFiltered property of the interfaces IChartCategory and IChartSerie.

The following code snippet illustrates how to apply chart filters using Essential XlsIO.

//The first worksheet object in the worksheet’s collection is accessed.
 IWorksheet worksheet = workbook.Worksheets[0];
 //Chart accessed from the worksheet.          
  IChart chart= worksheet.Charts[0];
 //Apply the category filter.
  string[] categorieNames = { "QUARTER 1", "QUARTER 3" };
  foreach (string categoryName in categorieNames)
  {
     chart.Categories[categoryName].IsFiltered = true;
   }

   //Apply the series filter.
   string[] serieNames = { "Saddle Bags", "Tires", "Rear Sprockets" };
   foreach (string serieName in serieNames)
   {
    chart.Series[serieName].IsFiltered = true;
   }

For a sample on using chart filters, please follow this link: http://www.syncfusion.com/downloads/Support/DirectTrac/12345/XlsIO_ChartFilters-1423402098.zip

 

- XlsIO Team

Loading