Is it possible to remove the 0 values from charts?

  • 1
  • Question
  • Updated 4 months ago
  • Answered
Wondering if anyone has a way to remove the 0 values from charts as it provides no value to my users.
Photo of Josef Lagorio

Josef Lagorio

  • 2,864 Points 2k badge 2x thumb

Posted 4 months ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Several ways.

You can create a snippet to remove the points from the series.
You can manually create a condition in XML where the value != 0.
You can create a condition on the model that filters out anything where the value is 0.
Photo of Josef Lagorio

Josef Lagorio

  • 2,864 Points 2k badge 2x thumb
I'm using an aggregate model and not sure how to tackle any of these recommendations. 
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Josef,

I think the easiest approach is to add the 'Having' clause to the XML.  Skuid's API supports adding the 'Having' clause to the SOQL, but there is no user interface to add this XML to the page.  Here is a write up from Zach:  https://community.skuid.com/skuid/topics/filter_on_count

Here is the XML to add.  It goes just below the 'groupby' XML.
<havings>
    <having field="Id" fieldfunction="COUNT" operator="gt" value="0" enclosevalueinquotes="false"/>
</havings>

Here is a sample page that shows the count of Tasks by Owner where the Count>5.

Thanks,

Bill

<skuidpage personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="TaskCountByOwner" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Task" type="aggregate">
            <fields>
                <field id="Id" name="countId" function="COUNT"/>
            </fields>
            <conditions/>
            <actions/>
            <groupby method="simple">
                <field id="OwnerId" name="ownerId"/>
                <field id="Owner.Name" name="ownerName"/>
            </groupby>
            <havings>
                <having field="Id" fieldfunction="COUNT" operator="gt" value="5" enclosevalueinquotes="false"/>
            </havings>
        </model>
    </models>
    <components>
        <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="false" model="TaskCountByOwner" buttonposition="" mode="readonly" allowcolumnreordering="true" responsive="true" uniqueid="sk-3SJP-333">
            <fields>
                <field id="Owner.Name" name="ownerName" hideable="true" uniqueid="fi-3SJR-351"/>
                <field id="Id" name="countId" hideable="true" uniqueid="fi-3SJR-352"/>
            </fields>
            <rowactions/>
            <massactions usefirstitemasdefault="true"/>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
        <actionsequences uniqueid="sk-3SJL-315"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I learned something new today! Never seen this <having> before!
Photo of Josef Lagorio

Josef Lagorio

  • 2,864 Points 2k badge 2x thumb
The chart is rendering fine, but is still loading "0" values. 
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Joe,

When you're building your aggregate model, are the zero values just the results of a group sum (or count) totaling 0? In other words, it would help to understand more about what the zeros look like in the model itself, to see if any of Pat's suggestions could be leveraged.
Photo of Josef Lagorio

Josef Lagorio

  • 2,864 Points 2k badge 2x thumb
Hey Mark,
 
The zero values are a result of a group count.

Here is the model's SOQL:

SELECT COUNT(Id) countId,COUNT(Id) TeamAverage,OwnerId ownerId,Owner.Name ownerName,Type type FROM Task WHERE (Type in ('Call','Call Connect','Email','Email connect','Face to Face Meeting','AE Connect','Left Voice Mail'))AND(OwnerId in ('005800000091XI2AAM','0058000000CN9woAAD','0058000000EfaU1AAJ','0058000000Eg02CAAR')) GROUP BY OwnerId,Owner.Name,Type HAVING (COUNT(Id) > 0)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Can you copy the SOQL generated by the model? Alternatively, can you copy the XML for the page along with the name/id of the model being used in the chart.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Looks like there's not really a simple answer here, but you can do this with a before render snippet using the highcharts api:

https://stackoverflow.com/questions/49421548/want-to-hide-column-having-0-value-in-highchart-basic-c...
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Apparently you may also be able to get highcharts to do the right thing if you replace the 0 values with null.
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Matt,

This is a cool find.  It means you can 'hide' the '0' values (or any 'x' value) using a formula field.  Something like this:

IF({{countId}}>10,{{countId}},"")

Just change you chart to use the formula field instead of 'countId'.

Thanks!

Bill