Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Dynamic DotsVisible LineChart

  1. #1

    Default Dynamic DotsVisible LineChart

    Hello, With CDE, is that possible to have a linechart with 2 series where the property DotsVisible for Serie 1 is true and for Serie 2 is false?

    I've searched for some extension point that could help me in this case, but no success, I just found the property for the whole chart.Thanks!

  2. #2
    Join Date
    Mar 2012
    Posts
    645

    Default

    Hi Leandro,

    yes. There are two methods:

    Dynamic dot_visible extension point

    Set the dotsVisible option to true, but then conditionally hide it using the dot_visible extension point.

    For example, in preExecution:
    Code:
    function() {
      $.extend(this.chartDefinition, {
        dotsVisible: true
        dot_visible: function(scene) {
          return scene.getSeries() !== "MySeriesWithoutDots";
        }
      };
    }
    While this might be easy (and fun?) if you only need to change the styling for a single visual aspect, it does have its costs.
    If there are many extension points to configure in this dynamic way, it gets somewhat verbose.
    We fill we are using a canon to kill a fly.
    You lose the declarative nature in a case with arguably simple customizations. One immediate victim is that the corresponding legend items won't automatically display the desired style for each series, because dynamic/function extension points could not work well in the legend item environment.
    So we end up having to repeat the styling for the legend item:

    Code:
    function() {
      $.extend(this.chartDefinition, {
        // ...
        legendDot_visible: function(scene) {
          return scene.getValue() !== "MySeriesWithoutDots";
        }
      };
    }
    Use one plot for series style group

    If you only have two series groups you can use the main plot and plot2:

    Code:
    function() {
      $.extend(this.chartDefinition, {
        // Plot Main
        dotsVisible: true
        
        // Plot 2
        plot2: true,
        plot2Series: ["MySeriesWithoutDots"],
        plot2DotsVisible: false
      };
    }
    With this method, the legend items associated with each plot will nicely use the dot style used by the "corresponding" plot.

    If you have more than two styling series groups, you can create more plots, at will, and style each one accordingly:

    Code:
    function() {
      $.extend(this.chartDefinition, {
         plots: [
            {
                name: 'main',
                dotsVisible: true,
                dataPart: 0
            },
            {
                type: 'point',
                dotsVisible:  false,
                dataPart: 1
            },
             {
                type: 'point',
                dotsVisible:  false,
                dot_strokeDasharray: "- ",
                dataPart: 2
            }
        ],
    
        // Calculate dataPart dimension according to series value:
        calculations: [{
            names: 'dataPart',
            calculation: function(datum, atoms) {
                switch(datum.atoms.series.value) {
                  case "MySeriesWithouDots":
                     atoms.dataPart = 1;
                     break;
                  case "MySeriesWithouDotsAndDashed":
                     atoms.dataPart = 2;
                     break;
                  default:
                     atoms.dataPart = 0;
                     break;
                }
            }
        }],
      });
    }

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
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

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