How to add more metrics on the country_map in Apache-superset?How 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?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

What is the term when two people sing in harmony, but they aren't singing the same notes?

Stereotypical names

Can I Retrieve Email Addresses from BCC?

Bob has never been a M before

Is there enough fresh water in the world to eradicate the drinking water crisis?

Would it be legal for a US State to ban exports of a natural resource?

Female=gender counterpart?

Can a malicious addon access internet history and such in chrome/firefox?

What does the "3am" section means in manpages?

Java - What do constructor type arguments mean when placed *before* the type?

Should my PhD thesis be submitted under my legal name?

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

Can the harmonic series explain the origin of the major scale?

Is the next prime number always the next number divisible by the current prime number, except for any numbers previously divisible by primes?

Is there a good way to store credentials outside of a password manager?

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

Have I saved too much for retirement so far?

Teaching indefinite integrals that require special-casing

What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?

Did US corporations pay demonstrators in the German demonstrations against article 13?

I2C signal and power over long range (10meter cable)

Can I create an upright 7-foot × 5-foot wall with the Minor Illusion spell?

For airliners, what prevents wing strikes on landing in bad weather?



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


How 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

793728




793728












  • 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,86611032




3,86611032












  • 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

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович