Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery from highchart add-in #2584

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ var BEFORE_CHART_FORMAT_TEMPLATE =
// Initialization of the control add-in.
// Note: This function is called by the manifest after loading the control add-in.
function Initialize() {
$(window).resize(function () {
var width = $(this).width();
var height = $(this).height();
window.addEventListener('resize', function () {
var width = window.document.documentElement.getBoundingClientRect().width;
var height = window.document.documentElement.getBoundingClientRect().height;

onChartSizeChanged(width, height);
});

raiseAddInReady();
}

function controlAddIn() {
return document.getElementById('controlAddIn');
}

// Update the chart with the supplied chart data.
// Note: This function is called from the application code.
function Update(chartData) {
Expand Down Expand Up @@ -96,7 +100,7 @@ function createUI(chartData) {
}

// Remove any existing content
$("#controlAddIn").empty();
controlAddIn().innerHTML = '';

if (validateChartData(chartData)) {
initializeChartLanguage(chartData);
Expand Down Expand Up @@ -152,9 +156,11 @@ function validateYAxisRange(chartData) {

// Create a DIV containing the specified message text.
function createMessage(text) {
$("#controlAddIn").append(
'<div class="' + getMessageClassName() + '"><span>' + text + "</span></div>"
);
var element = document.createElement("div");
element.className = getMessageClassName();
element.innerHTML = '<span>' + text + '<span>';

controlAddIn().appendChild(element);
}

// Initialize the month, short month, and weekday names of the chart.
Expand Down Expand Up @@ -403,10 +409,12 @@ function createChart(chartData) {
);

// Make chart non-focusable
$(chart.container).find("svg").attr("focusable", "false");
chart.container.querySelectorAll("svg").forEach(svg => {
svg.setAttribute("focusable", "false")
});

var width = $(chart.container).width();
var height = $(chart.container).height();
var width = chart.container.getBoundingClientRect().width;
var height = chart.container.getBoundingClientRect().height;

// Update the size-dependent properties
if (width > 0 && height > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ controladdin BusinessChart
HorizontalShrink = true;

Scripts = 'Resources\BusinessChart\js\BusinessChartAddIn.js',
'https://bc-cdn.dynamics.com/common/js/jquery-3.5.1.min.js',
'https://bc-cdn.dynamics.com/common/js/highcharts-9.1.1.js',
'https://bc-cdn.dynamics.com/common/js/highcharts-more-9.1.1.js',
'https://bc-cdn.dynamics.com/common/js/accessibility-9.1.1.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ controladdin "Microsoft.Dynamics.Nav.Client.BusinessChart"
HorizontalShrink = true;

Scripts = 'Resources\BusinessChart\js\BusinessChartAddIn.js',
'https://bc-cdn.dynamics.com/common/js/jquery-3.5.1.min.js',
'https://bc-cdn.dynamics.com/common/js/highcharts-9.1.1.js',
'https://bc-cdn.dynamics.com/common/js/highcharts-more-9.1.1.js',
'https://bc-cdn.dynamics.com/common/js/accessibility-9.1.1.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ var BEFORE_CHART_FORMAT_TEMPLATE =
// Initialization of the control add-in.
// Note: This function is called by the manifest after loading the control add-in.
function Initialize() {
$(window).resize(function () {
var width = $(this).width();
var height = $(this).height();
window.addEventListener('resize', function () {
var width = window.document.documentElement.getBoundingClientRect().width;
var height = window.document.documentElement.getBoundingClientRect().height;

onChartSizeChanged(width, height);
});

raiseAddInReady();
}

function controlAddIn() {
return document.getElementById('controlAddIn');
}

// Update the chart with the supplied chart data.
// Note: This function is called from the application code.
function Update(chartData) {
Expand Down Expand Up @@ -96,7 +100,7 @@ function createUI(chartData) {
}

// Remove any existing content
$("#controlAddIn").empty();
controlAddIn().innerHTML = '';

if (validateChartData(chartData)) {
initializeChartLanguage(chartData);
Expand Down Expand Up @@ -152,9 +156,11 @@ function validateYAxisRange(chartData) {

// Create a DIV containing the specified message text.
function createMessage(text) {
$("#controlAddIn").append(
'<div class="' + getMessageClassName() + '"><span>' + text + "</span></div>"
);
var element = document.createElement("div");
element.className = getMessageClassName();
element.innerHTML = '<span>' + text + '<span>';

controlAddIn().appendChild(element);
}

// Initialize the month, short month, and weekday names of the chart.
Expand Down Expand Up @@ -403,10 +409,12 @@ function createChart(chartData) {
);

// Make chart non-focusable
$(chart.container).find("svg").attr("focusable", "false");
chart.container.querySelectorAll("svg").forEach(svg => {
svg.setAttribute("focusable", "false")
});

var width = $(chart.container).width();
var height = $(chart.container).height();
var width = chart.container.getBoundingClientRect().width;
var height = chart.container.getBoundingClientRect().height;

// Update the size-dependent properties
if (width > 0 && height > 0) {
Expand Down
Loading