0

I have a working Highcharts bar chart with 2 series that exports to CSV correctly. I added a hidden ROUND series that should be included in the exported CSV data. Setting the includeInDataExport property to true is supposed make this happen. However, this is not working for me and I've not found an example showing how to correctly use this property.

Here are the current chart options.

{
  chart: {
    type: "bar"
    marginTop: 30
    spacingRight: 50
    style: {
      fontWeight: "400",
      fontFamily: "Montserrat"
    }
  },
  title: {
    text: ""
  }
  xAxis: {
    categories: Array(7),
    lineWidth: 1
  }
  yAxis: {
    min: 0,
    lineWidth: 1
  }
  legend: {
    reversed: true,
    itemStyle: {
    }
  }
  tooltip: {
    headerFormat: "COMPANY: {point.x}<br/>",
    pointFormat: "{series.name}: <b>${point.y}</b>"
  }
  plotOptions: {
    bar: {
      dataLabels: {
        enabled: true
      },
      includeInDataExport: true
    },
    series: {
      colorByPoint: true,
      includeInDataExport: true
    }
  }
  series: [
    {
      name: "ROUND",
      data: [
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ],
      visible: false,
      showInLegend: false
    },
    {
      name: "P2",
      data: [
        230.3,
        228.25,
        217.72,
        243.34,
        235.56,
        205.73,
        252.83
      ]
    },
    {
      name: "P1",
      data: [
        115.15,
        115.58,
        104.2,
        115.58,
        113.34,
        101.27,
        121.3
      ]
    }
  ]
}}
softweave
  • 1,455
  • 2
  • 16
  • 27
  • My motivation for wanting to export hidden series was the need to include data to the CSV that is not displayed in the chart. I was able to do this by implementing a custom CSV download using information in these stackoverflow questions on [customizing download csv functionality in highcharts](https://stackoverflow.com/questions/38482574/how-to-customize-download-csv-functionality-in-highcharts) and [export to csv using hidden CSVLink](https://stackoverflow.com/questions/48760815/export-to-csv-button-in-react-table) – softweave Mar 06 '20 at 12:34

1 Answers1

0

It seems that the current Highcharts logic doesn't allow to get CSV data from series which has visible set to false, see: https://github.com/highcharts/highcharts/blob/master/js/modules/export-data.src.js#L350

From this code, it seems like in the past someone has a purpose in it because of some bug, but I am not sure what to think about it now. If you want you can start a thread in the Highcharts Github issue channel: https://github.com/highcharts/highcharts/issues

As a workaround I suggest to use this logic just without this condition about series visibility:

Demo: https://jsfiddle.net/BlackLabel/n5za1q3x/

   this.series.forEach(function(series) {
     var keys = series.options.keys,
       pointArrayMap = keys || series.pointArrayMap || ['y'],
       valueCount = pointArrayMap.length,
       xTaken = !series.requireSorting && {},
       xAxisIndex = xAxes.indexOf(series.xAxis),
       categoryAndDatetimeMap = getCategoryAndDateTimeMap(series, pointArrayMap),
       mockSeries, j;
     if (series.options.includeInDataExport !== false &&
       !series.options.isInternal // #55
     ) {
.........
Sebastian Wędzel
  • 11,417
  • 1
  • 6
  • 16