Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tooltip ordering with data_order and add tooltip_order #1813

Merged
merged 1 commit into from
Feb 9, 2017

Conversation

panthony
Copy link
Contributor

This is an attempt to fix various issues around tooltip ordering ( #1050 #1764 ).

This PR adds:

  • handling of data_order with array (follow the order given by the array)
  • new tooltip_order option that takes the same arguments as data_order (except for functions where parameters are values instead of data)
  • tests that hopefully cover the majority of cases

This PR fixes:

  • sort of tooltip if data_order is null or a function

@panthony panthony changed the title Clearer handling of tooltip ordering with data_order option Fix tooltip ordering with data_order and add tooltip_order Aug 19, 2016
If data is grouped:
  - the tooltip will keep the same ordering as the stacked values

If data is not grouped:
  - the tooltip will use the data_order option to sort the values

 Also adds an optional 'tooltip_order' option. If set, it will override the data_order option.
@codecov-io
Copy link

Current coverage is 64.13% (diff: 100%)

Merging #1813 into dev will increase coverage by 0.39%

@@                dev      #1813   diff @@
==========================================
  Files             1          1          
  Lines          4424       4450    +26   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2820       2854    +34   
+ Misses         1604       1596     -8   
  Partials          0          0          

Powered by Codecov. Last update f7f99e0...c6509bc

@pchaganti
Copy link

+1

@bchartoff
Copy link

Would be great functionality, if a merge makes sense to y'all!

@phandel
Copy link

phandel commented Dec 21, 2016

+1

2 similar comments
@tcunha85
Copy link

+1

@jorgemmsilva
Copy link

+1

@aendra-rininsland aendra-rininsland merged commit 461bcdd into c3js:dev Feb 9, 2017
@aendra-rininsland
Copy link
Member

Apologies for the delay in getting to this — merging!

@alexgerv
Copy link
Contributor

alexgerv commented Jun 5, 2017

@Aendrew this was merged onto dev. Should we open a new PR for master ?

@aendra-rininsland
Copy link
Member

@alexgerv Yeah, if you wouldn't mind that would be terrific — apologies for the hassle!

@alexgerv
Copy link
Contributor

alexgerv commented Jun 6, 2017

No worries @Aendrew , see PR #2070

@chaitanmk
Copy link

Hi,

can you please provide sample code for tooltip_order.

@CaffeineFusion
Copy link

CaffeineFusion commented Aug 4, 2017

@chaitanmk - had a flick through the source and derived the following:

// Order by value
tooltip: {
	order: 'asc'
}
//Order by label
tooltip: {
    order: function (t1, t2) {
        return t1.id > t2.id;
    }
}

Note: The sorting for tooltips appears to work in reverse of the order functions for data labels.

data: {
    order: function (t1, t2) {
        return t1.id < t2.id;
    }
}

Corresponds to the opposite function for the tooltip sort:

tooltip: {
    order: function (t1, t2) {
        return t1.id > t2.id;
    }
}

@panthony panthony deleted the fix/tooltip-order branch February 28, 2018 09:59
@easz
Copy link

easz commented Apr 30, 2021

using [email protected]

so basically if I want the data shown in grouped tooltip having the same order as that in data columns, I have to extra declare this:

tooltip: {
    order: function(t1, t2) {
      return t1.index > t2.index;
    }

why we cannot just make it as default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.