<jupyter_start><jupyter_text>Get Data<jupyter_code>data = pd.read_csv(os.path.abspath('../data_files/country_codes.csv'), index_col=[0])
country_codes = data.index.values
country_names = data['Name']<jupyter_output><empty_output><jupyter_text>Basic Market Map<jupyter_code>market_map = MarketMap(names=country_codes,      
                       # basic data which needs to set for each map
                       ref_data=data,            
                       # Data frame which can be used for different properties of the map
                       # Axis and scale for color data
                       tooltip_fields=['Name'],
                       layout={'min_width': '800px', 'min_height': '600px'})

market_map
market_map.colors = ['MediumSeaGreen']
market_map.font_style = {'font-size': '16px', 'fill':'white'}
market_map.title = 'Country Map'
market_map.title_style = {'fill': 'Red'}<jupyter_output><empty_output><jupyter_text>GDP data with grouping by continentWorld Bank national accounts data, and OECD National Accounts data files. (The World Bank: GDP per capita (current US$))<jupyter_code>gdp_data = pd.read_csv(os.path.abspath('../data_files/gdp_per_capita.csv'), index_col=[0], parse_dates=True)
gdp_data.fillna(method='backfill', inplace=True)
gdp_data.fillna(method='ffill', inplace=True)
col = ColorScale(scheme='Greens')
continents = data['Continent'].values
ax_c = ColorAxis(scale=col, label='GDP per Capita', visible=False)

data['GDP'] = gdp_data.iloc[-1]

market_map = MarketMap(names=country_codes, groups=continents,       # Basic data which needs to set for each map
                       cols=25, row_groups=3,                        # Properties for the visualization
                       ref_data=data,                                # Data frame used for different properties of the map
                       tooltip_fields=['Name', 'Continent', 'GDP'],  # Columns from data frame to be displayed as tooltip
                       tooltip_formats=['', '', '.1f'],
                       scales={'color': col}, axes=[ax_c],
                       layout=Layout(min_width='800px', min_height='600px'))           # Axis and scale for color data
deb_output = Label()
def selected_index_changed(change):
    deb_output.value = str(change.new)
        
market_map.observe(selected_index_changed, 'selected')
VBox([deb_output, market_map])
# Attribute to show the names of the groups, in this case the continents
market_map.show_groups = True
# Setting the selected countries
market_map.show_groups = False
market_map.selected = ['PAN', 'FRA', 'PHL']
# changing selected stroke and hovered stroke variable
market_map.selected_stroke = 'yellow'
market_map.hovered_stroke = 'violet'<jupyter_output><empty_output><jupyter_text>Setting the color based on data<jupyter_code># Adding data for color and making color axis visible
market_map.color = data['GDP']
ax_c.visible = True<jupyter_output><empty_output><jupyter_text>Adding a widget as tooltip<jupyter_code># Creating the figure to be displayed as the tooltip
sc_x = DateScale()
sc_y = LinearScale()

ax_x = Axis(scale=sc_x, grid_lines='dashed', label='Date')
ax_y = Axis(scale=sc_y, orientation='vertical', grid_lines='dashed',
            label='GDP', label_location='end', label_offset='-1em')

line = Lines(x= gdp_data.index.values, y=[], scales={'x': sc_x, 'y': sc_y}, colors=['orange'])
fig_tooltip = Figure(marks=[line], axes=[ax_x, ax_y])
market_map = MarketMap(names=country_codes, groups=continents,
                       cols=25, row_groups=3,
                       color=data['GDP'], scales={'color': col}, axes=[ax_c],
                       ref_data=data, tooltip_widget=fig_tooltip,
                       layout=Layout(min_width='900px', min_height='600px'))

# Update the tooltip chart
hovered_symbol = ''
def hover_handler(self, content):
    global hovered_symbol
    symbol = content.get('data', '')
    
    if(symbol != hovered_symbol):
        hovered_symbol = symbol
        if(gdp_data.get(hovered_symbol) is not None):
            line.y = gdp_data[hovered_symbol].values
            fig_tooltip.title = content.get('ref_data', {}).get('Name', '')

# Custom msg sent when a particular cell is hovered on
market_map.on_hover(hover_handler)
market_map<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11952469711090401, 'fraction_numerical': 0.007222739981360671, 'mean_word_length': 3.4858934169278997, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '102835', 'license': 'Apache-2.0', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1302, 'n_words': 307, 'path': 'examples/Marks/Object Model/Market Map.ipynb', 'repo_name': 'davidbrochart/bqplot', 'size': '4292'}