Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Bar chart customizing.

  1. #1
    Join Date
    Mar 2013
    Posts
    1

    Default Bar chart customizing.

    Hi, i wish to create bar chart with yAxysLabels placed on the bars. I tryed override postExecution function like this:
    Code:
        var bar = this.chart.barChartPanel.pvBar;
        var chart = this.chart;
        var resultset = this.query.lastResults().resultset;
        var data = resultset.map(function(value, index) {return sprintf("%s: %d", value[0], value[1])});
        bar.anchor("left").add(pv.Label)
            .textStyle("black")
            .textAlign("left")
            .text(function(d){ return mystery_function(data)});
        bar.root.render();
    Сan i write this
    Code:
    .text(function(d){ return mystery_function(data)});
    with considering bar iteration? (may be is it something like .text(function(d){ return data[this.index]}) ?)

    (excuse me for any mistakes above. English is not my natural language)

  2. #2
    Join Date
    Mar 2012
    Posts
    645

    Default

    Are you using CCCv2? If so, you can use the following:

    Code:
    new pvc.BarChart({
        canvas: "cccBarExample1",
        width:   400,
        height:  300,
        orientation:   'horizontal',
        animate:        false,
        selectable:     true,
        hoverable:      true,
        valuesVisible:  true,
        valuesMask:     "{value}",
        valuesAnchor:   'right',
        valuesFont:      'bold 15px sans-serif',
        contentMargins: {right: 20}, // heuristic, label overflow
        extensionPoints: {
            label_textStyle: 'green',
            label_textAlign: 'left'
        }
    })
    .setData(relational_03, { crosstabMode: false })
    .render();
    It'll result in:
    Name:  BarChartValueLabels.jpg
Views: 363
Size:  24.5 KB

    Try this at http://www.webdetails.pt/ctools.html#tabccc > "CCC.CHARTS" > "BAR" > "SIMPLE BAR"

    Instead of using the "valuesMask" option, you can also explicitly calculate the label text, using something like the following extension point:
    Code:
    label_text: function(scene) { return scene.vars.value.label; }

  3. #3

    Default

    Hi duarte.leao,


    Nice post ! It is work for me.


    Thank You.

  4. #4
    Join Date
    May 2013
    Posts
    12

    Default

    its absolutely fine and there are no issues for it right now.
    .

  5. #5
    Join Date
    Dec 2012
    Posts
    121

    Default

    Hi all,
    is it possible to change the cda json on the barchart?
    I want to manipulate the json of my barchart and render the new one.

    Yamas,
    marco

  6. #6
    Join Date
    Mar 2012
    Posts
    645

    Default

    Hi marcolino,

    a CDE component's "postFetch" handler is the place for that:

    Code:
    function(cdaData) {
        // Manipulate cdaData in any desired way.
        // ...
    
        // Return modified cdaData or some appropriate replacement
        return cdaData;
    }
    Oh, and please create new threads for specific questions, like this one :-/

    EDIT: I see you had done it already: http://forums.pentaho.com/showthread...on-of-barchart
    Last edited by duarte.leao; 07-22-2013 at 01:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.