-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
#10836 add getLabelItems public method #10837
Closed
cmcnulty
wants to merge
10
commits into
chartjs:master
from
cmcnulty:feature-10836-expose-label-items
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8499920
fix #10836 - add publc getLabelItems()
cmcnulty 421ff52
textOffset not a render option
cmcnulty 58cb9e6
rename renderTextOptions to options
cmcnulty 67d9a93
fix import
cmcnulty 3dd774a
condense imports
cmcnulty 71be6c3
revert to known-passing imports
cmcnulty b2e06de
try again - passing locally
cmcnulty 87c99f2
Merge branch 'master' of https://github.com/LeeLenaleee/Chart.js into…
LeeLenaleee 159435c
merge conflict, update path to canvas font spec
LeeLenaleee 7f16c70
Merge branch 'master' into feature-10836-expose-label-items
LeeLenaleee File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { PointStyle } from '../index.js'; | ||
import { Color } from '../color.js'; | ||
import { ChartArea, RoundedRect } from '../geometric.js'; | ||
import { CanvasFontSpec } from '../../src/helpers/helpers.options.js'; | ||
import { PointStyle, Scriptable, ScriptableScaleContext } from '../index.js'; | ||
import { Color } from '../color'; | ||
import { ChartArea, RoundedRect } from '../geometric'; | ||
import { CanvasFontSpec } from '../../src/helpers/helpers.options'; | ||
Comment on lines
+2
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add js extension |
||
|
||
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void; | ||
|
||
|
@@ -72,13 +72,13 @@ export interface RenderTextOpts { | |
* The text alignment to use. If unset, the existing | ||
* textAlign property of the context is unchanged | ||
*/ | ||
textAlign: CanvasTextAlign; | ||
textAlign?: CanvasTextAlign; | ||
|
||
/** | ||
* The text baseline to use. If unset, the existing | ||
* textBaseline property of the context is unchanged | ||
*/ | ||
textBaseline: CanvasTextBaseline; | ||
textBaseline?: CanvasTextBaseline; | ||
|
||
/** | ||
* If specified, a translation to apply to the context | ||
|
@@ -89,6 +89,38 @@ export interface RenderTextOpts { | |
* Underline the text | ||
*/ | ||
underline?: boolean; | ||
|
||
/** | ||
* Dimensions for drawing the label backdrop | ||
*/ | ||
backdrop?: BackdropOptions; | ||
} | ||
|
||
export interface BackdropOptions { | ||
/** | ||
* Left position of backdrop as pixel | ||
*/ | ||
left: number; | ||
|
||
/** | ||
* Top position of backdrop as pixel | ||
*/ | ||
top: number; | ||
|
||
/** | ||
* Width of backdrop in pixels | ||
*/ | ||
width: number; | ||
|
||
/** | ||
* Height of backdrop in pixels | ||
*/ | ||
height: number; | ||
|
||
/** | ||
* Color of label backdrops. | ||
*/ | ||
color: Scriptable<Color, ScriptableScaleContext>; | ||
} | ||
|
||
export function renderText( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils.js'; | ||
|
||
import { TimeUnit } from '../src/core/core.adapters.js'; | ||
import PointElement from '../src/elements/element.point.js'; | ||
import { EasingFunction } from '../src/helpers/helpers.easing.js'; | ||
import { AnimationEvent } from './animation.js'; | ||
import { AnyObject, EmptyObject } from './basic.js'; | ||
import { Color } from './color.js'; | ||
import Element from '../src/core/core.element.js'; | ||
import { ChartArea, Padding, Point } from './geometric.js'; | ||
import { LayoutItem, LayoutPosition } from './layout.js'; | ||
|
||
export { EasingFunction } from '../src/helpers/helpers.easing.js'; | ||
export { default as ArcElement, ArcProps } from '../src/elements/element.arc.js'; | ||
export { default as PointElement, PointProps } from '../src/elements/element.point.js'; | ||
export { Animation, Animations, Animator, AnimationEvent } from './animation.js'; | ||
export { Color } from './color.js'; | ||
export { ChartArea, Point } from './geometric.js'; | ||
export { LayoutItem, LayoutPosition } from './layout.js'; | ||
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils'; | ||
|
||
import { TimeUnit } from '../src/core/core.adapters'; | ||
import PointElement from '../src/elements/element.point'; | ||
import { EasingFunction } from '../src/helpers/helpers.easing'; | ||
import { AnimationEvent } from './animation'; | ||
import { AnyObject, EmptyObject } from './basic'; | ||
import { Color } from './color'; | ||
import Element from '../src/core/core.element'; | ||
import { ChartArea, Padding, Point } from './geometric'; | ||
import { LayoutItem, LayoutPosition } from './layout'; | ||
import { RenderTextOpts } from './helpers/helpers.canvas'; | ||
import { CanvasFontSpec } from '../src/helpers/helpers.options'; | ||
|
||
export { EasingFunction } from '../src/helpers/helpers.easing'; | ||
export { default as ArcElement, ArcProps } from '../src/elements/element.arc'; | ||
export { default as PointElement, PointProps } from '../src/elements/element.point'; | ||
export { Animation, Animations, Animator, AnimationEvent } from './animation'; | ||
export { Color } from './color'; | ||
export { ChartArea, Point } from './geometric'; | ||
export { LayoutItem, LayoutPosition } from './layout'; | ||
Comment on lines
+1
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same |
||
|
||
export interface ScriptableContext<TType extends ChartType> { | ||
active: boolean; | ||
|
@@ -1311,6 +1313,7 @@ export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends El | |
getMinMax(canStack: boolean): { min: number; max: number }; | ||
getTicks(): Tick[]; | ||
getLabels(): string[]; | ||
getLabelItems(chartArea?: ChartArea): LabelItem[]; | ||
beforeUpdate(): void; | ||
configure(): void; | ||
afterUpdate(): void; | ||
|
@@ -1354,6 +1357,12 @@ export interface ScriptableScalePointLabelContext { | |
type: string; | ||
} | ||
|
||
export interface LabelItem { | ||
label: string | string[]; | ||
font: CanvasFontSpec; | ||
textOffset: number; | ||
options: RenderTextOpts; | ||
} | ||
|
||
export declare const Ticks: { | ||
formatters: { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#10879