Cards, Dashboards, Stories

Cards, Dashboards, Stories

Blank Brick Dataset Schema

I created a blank brick to track office locations in the path of hurricane Beryl. My ETL produces a dataset with latitude and longitude in decimal. Now my blank brick is showing these values as integers. They are not integer. How do I force the blank brick to re-evaluate the schema. I tried reloading and reassigning.

I also tried the toolkit under admin. It shows the schema with decimal values.

What made the brick start treating them as integer?

image.png

** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answer

  • Contributor
    edited July 2024 Answer ✓

    @ArborRose I found your issue. On your javascript line 24 (and on line 42 of your example data) you are "Check[ing] if latitude and longitude are valid".

    However, because the longitude always happens to be a negative number (a falsey boolean) in your dataset your function is bypassing the if statement and not adding the data to your mapping.

    *This is a wonderful quirk of javascript that does not exist in Python/Ruby/PHP/C/C++/Java

    ** Was this post helpful? Click 💡/💖/👍/😊 below. **
    ** If it solved your problem. Accept it as a solution! ✔️ **

    Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
    Did I help you out? Feedback is priceless and will help me more than you know.Write a review!

Answers

  • Domo Employee

    So if you view the data in the dataset its all decimals but when you get to the brick it shows as all integers?

  • Yes, correct. My dataset has the values as decimal. And the schema confirms it.

    image.png image.png

    In my code, I created "data2" as a set of values typed in rather than the dataset. Those values plot just fine. You can see one on Dallas and another on Houston.

    But the dataset values are not plotting on my map because the dataset is somehow not allowing them to stay in decimal format.

    image.png

    This is scary because I am currently working on an accounts receivable brick that has a lot of columns. I cringe at the thought that Domo might suddenly warp my dataset on the way in.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • For Eric or anyone who wants my code, I include it below. In fact, I should include @eddiesmall, as this is method people may want to incorporate into infographics. For my purpose, I am tracking hurricane Beryl so we can keep an eye on our medical offices along its path. You can join your Domo address information with a city location database containing longitude and latitude data.

    html:

    1. <div id="map" style="height: 800px; width: 100%;"></div>
    2. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
    3. <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
    4.  
    1. function initMap() {
    2. // Create a map centered on Texas
    3. var map = L.map('map').setView([31.9686, -99.9018], 6);
    4.  
    5. // Add OpenStreetMap tile layer
    6. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    7. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    8. }).addTo(map);
    9.  
    10. // Define a smaller dot style
    11. var dotStyle = {
    12. radius: 5, // Size of the dot
    13. fillColor: '#ff7800', // Dot color
    14. color: '#000', // Dot border color
    15. weight: 1, // Border thickness
    16. opacity: 1, // Border opacity
    17. fillOpacity: 0.8 // Dot fill opacity
    18. };
    19.  
    20. // Fetch data from `dataset0`
    21. domo.get('/data/dataset0').then(function(response) {
    22. response.forEach(function(record) {
    23. // Check if latitude and longitude are valid
    24. if (record.latitude && record.longitude) {
    25. L.circleMarker([record.latitude, record.longitude], dotStyle)
    26. .addTo(map)
    27. .bindPopup(record.name + '<br>' + record.address_line1 + '<br>' + record.city + ', ' + record.state + ' ' + record.zipcode);
    28. }
    29. });
    30. }).catch(function(error) {
    31. console.error('Error fetching data from dataset0:', error);
    32. });
    33.  
    34. // Example data
    35. var data2 = [
    36. {latitude: 32.78, longitude: -96.80, name: 'Dallas, TX', address_line1: '123 Main St', city: 'Dallas', state: 'TX', zipcode: '75201'},
    37. {latitude: 29.76, longitude: -95.37, name: 'Houston, TX', address_line1: '456 Elm St', city: 'Houston', state: 'TX', zipcode: '77002'}
    38. ];
    39.  
    40. // Add dots for each location
    41. data2.forEach(function(record) {
    42. if (record.latitude && record.longitude) {
    43. L.circleMarker([record.latitude, record.longitude], dotStyle)
    44. .addTo(map)
    45. .bindPopup(record.name + '<br>' + record.address_line1 + '<br>');
    46. }
    47. });
    48. }
    49.  
    50. // Initialize the map
    51. initMap();

    css:

    1. /* Style for the map container */
    2. #map {
    3. height: 100%;
    4. width: 100%;
    5. }

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • Contributor
    edited July 2024 Answer ✓

    @ArborRose I found your issue. On your javascript line 24 (and on line 42 of your example data) you are "Check[ing] if latitude and longitude are valid".

    However, because the longitude always happens to be a negative number (a falsey boolean) in your dataset your function is bypassing the if statement and not adding the data to your mapping.

    *This is a wonderful quirk of javascript that does not exist in Python/Ruby/PHP/C/C++/Java

    ** Was this post helpful? Click 💡/💖/👍/😊 below. **
    ** If it solved your problem. Accept it as a solution! ✔️ **

    Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
    Did I help you out? Feedback is priceless and will help me more than you know.Write a review!

  • @MattTheGuru - Interesting catch. Thanks. But it won't fix anything if the dataset is defining those values as integers. {Look at the screenshots of the dataset table.}

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • It appears my issue was in the fetching of the dataset. Here's code that works. Thank you Matt.

    1. function initMap() {
    2. // Create a map centered on Texas
    3. var map = L.map('map').setView([31.9686, -99.9018], 6);
    4.  
    5. // Add OpenStreetMap tile layer
    6. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    7. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    8. }).addTo(map);
    9.  
    10. // Define a smaller dot style
    11. var dotStyle = {
    12. radius: 5, // Size of the dot
    13. fillColor: '#ff7800', // Dot color
    14. color: '#000', // Dot border color
    15. weight: 1, // Border thickness
    16. opacity: 1, // Border opacity
    17. fillOpacity: 0.8 // Dot fill opacity
    18. };
    19.  
    20. // Function to check if a value is a valid number
    21. function isValidNumber(value) {
    22. return typeof value === 'number' && !isNaN(value);
    23. }
    24.  
    25. // Fetch data from `dataset0`
    26. domo.get('/data/v1/dataset0').then(function(response) {
    27. // Log fetched data to a div
    28. const logDiv = document.createElement('div');
    29. logDiv.innerHTML = '<strong>Fetched data from dataset0:</strong><br>' + JSON.stringify(response, null, 2);
    30. document.body.appendChild(logDiv);
    31.  
    32. response.forEach(function(record) {
    33. // Log each record to a div
    34. const recordDiv = document.createElement('div');
    35. recordDiv.innerHTML = '<strong>Record:</strong><br>' + JSON.stringify(record, null, 2);
    36. document.body.appendChild(recordDiv);
    37.  
    38. // Check if latitude and longitude are valid numbers
    39. if (isValidNumber(record.latitude) && isValidNumber(record.longitude)) {
    40. const validCoordDiv = document.createElement('div');
    41. validCoordDiv.innerHTML = '<strong>Valid coordinates:</strong><br> Latitude: ' + record.latitude + ', Longitude: ' + record.longitude;
    42. document.body.appendChild(validCoordDiv);
    43.  
    44. L.circleMarker([record.latitude, record.longitude], dotStyle)
    45. .addTo(map)
    46. .bindPopup(record.name + '<br>' + record.address_line1 + '<br>' + record.city + ', ' + record.state + ' ' + record.zipcode);
    47. } else {
    48. const invalidCoordDiv = document.createElement('div');
    49. invalidCoordDiv.innerHTML = '<strong>Invalid coordinates:</strong><br> Latitude: ' + record.latitude + ', Longitude: ' + record.longitude;
    50. document.body.appendChild(invalidCoordDiv);
    51. }
    52. });
    53. }).catch(function(error) {
    54. const errorDiv = document.createElement('div');
    55. errorDiv.innerHTML = '<strong>Error fetching data from dataset0:</strong><br>' + error;
    56. document.body.appendChild(errorDiv);
    57. console.error('Error fetching data from dataset0:', error);
    58. });
    59. }
    60.  
    61. // Initialize the map
    62. initMap();
    63.  

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In