javascript - Update title dynamically on Apexcharts - Stack Overflow

I am using Updateseries to update x and y axis. How can i update title?$.getJSON('chartData.php�

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 '
  })  

 });

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 '
  })  

 });
Share Improve this question edited Jan 2, 2020 at 7:07 asked Dec 31, 2019 at 7:54 user12510360user12510360 2
  • 1 Ok I used: $(".apexcharts-title-text").text("lel") – user12510360 Commented Dec 31, 2019 at 8:14
  • The above method is not remended as it will be wiped off on the next render. Try resizing your browser and you'll see it goes back to original. Please refer to my answer below. – junedchhipa Commented Dec 31, 2019 at 20:24
Add a ment  | 

2 Answers 2

Reset to default 3

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./docs/methods/#updateOptions

this code can update the title in the chart.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744302565a4567570.html

相关推荐

  • javascript - Update title dynamically on Apexcharts - Stack Overflow

    I am using Updateseries to update x and y axis. How can i update title?$.getJSON('chartData.php�

    7天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信