private static void AppendWidgetCode(StringBuilder stringBuilder, TabularDataResourceJsonString data, string divId, string functionName, Uri libraryUri, string libraryVersion, string cacheBuster) { libraryVersion ??= "1.0.0"; stringBuilder.AppendLine($@" let {functionName} = () => {{"); if (libraryUri != null) { var libraryAbsoluteUri = libraryUri.AbsoluteUri.Replace(".js", string.Empty); cacheBuster ??= libraryAbsoluteUri.GetHashCode().ToString("0"); stringBuilder.AppendLine($@" (require.config({{ 'paths': {{ 'context': '{libraryVersion}', 'nteractUri' : '{libraryAbsoluteUri}', 'urlArgs': 'cacheBuster={cacheBuster}' }}}}) || require)(['nteractUri'], (nteract) => {{"); } else { stringBuilder.AppendLine($@" configureRequireFromExtension('nteract','{libraryVersion}')(['nteract/nteractapi'], (nteract) => {{"); } stringBuilder.AppendLine($@" nteract.createDataExplorer({{ data: {data}, container: document.getElementById(""{divId}"") }}); }}, (error) => {{ console.log(error); }}); }};"); }
private static void GenerateCode(TabularDataResourceJsonString data, StringBuilder code, string divId, string requireUri, Uri uri, string context, string cacheBuster) { var functionName = $"renderDataExplorer_{divId}"; GenerateFunctionCode(data, code, divId, functionName, uri, context, cacheBuster); GenerateRequireLoader(code, functionName, requireUri); }
private static void GenerateFunctionCode(TabularDataResourceJsonString data, StringBuilder code, string divId, string functionName, Uri uri, string context, string cacheBuster) { context ??= "1.0.0"; code.AppendLine($@" let {functionName} = () => {{"); if (uri != null) { var absoluteUri = uri.AbsoluteUri.Replace(".js", string.Empty); cacheBuster ??= absoluteUri.GetHashCode().ToString("0"); code.AppendLine($@" (require.config({{ 'paths': {{ 'context': '{context}', 'nteractUri' : '{absoluteUri}', 'urlArgs': 'cacheBuster={cacheBuster}' }}}}) || require)(['nteractUri'], (nteract) => {{"); } else { code.AppendLine($@" configureRequireFromExtension('nteract','{context}')(['nteract/nteractapi'], (nteract) => {{"); } code.AppendLine($@" nteract.createDataExplorer({{ data: {data}, container: document.getElementById(""{divId}"") }}); }}, (error) => {{ console.log(error); }}); }};"); }
private static void GenerateCode(TabularDataResourceJsonString data, StringBuilder code, string divId, string requireUri, Uri uri, string context, string cacheBuster) { var functionName = $"renderSandDanceExplorer_{divId}"; AppendWidgetCode(code, data, divId, functionName, uri, context, cacheBuster); }