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

Region map: k-means choropleth coloring breaks with small number of rows #4684

Open
tlrobinson opened this Issue Apr 4, 2017 · 6 comments

Comments

Projects
None yet
9 participants
@tlrobinson
Copy link
Member

tlrobinson commented Apr 4, 2017

If the number of rows is less than the number of colors (5), the k-means library throws this error:

ckmeans.js?7bb6:223 Uncaught Error: Cannot generate more classes than there are data values

@tanzoniteblack

This comment has been minimized.

Copy link
Contributor

tanzoniteblack commented Apr 4, 2017

Whoops, I'll have a fix for that shortly.

tanzoniteblack added a commit to tanzoniteblack/metabase that referenced this issue Apr 4, 2017

@camsaul camsaul added this to the 0.24.0 milestone Apr 12, 2017

@mariomka

This comment has been minimized.

Copy link

mariomka commented Nov 22, 2018

I have the same problem in v0.31.0.

@FadhelC

This comment has been minimized.

Copy link

FadhelC commented Dec 6, 2018

Same issue in v0.31.1

@programwar

This comment has been minimized.

Copy link

programwar commented Jan 23, 2019

It's still present on v0.31.2

@clouless

This comment has been minimized.

Copy link

clouless commented Mar 21, 2019

I am getting the exact same error Dockerized Metabase v0.31.2.

I have a column for ISO 31661 a2 country codes and a sum of sales.

image

When I change the view to map, then this happens:

demo

I get the console error:

vendor.bundle.js?78262faa1c529a733077:189 Uncaught Error: cannot generate more classes than there are data values
    at Object.t.exports [as ckmeans] (vendor.bundle.js?78262faa1c529a733077:189)
    at t.value (app-main.bundle.js?78262faa1c529a733077:5)
    at u._renderValidatedComponentWithoutOwnerOrContext (vendor.bundle.js?78262faa1c529a733077:145)
    at u._renderValidatedComponent (vendor.bundle.js?78262faa1c529a733077:145)
    at u._updateRenderedComponent (vendor.bundle.js?78262faa1c529a733077:145)
    at u._performComponentUpdate (vendor.bundle.js?78262faa1c529a733077:145)
    at updateComponent (vendor.bundle.js?78262faa1c529a733077:145)
    at u.performUpdateIfNecessary (vendor.bundle.js?78262faa1c529a733077:145)
    at Object.performUpdateIfNecessary (vendor.bundle.js?78262faa1c529a733077:83)
    at b (vendor.bundle.js?78262faa1c529a733077:83)

I found no workaround to get this working. Does not matter for me if Cumulative Sum or just Sum.

  • Metabase: dockerized metabase/metabase:v0.32.0-RC1 and metabase/metabase:v0.31.2
  • Browser: Google Chrome v72.0.3626.121 (official build) (64-Bit)
  • OS: macOS Mojave v10.14.1
  • Database: dockerized postgres:10-alpine
  • SQL Schema and testdata
CREATE USER metabase WITH PASSWORD 'metabase123';

DROP DATABASE IF EXISTS "stats";
CREATE DATABASE "stats"
    WITH OWNER "metabase"
    ENCODING 'UTF8'
    LC_COLLATE = 'en_US.UTF-8'
    LC_CTYPE = 'en_US.UTF-8'
    TEMPLATE template0;

\c stats;

--
-- TABLES
--
DROP TABLE IF EXISTS atlassian_marketplace_products CASCADE;
CREATE TABLE atlassian_marketplace_products(
 id serial PRIMARY KEY,
 name VARCHAR(255) NOT NULL,
 app_key VARCHAR(255) NOT NULL
);
DROP TABLE IF EXISTS atlassian_marketplace_app_types CASCADE;
CREATE TABLE atlassian_marketplace_app_types(
 id serial PRIMARY KEY,
 name VARCHAR(255) NOT NULL
);
DROP TABLE IF EXISTS atlassian_marketplace_sales_per_country CASCADE;
CREATE TABLE atlassian_marketplace_sales_per_country(
 id serial PRIMARY KEY,
 product_fk INTEGER REFERENCES atlassian_marketplace_products(id),
 num_sales INTEGER NOT NULL,
 country VARCHAR(255) NOT NULL,
 country_iso VARCHAR(255) NOT NULL,
 revenue  DECIMAL NOT NULL,
 app_type_fk INTEGER REFERENCES atlassian_marketplace_app_types(id),
 timestamp TIMESTAMPTZ NOT NULL
);

--
-- DEMO DATA
--
INSERT INTO atlassian_marketplace_products(name, app_key) VALUES('App1', 'app1key');

INSERT INTO atlassian_marketplace_app_types(name) VALUES('Cloud');
INSERT INTO atlassian_marketplace_app_types(name) VALUES('Server');
INSERT INTO atlassian_marketplace_app_types(name) VALUES('Data Center');
INSERT INTO atlassian_marketplace_app_types(name) VALUES('All');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Germany', 'DE', 500, 1, '2019-03-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'United States of America', 'US', 500, 1, '2019-03-17 12:00:00.000000 EST');

--
-- PERMISSIONS
--
GRANT ALL PRIVILEGES ON TABLE atlassian_marketplace_products TO metabase;
GRANT ALL PRIVILEGES ON TABLE atlassian_marketplace_app_types TO metabase;
GRANT ALL PRIVILEGES ON TABLE atlassian_marketplace_sales_per_country TO metabase;

GRANT ALL PRIVILEGES ON SEQUENCE atlassian_marketplace_products_id_seq TO metabase;
GRANT ALL PRIVILEGES ON SEQUENCE atlassian_marketplace_app_types_id_seq TO metabase;
GRANT ALL PRIVILEGES ON SEQUENCE atlassian_marketplace_sales_per_country_id_seq TO metabase;

And more testdata generating at least 5 countries fixes it...

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2019-02-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2019-02-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2019-01-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2019-01-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2018-12-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2018-12-17 12:00:00.000000 EST');


INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2019-02-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2019-02-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2019-01-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2019-01-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 2, 'Jamaica', 'JM', 999, 1, '2018-12-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Netherlands', 'NL', 999, 1, '2018-12-17 12:00:00.000000 EST');

INSERT INTO atlassian_marketplace_sales_per_country(product_fk, num_sales, country, country_iso, revenue, app_type_fk, timestamp)
    VALUES(1, 3, 'Russian Federation', 'RU', 999, 1, '2018-12-17 12:00:00.000000 EST');

image

image

@fvides

This comment has been minimized.

Copy link

fvides commented Mar 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.