question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to keep null values in generated options

See original GitHub issue

Despite the big effort made in pyecharts, it normal to find ECharts options unavailable using pyecharts classes. This is where the _option attribute becomes helpful (is there a better way?). Sometimes an ECharts option needs to be set to null as in the example below when setting a candlestick chart.

itemStyle: {
  normal: {
    color: '#06B800',
    color0: '#FA0000',
    borderColor: null,
    borderColor0: null
    }
}

When adding these keys to _option, the keys whose value is None are removes from the generated options because of the following code in the Base class:

@property
def options(self):
    return utils.remove_key_with_none_value(self._option)

Also this makes it harder when there’s a lot of work needs to be done with _option as the removed keys need to be recreated first. For example, in the example above itemStyle needed to be created first, then the dictionary value assigned ({'normal' : { 'color': ...} }) assigned instead of accessing individual keys.

Is there a way to handle this? if not, I suggest adding an option to preserve null values in the generated options such as:

bar = Bar(remove_none_options=True)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chfwcommented, Aug 30, 2018

OK. Just checked the options documentation, if pyecharts omits both options, borderColor defaults to #c23531 and borderColor0 defaults to #314656.

So I would propose that pyecharts provides ‘NULL’ definition to signal that the key should be present and with value ‘null’ in js/html. In this way, remove_key_with_none_value() will ignore NULLed keys.

0reactions
YasserHassancommented, Aug 31, 2018

Great. What do you think the best value that NOT_SET should take? I think NumPy’s way of using nanis good if there’s no other safe value in mind. As show in numpy.nan’s documentation, it is “IEEE 754 floating point representation of Not a Number (NaN)”. In this case, is_not_set() could be the equivalent of NumPy’s isnan() to test for unassigned options.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Include Null Values in JSON - SQL Server - Microsoft Learn
In this article​​ To include null values in the JSON output of the FOR JSON clause, specify the INCLUDE_NULL_VALUES option. If you don't...
Read more >
How to keep null values when writing to csv - Stack Overflow
Naming the columns in a FORCE_NULL option lets PostgreSQL accept both the empty column and "" as NULL values for those columns, e.g.:...
Read more >
Working with SQL NULL values - SQLShack
This article will show functions and operators for handling SQL NULL values.
Read more >
Dealing with null in Spark - MungingData
Let's create a DataFrame with a name column that isn't nullable and an age ... You can keep null values out of certain...
Read more >
Handling Null and Other Special Values - Tableau Help
When a measure contains null values, they are usually plotted in a view as zero. To see other options, including how to suppress...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found