Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to change title in a chart

  1. #1

    Default Answered: How to change title in a chart

    Hello,

    I am new with extjs 6.5. I try to dynamically change or in fact to set the title of a chart. It depends on the age of the user, which title has to be used. My code is

    xtype: 'chart',
    id: 'evalChart',
    renderTo: document.body,
    width: '95%',
    height: '95%',
    captions: {
    title: 'This is the title I want to change',
    credits: 'And if you have an idea, I would like to change this text too'
    },

    my app is showing the title and credits. But I don't find any way to change the title. Please help.

    Thank you!

  2. I suspect a bug.

    Hijacked someone else's fiddle to get an example chart

    https://fiddle.sencha.com/#view/editor&fiddle/27cg

    To use binding you need to have an initial caption set (not specified in documentation), however updating the caption via the viewmodel results in the caption not appearing where you'd expect it to.

    It does appear to work with just the title set up in viewmodel though.

  3. #2

    Default

    No one has any idea?

  4. #3
    Sencha Premium Member
    Join Date
    Feb 2016
    Posts
    51
    Answers
    1

    Default

    Have a look at using binding and viewmodels. Your title and credits would likely use a formula, though if it's just a simple 'this is a title for someone ' x ' years old' then I think this can be done with a straight bind to the value

  5. #4

    Default

    Hey Matt,

    thanks for that idea. I liked it, but sadly can't make it work :-(. It is working perfectly fine for example if I try it with a toolbar. But the title won't appear in the chart at all. I tried the following three ways:

    1. try:

    bind: {
    captions :{
    title :{
    bindTo: '{chartTitle}',
    deep: true
    }
    }
    },

    2.try:


    captions :{
    bind: {
    title :{
    bindTo: '{chartTitle}',
    deep: true
    }
    }
    },

    3. try:

    captions :{
    bind: {
    title: '{chartTitle}'
    }
    },



    But sadly the title didn't appear in the chart. Any idea what is wrong in my code or way to do it?

  6. #5
    Sencha User
    Join Date
    Jun 2017
    Posts
    13
    Answers
    3

    Default

    What if you tried changing example 1 to

    Code:
    captions: {
          title: {
              bind: {
                   text: '{chartTitle}'
              }
          }
    }

  7. #6
    Sencha Premium Member
    Join Date
    Feb 2016
    Posts
    51
    Answers
    1

    Default

    If drollo's example doesn't work, then try using a formula to return an entire captions object config.

    I.e.
    Code:
        formulas: {
        getChartCaption: function(get) {
            return {
                title: get('chartTitle'),
                credits: get('chartCredits')
            }
        }
        }
    
    bind: {captions: '{getChartCaption}'}

  8. #7

    Default

    Sadly this one gives an Error: "Uncaught TypeError: Cannot set property 'title' of null"

    at ctor.applyCaptions (app.js?_dc=20170926112718:1)
    at ctor.b [as setCaptions] (app.js?_dc=20170926112718:1)
    at ctor.onBindNotify (app.js?_dc=20170926112718:1)
    at ctor.notify (app.js?_dc=20170926112718:1)
    at ctor.react (app.js?_dc=20170926112718:1)
    at ctor.notify (app.js?_dc=20170926112718:1)
    at ctor.onTick (app.js?_dc=20170926112718:1)
    at app.js?_dc=20170926112718:1
    at Object.elevate (app.js?_dc=20170926112718:1)
    at c (app.js?_dc=20170926112718:1)

    Therefor I also tried:

    captions: { bind: '{getChartCaption}'}, => nothing appeared but also no Error

    captions: { bindTo: '{getChartCaption}', deep: true }, => {getChartCaption} appeard, not the string I was hoping for but really just '{getChartCaption}'. At least also no error, but still not the title I need and no credits
    captions: { bindTo: '{getChartCaption}'}, => same result. It was just shown the '{getChartCaption}' and not 'Example of the title I want to have - Age 59'

    Unbenannt.jpg

  9. #8

    Default

    Still nothing is shown as the title :-(

  10. #9

    Default

    @ drollo96: Still nothing is shown as the title :-(

  11. #10
    Sencha Premium Member
    Join Date
    Feb 2016
    Posts
    51
    Answers
    1

    Default

    I suspect a bug.

    Hijacked someone else's fiddle to get an example chart

    https://fiddle.sencha.com/#view/editor&fiddle/27cg

    To use binding you need to have an initial caption set (not specified in documentation), however updating the caption via the viewmodel results in the caption not appearing where you'd expect it to.

    It does appear to work with just the title set up in viewmodel though.

Page 1 of 2 12 LastLast

Similar Threads

  1. change the title of chart image
    By nostalgieing in forum Ext: Q&A
    Replies: 1
    Last Post: 5 Nov 2012, 6:02 AM
  2. Change title of Ext.chart.interactions.ItemInfo
    By fozzy83 in forum Sencha Touch 1.x: Charts
    Replies: 2
    Last Post: 2 Feb 2012, 5:45 AM
  3. Dynamically Change Chart Axis Title
    By jkraft04 in forum Ext: Q&A
    Replies: 3
    Last Post: 7 Oct 2011, 12:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •