namespace anychart.utils Improve this Doc
The anychart.utils namespace contains static utility methods.
Functions Overview
hideTooltips() | Hide all tooltips. |
htmlTableFromCsv() | Creates HTML Table from CSV string. |
json2xml() | Converts JSON object to an XML Node tree or String (string by default). |
xml2json() | Public function that parses XML and returns JSON. It hides all errors in |
Typedefs Overview
anychart.utils.RectObj | Type definition for the rectangle. |
Functions Description
hideTooltips
Hide all tooltips.
Params:
Name | Type | Description |
---|---|---|
force | boolean | Ignore tooltips hide delay. |
htmlTableFromCsv
Creates HTML Table from CSV string.
Params:
Name | Type | Description |
---|---|---|
csv | string | CSV string. |
title | string | Title to set. |
asString | boolean | Defines output: HTML string if True, DOM element if False. |
csvSettings | Object | CSV settings. |
Returns:
Element - HTML table instance, HTML string or null if parsing CSV to table fails.json2xml
Converts JSON object to an XML Node tree or String (string by default).
Params:
Name | Type | Description |
---|---|---|
json | Object | string | JSON source object or string. |
rootNodeName | string | Root node name. |
returnAsXmlNode | boolean | Whether to return value as XML node. |
Returns:
string | Node -xml2json
Public function that parses XML and returns JSON. It hides all errors in
Document structure, so the result may be not as strict as expected.
The function converts XML string or node to an object with attributes
introduced as same named string properties. All subnodes are also converted to
correspondingly named properties by the next rules:
- if there is only one child with this name, it is converted into an object
an added just as an object property to the parent object.
- if there are multiple children with the same name, they are also converted
to separate objects and then added to the parent object as an array.
- if there is an attribute named just like the node(s), the node(s) will
completely replace the attribute.
- if there is any text value or a CDATA node or any their combination in the
node, that value is stored as a string in a property named "value" even in
cases when there is a subnode named "value" (but the node with this name
still can be found in '#children#' array mentioned below).
Also some service properties are added to an object representing a node:
- '#name#' property - the node name
- '#children#' array property - all node children listed in order they appear
in the node
- mentioned above 'value' string property - contains textual value of the
node
Usage sample:
var a = new XMLHttpRequest(); a.open('GET', 'https://sample.com', false, '', ''); a.send(null); // for example there was the next XML: //json variable will have the following structure: { #name#: 'root', #children#: [ {#name#: 'child', #children#: []}, {#name#: 'child', #children#: [], value: 'some text value and a CDATA '} {#name#: 'child_other', #children#: []} ], a: '123', child: [ {#name#: 'child', #children#: []}, {#name#: 'child', #children#: [], value: 'some text value and a CDATA '} ], child_other: {#name#: 'child_other', #children#: []} }// var json = anychart.utils.XML2JSON(a.responseXML);// some text value ////
Params:
Name | Type | Description |
---|---|---|
xml | string | Node | XML source string. |
Returns:
Object | string - Transformation result JSON (may by null).