user12510360
user12510360

Reputation:

Update title dynamically on Apexcharts

I am using Updateseries to update x and y axis. How can i update title?

$.getJSON('chartData.php', {
    devicename: feature.get('id')
}, (response) => {
    chart.updateSeries([{
        data: response
    }])

    let chart = new ApexCharts(document.getElementById("chart"), options)
    chart.updateOptions({
    title: 'Water Consumption per day on December 2019 for '
  })  

 });

Upvotes: 2

Views: 15343

Answers (2)

junedchhipa
junedchhipa

Reputation: 5627

You should use the updateOptions method of ApexCharts to update any other configuration.

updateSeries only deals with data of the chart, while updateOptions allows changing the configuration of the chart dynamically

var chart = new ApexCharts(el, options);

chart.updateOptions({
  title: {
    text: 'new title'
  }
})

Docs for updateOptions - https://apexcharts.com/docs/methods/#updateOptions

Upvotes: 3

Dakshina
Dakshina

Reputation: 75

this code can update the title in the chart.

*ApexCharts.exec('id', "updateOptions", {*
        title:{
            text:title1
        }
    });

Upvotes: 0

Related Questions