Search code examples
javascriptjquerychartshighchartsspline

Highcharts areaspline, not getting the default color for chart


I am creating an areaspline highcharts. As I am not setting any color it should default to the default blue. For me its automatically filling with rgba(247, 163, 92, 0.75);. Why is that happening. How can I get the default darker blue on the top border and the default blue inside the areaspline.

Here is my code:

    let series_vals = [];
    let data_array = [];
    let val_array = [];
    for (let i = 0; i <= 15 i++) {
        series_trend.push("series_trend" + i);
        data_array.push([]);
        val_array.push(val);
    }
    let series = [];

    series_vals.forEach((name, index) => {
        series.push({
            val_array: val_array[index],
            data: data_array[index],
        })
    });

    $.getJSON(json, result => {
        series.forEach(obj => {
            result.forEach((elem, i, array) => {
                if (elem.val === obj.val) {
                    obj.data.push({
                        x: elem.date,
                        y: elem.xyz,
                    });
                }
            });
        });
        Highcharts.chart(target, {
            chart: {
                height: 100,
                width: 300,
                type: 'areaspline',
            },
            title: {
                text: ''
            },
            credits: {
                enabled: false
            },
            legend: {
                enabled: false
            },
            xAxis: {
                visible: false
            },
            yAxis: {
                visible: false
            },
            tooltip: {
                formatter: function() {
                    let date_format = (filter == 'day') ? moment(this.key).format('MMM DD, YYYY') : moment(this.key).format('MMM YYYY');
                    let tooltip = `
                    <span style="font-weight:500;">${date_format}</span>
                    <br />
                    <span>${this.y}</span>
             `;
                    return tooltip;
                },
                useHTML: true
            },
            plotOptions: {
                series: {
                    fillColor: null,
                    marker: {
                        enabled: false,
                        symbol: 'circle'
                    }
                }
            },
            series: series
        });
    });

By default this is the color I am getting: areaspline.

Is there anyway I can change it to the default?


Solution

  • You can set area color by setting these options:

      plotOptions: {
        areaspline: {
          fillColor: 'rgba(123, 181, 236, 0.7)',
          lineColor: '#7BB5EC',
          marker: {
            fillColor: '#7BB5EC'
          }
        }
      }
    

    Demo: