Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
5cca85d1
Commit
5cca85d1
authored
8 years ago
by
Ryan Smith
Browse files
Options
Downloads
Patches
Plain Diff
Make k-means grouping work with less than 5 rows
Fixes:
https://github.com/metabase/metabase/issues/4684
parent
9580c50f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/visualizations/components/ChoroplethMap.jsx
+8
-6
8 additions, 6 deletions
.../src/metabase/visualizations/components/ChoroplethMap.jsx
with
8 additions
and
6 deletions
frontend/src/metabase/visualizations/components/ChoroplethMap.jsx
+
8
−
6
View file @
5cca85d1
...
...
@@ -154,9 +154,11 @@ export default class ChoroplethMap extends Component {
const
getFeatureKey
=
(
feature
)
=>
String
(
feature
.
properties
[
keyProperty
]).
toLowerCase
();
const
getFeatureValue
=
(
feature
)
=>
valuesMap
[
getFeatureKey
(
feature
)];
const
heatMapColors
=
HEAT_MAP_COLORS
.
slice
(
0
,
Math
.
min
(
HEAT_MAP_COLORS
.
length
,
rows
.
length
))
const
onHoverFeature
=
(
hover
)
=>
{
onHoverChange
&&
onHoverChange
(
hover
&&
{
index
:
HEAT_MAP_COLORS
.
indexOf
(
getColor
(
hover
.
feature
)),
index
:
heatMapColors
.
indexOf
(
getColor
(
hover
.
feature
)),
event
:
hover
.
event
,
data
:
{
key
:
getFeatureName
(
hover
.
feature
),
value
:
getFeatureValue
(
hover
.
feature
)
}
})
...
...
@@ -169,15 +171,15 @@ export default class ChoroplethMap extends Component {
domain
.
push
(
getRowValue
(
row
));
}
const
groups
=
ss
.
ckmeans
(
domain
,
HEAT_MAP_COLORS
.
length
);
const
groups
=
ss
.
ckmeans
(
domain
,
heatMapColors
.
length
);
var
colorScale
=
d3
.
scale
.
quantile
().
domain
(
groups
.
map
((
cluster
)
=>
cluster
[
0
])).
range
(
HEAT_MAP_COLORS
);
var
colorScale
=
d3
.
scale
.
quantile
().
domain
(
groups
.
map
((
cluster
)
=>
cluster
[
0
])).
range
(
heatMapColors
);
let
legendColors
=
HEAT_MAP_COLORS
.
slice
();
let
legendTitles
=
HEAT_MAP_COLORS
.
map
((
color
,
index
)
=>
{
let
legendColors
=
heatMapColors
.
slice
();
let
legendTitles
=
heatMapColors
.
map
((
color
,
index
)
=>
{
const
min
=
groups
[
index
][
0
];
const
max
=
groups
[
index
].
slice
(
-
1
)[
0
];
return
index
===
HEAT_MAP_COLORS
.
length
-
1
?
return
index
===
heatMapColors
.
length
-
1
?
formatNumber
(
min
)
+
"
+
"
:
formatNumber
(
min
)
+
"
-
"
+
formatNumber
(
max
)
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment