Skip to content

[Excel] (Chart) Add leader lines snippet #992

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

alison-mk
Copy link
Contributor

@alison-mk alison-mk commented Jul 18, 2025

This PR adds a sample showing how to adjust leader lines for chart data labels.

@alison-mk alison-mk requested a review from Copilot July 18, 2025 17:34
Copilot

This comment was marked as outdated.

@alison-mk alison-mk requested a review from Copilot July 18, 2025 18:38
Copilot

This comment was marked as outdated.

@alison-mk alison-mk requested a review from Copilot August 11, 2025 23:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive sample demonstrating how to work with leader lines for chart data labels in Excel. The sample shows how to enable, disable, and format leader lines, which are visual connectors between data labels and their corresponding chart points.

Key changes:

  • Adds a new leader lines snippet with functions to manipulate leader line visibility and formatting
  • Updates configuration files to include the new sample in both development and production environments
  • Generates corresponding API documentation snippets for the Excel Office.js library

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
view/excel.json Adds reference to the leader lines sample for development environment
view-prod/excel.json Adds reference to the leader lines sample for production environment
snippet-extractor-output/snippets.yaml Generates API documentation snippets for leader lines functionality
samples/excel/10-chart/chart-leader-lines.yaml New complete sample demonstrating leader lines manipulation with setup, enable/disable, and formatting functions
playlists/excel.yaml Adds leader lines sample to development playlist
playlists-prod/excel.yaml Adds leader lines sample to production playlist

@alison-mk alison-mk marked this pull request as ready for review August 11, 2025 23:37
@alison-mk alison-mk requested a review from davidchesnut August 11, 2025 23:38
Copy link
Member

@davidchesnut davidchesnut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Looks good!

await context.sync();

// Move some data labels to create distance from their chart points.
series.points.items[1].dataLabel.top = series.points.items[1].dataLabel.top - 50;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a little more readable.

const point1 = series.points.items[1];
const point2 = series.points.items[2];

point1.dataLabel.top -= 50;
point2.dataLabel.top += 50;

});
}

async function disableLeaderLines() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling this hideLeaderLines (and throughout). Disable implies the leader lines don't work, which sort of means they are hidden, but it's also a bit ambiguous and doesn't match the UI button.

});
}

async function enableLeaderLines() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestion as previous. Consider using showLeaderLines (or showChartLeaderLines if worried about same names as the property later).

await context.sync();

// Move some data labels to create distance from their chart points.
series.points.items[1].dataLabel.top = series.points.items[1].dataLabel.top - 50;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a little more readable.

const point1 = series.points.items[1];
const point2 = series.points.items[2];

point1.dataLabel.top -= 50;
point2.dataLabel.top += 50;

await context.sync();

// Move some data labels to create distance from their chart points.
series.points.items[1].dataLabel.top = series.points.items[1].dataLabel.top - 50;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a little more readable.

const point1 = series.points.items[1];
const point2 = series.points.items[2];

point1.dataLabel.top -= 50;
point2.dataLabel.top += 50;

https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml


// This function adds data labels to the chart and positions them to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This function adds data labels to the chart and positions them to
// The following code adds data labels to the chart and positions them to

https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml


// This function changes the format of leader lines.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This function changes the format of leader lines.
// The following code changes the format of leader lines.


// This function changes the format of leader lines.

// It adjusts color, weight, and line style.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe combine this with previous comment.

Suggested change
// It adjusts color, weight, and line style.
// The following code adjusts color, weight, and line style.

https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml


// This function changes the format of leader lines.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This function changes the format of leader lines.
// The following code changes the format of leader lines.


// This function changes the format of leader lines.

// It adjusts color, weight, and line style.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe combine this comment with previous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants