1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    24
    Vote Rating
    0
    mgtneven is an unknown quantity at this point

      0  

    Default Unanswered: Dynamic chart theming

    Unanswered: Dynamic chart theming


    Hi,

    I'm a new developer in JavaScript, and extjs framework.

    I have several custom themes , and want to apply them to column chart, according to the number of series that shown in the chart.

    It means that if I have 3 series- I need to match Theme-Three, and if I have 7 series- I need to match Theme-Seven.

    Any idea how can I do that?

    Thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You will need to create different Ext.chart.theme.Theme for each and then set the theme property on the chart when you create it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    Here's a terse example of how to easily extend the Base theme:


    Code:
    // Custom colors, where it's assumed there will be four (or less) bars/columns on your chart.
    var myColors = ['#000000', '#0000ee', '#dd0000', '#00cc00'];
    
    
    // Extend the Base theme, using your custom colors
    Ext.chart.theme.MyTheme = Ext.extend(Ext.chart.theme.Base,  {
      constructor: function(config) {
        Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
          seriesThemes: myColors,
          colors: myColors
        }, config));
      }
    });

    To instruct a chart to use your custom theme:


    Code:
    Ext.create('Ext.chart.Chart', {
      theme: 'MyTheme',
      ...
    });

    If your chart's 'series' config uses multiple data points (as illustrated below), the custom colors will be used for each bar/column drawn for each data point, based on ordinal position (i.e., the first custom color will be used for the first data point, the second color for the second data point, and so on).


    Code:
    series: [{
      type: 'column',
      axis: 'left',
      highlight: true,
      xField: 'category',
      yField: ['data1', 'data2', 'data3', 'data4'],
      title:  ['Data 1', 'Data 2', 'Data 3', 'Data 4']
    }]

  4. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    24
    Vote Rating
    0
    mgtneven is an unknown quantity at this point

      0  

    Default


    Hi,

    Thanks for your quick reply, but I think you didn't understand me.

    I've made my custom themes (not one theme)-to use in different cases.

    My question now is how can I know which theme I have to put according to the number of series?

    For example: If I have
    yField: ['data1'],
    than I need to match the theme:
    theme: 'ColumnTheme1',

    but if I have
    yField: ['data1','data2','data3','data4','data5','data6','data7'],
    than I need to match the theme:
    theme: 'ColumnTheme7',


    and so on. The number of the fields in yField can be 1-7.

    Many thanks.

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Get the length of the array and append that to 'ColumnTheme'
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    24
    Vote Rating
    0
    mgtneven is an unknown quantity at this point

      0  

    Default


    Thanks for the reply.

    Now- I have to use just one theme- but I need to change the colors ,based on the series number.

    Colors for chart series is determined by the chart base color provided in the theme defaults. Default base color is then used to calculate the colors for other series as needed. These calculations are based on dividing the hue value by the number of series colors needed. Saturation and lightness values are not changed.

    My base color is: HSL: Hue=210deg; Saturation=43%; Lightness=55% , HEX: # 5588BB

    For multi series charts the hue value (0 – 360 deg) will be divided by the number of required series distributing the colors across the spectrum.

    For example:

    3 series chart: 360/3=120, so:
    base heu is: 210deg.
    slice 2: H210+120deg= H300.
    slice 3: H300+120deg=H90.

    7 series chart: 360/7=~52, so:
    base heu is: 210deg.
    slice 2:H210+52deg=H262.
    slice 2:H262+52deg=H314.
    slice 2:H314+52deg=H6.
    slice 2:H6+52deg=H58.
    slice 2:H58+52deg=H110.
    slice 2:H110+52deg=H162.

    and so on...

    It is not simple, I know.

    Any idea? it will be helpful!!!

    Many thanks.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."