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

Map visualization & data type for first column #14254

Closed
ArnoldWertfaktor opened this issue Jan 5, 2021 · 9 comments · Fixed by #16706
Closed

Map visualization & data type for first column #14254

ArnoldWertfaktor opened this issue Jan 5, 2021 · 9 comments · Fixed by #16706
Assignees
Labels
Priority:P3 Cosmetic bugs, minor bugs with a clear workaround Querying/Native The SQL/native query editor .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects Visualization/Maps
Milestone

Comments

@ArnoldWertfaktor
Copy link

In Metabase, the map visualization cannot be selected correctly if the first column is of type Numeric. With a string, on the other hand, it works.

Below is a small code to reproduce. The first variant (see screen) does not work, but the other three ones do (see screen 2 for an example).

For the code example 3 cities with their respective coordinates are used

--/*
SELECT 53.543764 AS "latitude", 10.009913 AS "longitude", 'Hamburg' AS "city_name"
UNION
SELECT 52.517037, 13.38886, 'Berlin'
UNION
SELECT 48.137108, 11.575382, 'München'
--*/
---------------------
-- If you want to use map-visualization properly, You have to use a VARCHAR-datatype or NULL for the first column.
---------------------
/*
SELECT 'Hamburg' AS "city_name", 53.543764 AS "latitude", 10.009913 AS "longitude"
UNION
SELECT 'Berlin', 52.517037, 13.38886
UNION
SELECT 'München', 48.137108, 11.575382
*/
---------------------
/*
SELECT 'Static VARCHAR column necessary for metabase to offer map visualization' as "metabase_workaround", 53.543764 AS "latitude", 10.009913 AS "longitude"
UNION
SELECT 'Static VARCHAR column necessary for metabase to offer map visualization' as "metabase_workaround", 52.517037, 13.38886
UNION
SELECT 'Static VARCHAR column necessary for metabase to offer map visualization' as "metabase_workaround", 8.137108, 11.575382
*/
---------------------
/*
SELECT null AS "null", 53.543764 AS "latitude", 10.009913 AS "longitude"
UNION
SELECT null, 52.517037, 13.38886
UNION
SELECT null, 48.137108, 11.575382
*/

Map Visualization _ Numeric

Map Visualization _ String

{
  "browser-info": {
    "language": "de",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15",
    "vendor": "Apple Computer, Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "1.8.0_272-heroku-b10",
    "java.vendor": "Oracle Corporation",
    "java.vendor.url": "http://java.oracle.com/",
    "java.version": "1.8.0_272-heroku",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "25.272-b10",
    "os.name": "Linux",
    "os.version": "4.4.0-1081-aws",
    "user.language": "en",
    "user.timezone": "Etc/UTC"
  },
  "metabase-info": {
    "databases": [
      "postgres"
    ],
    "hosting-env": "heroku",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "11.10 (Ubuntu 11.10-1.pgdg16.04+1)"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.8"
      }
    },
    "run-mode": "prod",
    "version": {
      "tag": "v0.37.2",
      "date": "2020-11-16",
      "branch": "release-x.37.x",
      "hash": "25e5f70"
    },
    "settings": {
      "report-timezone": "Europe/Berlin"
    }
  }
}
@flamber flamber added Priority:P3 Cosmetic bugs, minor bugs with a clear workaround Querying/Native The SQL/native query editor Visualization/Maps and removed .Needs Triage labels Jan 5, 2021
@flamber
Copy link
Contributor

flamber commented Jan 5, 2021

Hi @ArnoldWertfaktor
You can still select the map visualization even if it is grayed out.
Reproduce with Sample Dataset:

SELECT "PUBLIC"."PEOPLE"."LONGITUDE" AS "LONGITUDE", "PUBLIC"."PEOPLE"."LATITUDE" AS "LATITUDE", "PUBLIC"."PEOPLE"."CITY" AS "CITY"
FROM "PUBLIC"."PEOPLE"
LIMIT 10

Related to #13710

@ArnoldWertfaktor

This comment has been minimized.

@flamber

This comment has been minimized.

@notrom

This comment has been minimized.

@ArnoldWertfaktor

This comment has been minimized.

@flamber

This comment has been minimized.

@ArnoldWertfaktor

This comment has been minimized.

@flamber

This comment has been minimized.

@flamber flamber reopened this Jan 7, 2021
@nemanjaglumac
Copy link
Member

If you look closely enough, Map visualization is actually selected (on question load). Its parent div has an opacity of 0.25 so it looks greyed out.
image

Remove that opacity and this is what you'll see:
image

Related code lives in: frontend/src/metabase/query_builder/components/view/sidebars/ChartTypeSidebar.jsx:90

<Box
  p={1}
  w={1 / 3}
  className="text-centered"
  style={{ opacity: !isSensible ? 0.25 : 1 }}
>

isSensible prop is calculated on lines 56-61:

isSensible={
  result &&
  result.data &&
  visualization.isSensible &&
  visualization.isSensible(result.data)
}

This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:P3 Cosmetic bugs, minor bugs with a clear workaround Querying/Native The SQL/native query editor .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects Visualization/Maps
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants