src/js/extensions/chart/chart.js
function parseCode2DataAndOptions(code, callback) {
  code = trimKeepingTabs(code);
  const [firstCode, secondCode] = code.split(/\n{2,}/);

  // try to parse first code block as `options`
  let options = parseCode2ChartOption(firstCode);
  const url = options && options.editorChart && options.editorChart.url;

  // if first code block is `options` and has `url` option, fetch data from url
  let dataAndOptions;
  if (util.isString(url)) {
    // url option provided
    // fetch data from url
    const success = dataCode => {
      dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
      callback(dataAndOptions);
    };
    const fail = () => callback(null);

    $.get(url).done(success).fail(fail);
  } else {
    // else first block is `data`
    dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
    callback(dataAndOptions);
  }
}
function parseCode2DataAndOptions(code, callback) {
  code = trimKeepingTabs(code);
  const [firstCode, secondCode] = code.split(/\n{2,}/);

  // try to parse first code block as `options`
  let options = parseCode2ChartOption(firstCode);
  const url = options && options.editorChart && options.editorChart.url;

  // if first code block is `options` and has `url` option, fetch data from url
  let dataAndOptions;
  if (util.isString(url)) {
    // url option provided
    // fetch data from url
    const success = dataCode => {
      dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
      callback(dataAndOptions);
    };
    const fail = () => callback(null);

    $.get(url).done(success).fail(fail);
  } else {
    // else first block is `data`
    dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
    callback(dataAndOptions);
  }
}
function parseCode2DataAndOptions ( code , callback ) { code = trimKeepingTabs ( code ) ; const [ firstCode , secondCode ] = code . split ( / \n{2,} / ) ; // try to parse first code block as `options` let options = parseCode2ChartOption ( firstCode ) ; const url = options && options . editorChart && options . editorChart . url ; // if first code block is `options` and has `url` option, fetch data from url let dataAndOptions ; if ( util . isString ( url ) ) { // url option provided // fetch data from url const success = dataCode => { dataAndOptions = _parseCode2DataAndOptions ( dataCode , firstCode ) ; callback ( dataAndOptions ) ; } ; const fail = ( ) => callback ( null ) ; $ . get ( url ) . done ( success ) . fail ( fail ) ; } else { // else first block is `data` dataAndOptions = _parseCode2DataAndOptions ( firstCode , secondCode ) ; callback ( dataAndOptions ) ; } }
parse data and options for tui.chart
data format can be csv, tsv
options format is colon separated keys & values
@param {string} code - plain text format data & options
@param {Function} callback - callback which provides json format data & options
@ignore
parse data and options for tui . chart data format can be csv tsv options format is colon separated keys & values