Need to accept empty data
See original GitHub issueErrors occurred when I tried to use empty data
object to initialize a chart instance.
const chart = new frappe.Chart('.panel .chart', {
data: {},
type: 'line',
height: 320,
colors: ['#0294FF'],
})
This caused an Uncaught TypeError:
frappe-charts.min.iife.js:1 Uncaught TypeError: Cannot read property 'map' of undefined
at Ct (frappe-charts.min.iife.js:1)
at i.value (frappe-charts.min.iife.js:1)
at i.e (frappe-charts.min.iife.js:1)
at new i (frappe-charts.min.iife.js:1)
at Tt (frappe-charts.min.iife.js:1)
at new t (frappe-charts.min.iife.js:1)
at HTMLDocument.<anonymous> (stats-overview.js:20)
at l (jquery.js:2)
at Object.fireWith [as resolveWith] (jquery.js:2)
at Function.ready (jquery.js:2)
Seems frappe tried to call map
function of datasets
or labels
. But I only need to create an empty chart at that time, and update data on future user events.
I tried to use this as init data
{
labels: [],
datasets: [],
}
and got a lot of SVG errors which blocked the future data updatings.
Error: <g> attribute transform: Trailing garbage, "translate(0, undefined)".
It’s weird that
{
labels: [''],
datasets: [{
values: [0],
}],
}
also cause some errors such as
frappe-charts.min.iife.js:1 Error: <path> attribute d: Unexpected end of attribute. Expected number, "M".
and
Error: <circle> attribute cy: Expected length, "undefined".
but without blocking future updatings.
Seems it only works fine with two or more data points.
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:9
Top Results From Across the Web
c# - Data annotations for handling empty strings - Stack Overflow
This will let empty strings go through, but on a query for a list of entities already in the table that include null...
Read more >When to use NULL and when to use an empty string?
NULL means absence of value (i.e. there is no value), while empty string means there is a string value of zero length. For...
Read more >how to validate empty data in transform map? - ServiceNow
Hi All,. I need to validate below excel data while doing transform load (before loading to table). Validation should be like if the...
Read more >Blank, Coalesce, IsBlank, and IsEmpty functions in Power Apps
Some controls and data sources use an empty string to indicate a "no value" condition. To simplify app creation, the IsBlank and Coalesce ......
Read more >Handling JSON null and empty arrays and objects - IBM
JSON data has the concept of null and empty arrays and objects. This section explains how each of these concepts is mapped to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for your help. But actually for me, it’s not a perfect solution 😂. I don’t know any of the labels until the server responds them via an xhr (for example last 30 days as labels). Better if frappe could draw an empty chart without any data or labels provided at initialization. Now I manually set two labels as a walkaround, it seems a little bit strange showing two unrelated zero data points on every refresh before real data loaded.
The when creating charts it is necessary to provide the labels at least. With the labels in place the Charts will automatically fill in the value 0 as default for the missing values.
So a config like the following will work without any errors.
I hope this answers your question.