How to add more metrics on the country_map in Apache-superset?2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?Add new keys to a dictionary?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

How does Dispel Magic work against Stoneskin?

Is it true that real estate prices mainly go up?

Touchscreen-controlled dentist office snowman collector game

What is the definition of "Natural Selection"?

Who is our nearest neighbor

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?

How could a female member of a species produce eggs unto death?

Is all copper pipe pretty much the same?

Can "semicircle" be used to refer to a part-circle that is not a exact half-circle?

Life insurance that covers only simultaneous/dual deaths

validation vs test vs training accuracy, which one to compare for claiming overfit?

What is the difference between "shut" and "close"?

Is "history" a male-biased word ("his+story")?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

What has been your most complicated TikZ drawing?

Format picture and text with TikZ and minipage

Time travel short story where dinosaur doesn't taste like chicken

Are there situations where a child is permitted to refer to their parent by their first name?

Giving Plot options defined outside of the Plot expression

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Should QA ask requirements to developers?

Question about partial fractions with irreducible quadratic factors

Ban on all campaign finance?



How to add more metrics on the country_map in Apache-superset?



2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?Add new keys to a dictionary?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?










19















I am using country_map in apache-superset for visualization purposes. When zooming in on a polygon, information from the columns appears inside of the polygon, like so:



map



There is only one available metric option to display:
metric



Code for the metric update is found on this path:




superset/assets/src/visualizations/CountryMap/CountryMap.js




Code:



const updateMetrics = function (region) 
if (region.length > 0)
resultText.text(format(region[0].metric));

;


The metrics are defined in controls.jsx:




/superset/static/assets/src/explore/controls.jsx




const metrics = 
type: 'MetricsControl',
multi: true,
label: t('Metrics'),
validators: [v.nonEmpty],
default: (c) =>
const metric = mainMetric(c.savedMetrics);
return metric ? [metric] : null;
,
mapStateToProps: (state) =>
const datasource = state.datasource;
return
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource && datasource.type,
;
,
description: t('One or many metrics to display'),
;
const metric =
...metrics,
multi: false,
label: t('Metric'),
default: props => mainMetric(props.savedMetrics),
;


Country map is using metric, which doesn't allow multiple metrics to be selected, Code found here:




superset/assets/src/explore/controlPanels/CountryMap.js




 controlPanelSections: [

label: t('Query'),
expanded: true,
controlSetRows: [
['entity'],
['metric'],
['adhoc_filters'],
],
,

label: t('Options'),
expanded: true,
controlSetRows: [
['select_country', 'number_format'],
['linear_color_scheme'],
],
,
],


The python class of country_map is located at viz.py:



class CountryMapViz(BaseViz):

"""A country centric"""

viz_type = 'country_map'
verbose_name = _('Country Map')
is_timeseries = False
credits = 'From bl.ocks.org By john-guerra'

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = [
self.form_data['metric']]
qry['groupby'] = [self.form_data['entity']]
return qry


Changing the code in CountryMap.js and viz.py from metric to metrics results in the following error:



Traceback (most recent call last):
File "/Documents/superset/superset/superset/viz.py", line 410, in get_df_payload
df = self.get_df(query_obj)
File "/Documents/superset/superset/superset/viz.py", line 213, in get_df
self.results = self.datasource.query(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 797, in query
sql = self.get_query_str(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 471, in get_query_str
qry = self.get_sqla_query(**query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 585, in get_sqla_query
elif m in metrics_dict:
TypeError: unhashable type: 'list'


How can I add more metrics to display inside the polygon?










share|improve this question
























  • What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

    – gdlmx
    Mar 7 at 9:31











  • @gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

    – Snow
    Mar 7 at 9:56















19















I am using country_map in apache-superset for visualization purposes. When zooming in on a polygon, information from the columns appears inside of the polygon, like so:



map



There is only one available metric option to display:
metric



Code for the metric update is found on this path:




superset/assets/src/visualizations/CountryMap/CountryMap.js




Code:



const updateMetrics = function (region) 
if (region.length > 0)
resultText.text(format(region[0].metric));

;


The metrics are defined in controls.jsx:




/superset/static/assets/src/explore/controls.jsx




const metrics = 
type: 'MetricsControl',
multi: true,
label: t('Metrics'),
validators: [v.nonEmpty],
default: (c) =>
const metric = mainMetric(c.savedMetrics);
return metric ? [metric] : null;
,
mapStateToProps: (state) =>
const datasource = state.datasource;
return
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource && datasource.type,
;
,
description: t('One or many metrics to display'),
;
const metric =
...metrics,
multi: false,
label: t('Metric'),
default: props => mainMetric(props.savedMetrics),
;


Country map is using metric, which doesn't allow multiple metrics to be selected, Code found here:




superset/assets/src/explore/controlPanels/CountryMap.js




 controlPanelSections: [

label: t('Query'),
expanded: true,
controlSetRows: [
['entity'],
['metric'],
['adhoc_filters'],
],
,

label: t('Options'),
expanded: true,
controlSetRows: [
['select_country', 'number_format'],
['linear_color_scheme'],
],
,
],


The python class of country_map is located at viz.py:



class CountryMapViz(BaseViz):

"""A country centric"""

viz_type = 'country_map'
verbose_name = _('Country Map')
is_timeseries = False
credits = 'From bl.ocks.org By john-guerra'

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = [
self.form_data['metric']]
qry['groupby'] = [self.form_data['entity']]
return qry


Changing the code in CountryMap.js and viz.py from metric to metrics results in the following error:



Traceback (most recent call last):
File "/Documents/superset/superset/superset/viz.py", line 410, in get_df_payload
df = self.get_df(query_obj)
File "/Documents/superset/superset/superset/viz.py", line 213, in get_df
self.results = self.datasource.query(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 797, in query
sql = self.get_query_str(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 471, in get_query_str
qry = self.get_sqla_query(**query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 585, in get_sqla_query
elif m in metrics_dict:
TypeError: unhashable type: 'list'


How can I add more metrics to display inside the polygon?










share|improve this question
























  • What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

    – gdlmx
    Mar 7 at 9:31











  • @gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

    – Snow
    Mar 7 at 9:56













19












19








19


1






I am using country_map in apache-superset for visualization purposes. When zooming in on a polygon, information from the columns appears inside of the polygon, like so:



map



There is only one available metric option to display:
metric



Code for the metric update is found on this path:




superset/assets/src/visualizations/CountryMap/CountryMap.js




Code:



const updateMetrics = function (region) 
if (region.length > 0)
resultText.text(format(region[0].metric));

;


The metrics are defined in controls.jsx:




/superset/static/assets/src/explore/controls.jsx




const metrics = 
type: 'MetricsControl',
multi: true,
label: t('Metrics'),
validators: [v.nonEmpty],
default: (c) =>
const metric = mainMetric(c.savedMetrics);
return metric ? [metric] : null;
,
mapStateToProps: (state) =>
const datasource = state.datasource;
return
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource && datasource.type,
;
,
description: t('One or many metrics to display'),
;
const metric =
...metrics,
multi: false,
label: t('Metric'),
default: props => mainMetric(props.savedMetrics),
;


Country map is using metric, which doesn't allow multiple metrics to be selected, Code found here:




superset/assets/src/explore/controlPanels/CountryMap.js




 controlPanelSections: [

label: t('Query'),
expanded: true,
controlSetRows: [
['entity'],
['metric'],
['adhoc_filters'],
],
,

label: t('Options'),
expanded: true,
controlSetRows: [
['select_country', 'number_format'],
['linear_color_scheme'],
],
,
],


The python class of country_map is located at viz.py:



class CountryMapViz(BaseViz):

"""A country centric"""

viz_type = 'country_map'
verbose_name = _('Country Map')
is_timeseries = False
credits = 'From bl.ocks.org By john-guerra'

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = [
self.form_data['metric']]
qry['groupby'] = [self.form_data['entity']]
return qry


Changing the code in CountryMap.js and viz.py from metric to metrics results in the following error:



Traceback (most recent call last):
File "/Documents/superset/superset/superset/viz.py", line 410, in get_df_payload
df = self.get_df(query_obj)
File "/Documents/superset/superset/superset/viz.py", line 213, in get_df
self.results = self.datasource.query(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 797, in query
sql = self.get_query_str(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 471, in get_query_str
qry = self.get_sqla_query(**query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 585, in get_sqla_query
elif m in metrics_dict:
TypeError: unhashable type: 'list'


How can I add more metrics to display inside the polygon?










share|improve this question
















I am using country_map in apache-superset for visualization purposes. When zooming in on a polygon, information from the columns appears inside of the polygon, like so:



map



There is only one available metric option to display:
metric



Code for the metric update is found on this path:




superset/assets/src/visualizations/CountryMap/CountryMap.js




Code:



const updateMetrics = function (region) 
if (region.length > 0)
resultText.text(format(region[0].metric));

;


The metrics are defined in controls.jsx:




/superset/static/assets/src/explore/controls.jsx




const metrics = 
type: 'MetricsControl',
multi: true,
label: t('Metrics'),
validators: [v.nonEmpty],
default: (c) =>
const metric = mainMetric(c.savedMetrics);
return metric ? [metric] : null;
,
mapStateToProps: (state) =>
const datasource = state.datasource;
return
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource && datasource.type,
;
,
description: t('One or many metrics to display'),
;
const metric =
...metrics,
multi: false,
label: t('Metric'),
default: props => mainMetric(props.savedMetrics),
;


Country map is using metric, which doesn't allow multiple metrics to be selected, Code found here:




superset/assets/src/explore/controlPanels/CountryMap.js




 controlPanelSections: [

label: t('Query'),
expanded: true,
controlSetRows: [
['entity'],
['metric'],
['adhoc_filters'],
],
,

label: t('Options'),
expanded: true,
controlSetRows: [
['select_country', 'number_format'],
['linear_color_scheme'],
],
,
],


The python class of country_map is located at viz.py:



class CountryMapViz(BaseViz):

"""A country centric"""

viz_type = 'country_map'
verbose_name = _('Country Map')
is_timeseries = False
credits = 'From bl.ocks.org By john-guerra'

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = [
self.form_data['metric']]
qry['groupby'] = [self.form_data['entity']]
return qry


Changing the code in CountryMap.js and viz.py from metric to metrics results in the following error:



Traceback (most recent call last):
File "/Documents/superset/superset/superset/viz.py", line 410, in get_df_payload
df = self.get_df(query_obj)
File "/Documents/superset/superset/superset/viz.py", line 213, in get_df
self.results = self.datasource.query(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 797, in query
sql = self.get_query_str(query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 471, in get_query_str
qry = self.get_sqla_query(**query_obj)
File "/Documents/superset/superset/superset/connectors/sqla/models.py", line 585, in get_sqla_query
elif m in metrics_dict:
TypeError: unhashable type: 'list'


How can I add more metrics to display inside the polygon?







javascript python d3.js apache-superset






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 9:59







Snow

















asked Feb 11 at 9:59









SnowSnow

793628




793628












  • What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

    – gdlmx
    Mar 7 at 9:31











  • @gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

    – Snow
    Mar 7 at 9:56

















  • What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

    – gdlmx
    Mar 7 at 9:31











  • @gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

    – Snow
    Mar 7 at 9:56
















What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

– gdlmx
Mar 7 at 9:31





What did you modify exactly? Could you post your modification to CountryMap.js and viz.py?

– gdlmx
Mar 7 at 9:31













@gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

– Snow
Mar 7 at 9:56





@gdlmx In CountryMap.js I changed ['metric'] to ['metrics']. I did the same in viz.py, at the CountryMapViz class, where I just modified self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.

– Snow
Mar 7 at 9:56












1 Answer
1






active

oldest

votes


















1














The direct cause of the error TypeError: unhashable type: 'list' is your modification to file "viz.py":




self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.




As you can see in the source code here, form data metrics is a list object that contains metric, where metric is probably a string or other hashable object. In python language, a list object is not hashable. Because you replace a hashable object (metric) with an unhashable one (metrics), an unhashable type error is then raised.



The correct way to modify CoutryMapViz.query_obj() to accept metrics query can be found in the other Viz classes. The code section here is a very nice example:




class CalHeatmapViz(BaseViz):

"""Calendar heatmap."""
...

def query_obj(self):
d = super(CalHeatmapViz, self).query_obj()
fd = self.form_data
d['metrics'] = fd.get('metrics')
return d


Finally, the CoutryMapViz.query_obj() method should look like this:



class CountryMapViz(BaseViz):

...

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = fd.get('metrics')
qry['groupby'] = [self.form_data['entity']]
return qry





share|improve this answer

























  • This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

    – Snow
    Mar 7 at 14:39











  • This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

    – gdlmx
    Mar 7 at 17:47











  • To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

    – gdlmx
    Mar 7 at 17:58











  • my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

    – Snow
    Mar 8 at 11:29











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54627930%2fhow-to-add-more-metrics-on-the-country-map-in-apache-superset%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The direct cause of the error TypeError: unhashable type: 'list' is your modification to file "viz.py":




self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.




As you can see in the source code here, form data metrics is a list object that contains metric, where metric is probably a string or other hashable object. In python language, a list object is not hashable. Because you replace a hashable object (metric) with an unhashable one (metrics), an unhashable type error is then raised.



The correct way to modify CoutryMapViz.query_obj() to accept metrics query can be found in the other Viz classes. The code section here is a very nice example:




class CalHeatmapViz(BaseViz):

"""Calendar heatmap."""
...

def query_obj(self):
d = super(CalHeatmapViz, self).query_obj()
fd = self.form_data
d['metrics'] = fd.get('metrics')
return d


Finally, the CoutryMapViz.query_obj() method should look like this:



class CountryMapViz(BaseViz):

...

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = fd.get('metrics')
qry['groupby'] = [self.form_data['entity']]
return qry





share|improve this answer

























  • This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

    – Snow
    Mar 7 at 14:39











  • This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

    – gdlmx
    Mar 7 at 17:47











  • To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

    – gdlmx
    Mar 7 at 17:58











  • my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

    – Snow
    Mar 8 at 11:29
















1














The direct cause of the error TypeError: unhashable type: 'list' is your modification to file "viz.py":




self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.




As you can see in the source code here, form data metrics is a list object that contains metric, where metric is probably a string or other hashable object. In python language, a list object is not hashable. Because you replace a hashable object (metric) with an unhashable one (metrics), an unhashable type error is then raised.



The correct way to modify CoutryMapViz.query_obj() to accept metrics query can be found in the other Viz classes. The code section here is a very nice example:




class CalHeatmapViz(BaseViz):

"""Calendar heatmap."""
...

def query_obj(self):
d = super(CalHeatmapViz, self).query_obj()
fd = self.form_data
d['metrics'] = fd.get('metrics')
return d


Finally, the CoutryMapViz.query_obj() method should look like this:



class CountryMapViz(BaseViz):

...

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = fd.get('metrics')
qry['groupby'] = [self.form_data['entity']]
return qry





share|improve this answer

























  • This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

    – Snow
    Mar 7 at 14:39











  • This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

    – gdlmx
    Mar 7 at 17:47











  • To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

    – gdlmx
    Mar 7 at 17:58











  • my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

    – Snow
    Mar 8 at 11:29














1












1








1







The direct cause of the error TypeError: unhashable type: 'list' is your modification to file "viz.py":




self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.




As you can see in the source code here, form data metrics is a list object that contains metric, where metric is probably a string or other hashable object. In python language, a list object is not hashable. Because you replace a hashable object (metric) with an unhashable one (metrics), an unhashable type error is then raised.



The correct way to modify CoutryMapViz.query_obj() to accept metrics query can be found in the other Viz classes. The code section here is a very nice example:




class CalHeatmapViz(BaseViz):

"""Calendar heatmap."""
...

def query_obj(self):
d = super(CalHeatmapViz, self).query_obj()
fd = self.form_data
d['metrics'] = fd.get('metrics')
return d


Finally, the CoutryMapViz.query_obj() method should look like this:



class CountryMapViz(BaseViz):

...

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = fd.get('metrics')
qry['groupby'] = [self.form_data['entity']]
return qry





share|improve this answer















The direct cause of the error TypeError: unhashable type: 'list' is your modification to file "viz.py":




self.form_data['metric']] to self.form_data['metrics']], in the query_obj(self) method.




As you can see in the source code here, form data metrics is a list object that contains metric, where metric is probably a string or other hashable object. In python language, a list object is not hashable. Because you replace a hashable object (metric) with an unhashable one (metrics), an unhashable type error is then raised.



The correct way to modify CoutryMapViz.query_obj() to accept metrics query can be found in the other Viz classes. The code section here is a very nice example:




class CalHeatmapViz(BaseViz):

"""Calendar heatmap."""
...

def query_obj(self):
d = super(CalHeatmapViz, self).query_obj()
fd = self.form_data
d['metrics'] = fd.get('metrics')
return d


Finally, the CoutryMapViz.query_obj() method should look like this:



class CountryMapViz(BaseViz):

...

def query_obj(self):
qry = super(CountryMapViz, self).query_obj()
qry['metrics'] = fd.get('metrics')
qry['groupby'] = [self.form_data['entity']]
return qry






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 7 at 14:15

























answered Mar 7 at 14:06









gdlmxgdlmx

3,6521931




3,6521931












  • This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

    – Snow
    Mar 7 at 14:39











  • This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

    – gdlmx
    Mar 7 at 17:47











  • To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

    – gdlmx
    Mar 7 at 17:58











  • my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

    – Snow
    Mar 8 at 11:29


















  • This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

    – Snow
    Mar 7 at 14:39











  • This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

    – gdlmx
    Mar 7 at 17:47











  • To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

    – gdlmx
    Mar 7 at 17:58











  • my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

    – Snow
    Mar 8 at 11:29

















This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

– Snow
Mar 7 at 14:39





This change however does not make a difference in the metrics shown inside the polygon. Even if you select more than 1 metric in the form, only the first selected metric will be shown when you hover on or click the polygons

– Snow
Mar 7 at 14:39













This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

– gdlmx
Mar 7 at 17:47





This is to do with the get_data method. You can use the codes in the CalHeatmapViz.get_data() function as an example.

– gdlmx
Mar 7 at 17:47













To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

– gdlmx
Mar 7 at 17:58





To make the chart display correct, you need to modify the propTypes in CountryMap.js and CoutryMapViz.get_data() in viz.py. This is another question that worth to be discussed in another post.

– gdlmx
Mar 7 at 17:58













my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

– Snow
Mar 8 at 11:29






my question however is not about getting rid of the Type error, but rather about the end result being functional. But regardless, thanks for your contribution and the suggestions in the comment

– Snow
Mar 8 at 11:29




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54627930%2fhow-to-add-more-metrics-on-the-country-map-in-apache-superset%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

Zrinski family tree See also Navigation menu