-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Feature Proposal
I have a large dataset that I'm plotting where existing keys are often of the form "foo.bar". That dataset is already being used elsewhere in the application so changing it is not an option.
chart.js assumes that a '.' is only used to denote nested keys in objects, ie: interpreting the above as referring to {foo: { bar: 42 } }, whereas I need it to refer to { "foo.bar" : 42 }
Possible Implementation
The optimal approach would be to allow for escaping when defining the axis key, ie: 'yAxisKey' : 'foo\.bar'. In reality, the classic slash escape char would often need to be written as an uglier "foo\.bar", so perhaps a double-dot ("..") would work better.
Alternatively, a simpler approach, which I'm now using with a quick-patch, is to disable searching for nested objects if the key begins with a '.', ie: yAxisKey: '.foo.bar'.
function resolveObjectKey(obj, key) {
if (key === emptyString) {
return obj;
} else if (key[0] == '.') {
// A key starting with a '.' means nested names should not be resolved for this case
return obj[key.substr(1)];
}
let pos = 0;
...