-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Optimize charts plugin #78922
Optimize charts plugin #78922
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
*/ | ||
|
||
import _ from 'lodash'; | ||
import Color from 'color'; | ||
|
||
import d3 from 'd3'; | ||
|
||
import { coreMock } from '../../../../../core/public/mocks'; | ||
|
@@ -61,7 +63,7 @@ describe('Mapped Colors', () => { | |
mappedColors.mapKeys(arr); | ||
|
||
const colorValues = _(mappedColors.mapping).values(); | ||
expect(colorValues.includes(seedColors[0])).toBe(false); | ||
expect(colorValues).not.toContain(seedColors[0]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ A left over from debugging the tests, since this produces way better output, but I'd just leave it with this clearer API. |
||
expect(colorValues.uniq().size()).toBe(arr.length); | ||
}); | ||
|
||
|
@@ -78,9 +80,9 @@ describe('Mapped Colors', () => { | |
}); | ||
|
||
it('should treat different formats of colors as equal', () => { | ||
const color = d3.rgb(seedColors[0]); | ||
const rgb = `rgb(${color.r}, ${color.g}, ${color.b})`; | ||
const newConfig = { bar: rgb }; | ||
const color = new Color(seedColors[0]); | ||
const rgbColorString = `rgb(${color.red()}, ${color.green()}, ${color.blue()})`; | ||
const newConfig = { bar: rgbColorString }; | ||
config.set(COLOR_MAPPING_SETTING, newConfig); | ||
|
||
const arr = ['foo', 'bar', 'baz', 'qux']; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,14 @@ | |
*/ | ||
|
||
import _ from 'lodash'; | ||
import d3 from 'd3'; | ||
import Color from 'color'; | ||
|
||
import { CoreSetup } from 'kibana/public'; | ||
|
||
import { COLOR_MAPPING_SETTING } from '../../../common'; | ||
import { createColorPalette } from './color_palette'; | ||
|
||
const standardizeColor = (color: string) => d3.rgb(color).toString(); | ||
const standardizeColor = (color: string) => new Color(color).hex().toLowerCase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ The old code used d3.toString() which created a lower-case hex value, to make sure I don't need to touch the tests and we can thus better guarantee that this doesn't change any functionality, I kept here the same logic, even though technically we could use |
||
|
||
/** | ||
* Maintains a lookup table that associates the value (key) with a hex color (value) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ I also improved the TypeScript code in that place here and got rid of the
any
.