συμβάν
Παγκόσμιο Πρωτάθλημα Power BI DataViz
14 Φεβ, 4 μ.μ. - 31 Μαρ, 4 μ.μ.
Με 4 ευκαιρίες εισόδου, θα μπορούσατε να κερδίσετε ένα πακέτο συνεδρίου και να μεταβείτε στο LIVE Grand Finale στο Λας Βέγκας
Μάθετε περισσότεραΑυτό το πρόγραμμα περιήγησης δεν υποστηρίζεται πλέον.
Κάντε αναβάθμιση σε Microsoft Edge για να επωφεληθείτε από τις τελευταίες δυνατότητες, τις ενημερώσεις ασφαλείας και την τεχνική υποστήριξη.
Τα βοηθητικά προγράμματα μορφοποίησης περιέχουν, διασυνδέσεις και μεθόδους για τη μορφοποίηση τιμών. Περιέχει επίσης μεθόδους επέκτασης για την επεξεργασία συμβολοσειρών και τη μέτρηση μεγέθους κειμένου σε ένα έγγραφο SVG/HTML.
Η λειτουργική μονάδα παρέχει τις παρακάτω συναρτήσεις και διασυνδέσεις:
Αυτή η διασύνδεση περιγράφει κοινές ιδιότητες του κειμένου.
interface TextProperties {
text?: string;
fontFamily: string;
fontSize: string;
fontWeight?: string;
fontStyle?: string;
fontVariant?: string;
whiteSpace?: string;
}
Αυτή η συνάρτηση μετρά το πλάτος του κειμένου με συγκεκριμένες ιδιότητες κειμένου SVG.
function measureSvgTextWidth(textProperties: TextProperties, text?: string): number;
Παράδειγμα χρήσης measureSvgTextWidth
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.measureSvgTextWidth(textProperties);
// returns: 194.71875
Αυτή η συνάρτηση επιστρέφει ένα ορθογώνιο με τις δεδομένες ιδιότητες κειμένου SVG.
function measureSvgTextRect(textProperties: TextProperties, text?: string): SVGRect;
Παράδειγμα χρήσης measureSvgTextRect
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.measureSvgTextRect(textProperties);
// returns: { x: 0, y: -22, width: 194.71875, height: 27 }
Αυτή η συνάρτηση μετρά το ύψος του κειμένου με συγκεκριμένες ιδιότητες κειμένου SVG.
function measureSvgTextHeight(textProperties: TextProperties, text?: string): number;
Παράδειγμα χρήσης measureSvgTextHeight
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.measureSvgTextHeight(textProperties);
// returns: 27
Αυτή η συνάρτηση επιστρέφει μια γραμμή βάσης συγκεκριμένων ιδιοτήτων κειμένου SVG.
function estimateSvgTextBaselineDelta(textProperties: TextProperties): number;
Παράδειγμα:
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.estimateSvgTextBaselineDelta(textProperties);
// returns: 5
Αυτή η συνάρτηση εκτιμά το ύψος του κειμένου με συγκεκριμένες ιδιότητες κειμένου SVG.
function estimateSvgTextHeight(textProperties: TextProperties, tightFightForNumeric?: boolean): number;
Παράδειγμα χρήσης estimateSvgTextHeight
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.estimateSvgTextHeight(textProperties);
// returns: 27
Για παράδειγμα, ανατρέξτε στον κώδικα προσαρμοσμένης απεικόνισης.
Αυτή η συνάρτηση μετρά το πλάτος του svgElement.
function measureSvgTextElementWidth(svgElement: SVGTextElement): number;
Παράδειγμα χρήσης του measureSvgTextElementWidth:
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
// ...
let svg: D3.Selection = d3.select("body").append("svg");
svg.append("text")
.text("Microsoft PowerBI")
.attr({
"x": 25,
"y": 25
})
.style({
"font-family": "sans-serif",
"font-size": "24px"
});
let textElement: D3.Selection = svg.select("text");
textMeasurementService.measureSvgTextElementWidth(textElement.node());
// returns: 194.71875
Αυτή η συνάρτηση λαμβάνει τις ιδιότητες μέτρησης κειμένου του δεδομένου στοιχείου DOM.
function getMeasurementProperties(element: Element): TextProperties;
Παράδειγμα χρήσης getMeasurementProperties
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
// ...
let element: JQuery = $(document.createElement("div"));
element.text("Microsoft PowerBI");
element.css({
"width": 500,
"height": 500,
"font-family": "sans-serif",
"font-size": "32em",
"font-weight": "bold",
"font-style": "italic",
"white-space": "nowrap"
});
textMeasurementService.getMeasurementProperties(element.get(0));
/* returns: {
fontFamily:"sans-serif",
fontSize: "32em",
fontStyle: "italic",
fontVariant: "",
fontWeight: "bold",
text: "Microsoft PowerBI",
whiteSpace: "nowrap"
}*/
Αυτή η συνάρτηση λαμβάνει τις ιδιότητες μέτρησης κειμένου του δεδομένου στοιχείου κειμένου SVG.
function getSvgMeasurementProperties(svgElement: SVGTextElement): TextProperties;
Παράδειγμα χρήσης getSvgMeasurementProperties
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
// ...
let svg: D3.Selection = d3.select("body").append("svg");
let textElement: D3.Selection = svg.append("text")
.text("Microsoft PowerBI")
.attr({
"x": 25,
"y": 25
})
.style({
"font-family": "sans-serif",
"font-size": "24px"
});
textMeasurementService.getSvgMeasurementProperties(textElement.node());
/* returns: {
"text": "Microsoft PowerBI",
"fontFamily": "sans-serif",
"fontSize": "24px",
"fontWeight": "normal",
"fontStyle": "normal",
"fontVariant": "normal",
"whiteSpace": "nowrap"
}*/
Αυτή η συνάρτηση επιστρέφει το πλάτος ενός στοιχείου div.
function getDivElementWidth(element: JQuery): string;
Παράδειγμα χρήσης getDivElementWidth
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
// ...
let svg: Element = d3.select("body")
.append("div")
.style({
"width": "150px",
"height": "150px"
})
.node();
textMeasurementService.getDivElementWidth(svg)
// returns: 150px
Συγκρίνει το μέγεθος κειμένου μιας ετικέτας με το διαθέσιμο μέγεθος και αποδίδει αποσιωπητικά όταν το διαθέσιμο μέγεθος είναι μικρότερο.
function getTailoredTextOrDefault(textProperties: TextProperties, maxWidth: number): string;
Παράδειγμα χρήσης getTailoredTextOrDefault
του :
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
import TextProperties = textMeasurementService.TextProperties;
// ...
let textProperties: TextProperties = {
text: "Microsoft PowerBI!",
fontFamily: "sans-serif",
fontSize: "24px"
};
textMeasurementService.getTailoredTextOrDefault(textProperties, 100);
// returns: Micros...
Η λειτουργική μονάδα παρέχει τις ακόλουθες συναρτήσεις:
Αυτή η συνάρτηση ελέγχει εάν μια συμβολοσειρά τελειώνει με μια δευτερεύουσα συμβολοσειρά.
function endsWith(str: string, suffix: string): boolean;
Παράδειγμα χρήσης endsWith
του :
import { stringExtensions } from "powerbi-visuals-utils-formattingutils";
// ...
stringExtensions.endsWith("Power BI", "BI");
// returns: true
Αυτή η συνάρτηση συγκρίνει συμβολοσειρές, αγνοώντας τα πεζά-κεφαλαία.
function equalIgnoreCase(a: string, b: string): boolean;
Παράδειγμα χρήσης equalIgnoreCase
του :
import { stringExtensions } from "powerbi-visuals-utils-formattingutils";
// ...
stringExtensions.equalIgnoreCase("Power BI", "power bi");
// returns: true
Αυτή η συνάρτηση ελέγχει εάν μια συμβολοσειρά ξεκινά με μια δευτερεύουσα συμβολοσειρά.
function startsWith(a: string, b: string): boolean;
Παράδειγμα χρήσης startsWith
του :
import { stringExtensions } from "powerbi-visuals-utils-formattingutils";
// ...
stringExtensions.startsWith("Power BI", "Power");
// returns: true
Αυτή η συνάρτηση ελέγχει εάν μια συμβολοσειρά περιέχει μια καθορισμένη δευτερεύουσα συμβολοσειρά.
function contains(source: string, substring: string): boolean;
Παράδειγμα χρήσης contains
της μεθόδου :
import { stringExtensions } from "powerbi-visuals-utils-formattingutils";
// ...
stringExtensions.contains("Microsoft Power BI Visuals", "Power BI");
// returns: true
Ελέγχει εάν μια συμβολοσειρά είναι null ή δεν έχει οριστεί ή είναι κενή.
function isNullOrEmpty(value: string): boolean;
Παράδειγμα μεθόδου isNullOrEmpty
:
import { stringExtensions } from "powerbi-visuals-utils-formattingutils";
// ...
stringExtensions.isNullOrEmpty(null);
// returns: true
Η λειτουργική μονάδα παρέχει τις ακόλουθες συναρτήσεις, διασυνδέσεις και:
Αυτή η διασύνδεση περιγράφει δημόσιες μεθόδους και ιδιότητες του μορφοποιητή.
interface IValueFormatter {
format(value: any): string;
displayUnit?: DisplayUnit;
options?: ValueFormatterOptions;
}
Αυτή η μέθοδος μορφοποιήσει την καθορισμένη τιμή.
function format(value: any, format?: string, allowFormatBeautification?: boolean): string;
Παραδείγματα για IValueFormatter.format
το :
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ value: 1001 });
iValueFormatter.format(5678);
// returns: "5.68K"
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ value: 1e6 });
iValueFormatter.format(1234567890);
// returns: "1234.57M"
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ value: 1e9 });
iValueFormatter.format(1234567891236);
// returns: 1234.57bn
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ value: 1e12 });
iValueFormatter.format(1234567891236);
// returns: 1.23T
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ format: "E" });
iValueFormatter.format(1234567891236);
// returns: 1.234568E+012
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let valueFormatterUK = valueFormatter.create({ cultureSelector: "en-GB" });
valueFormatterUK.format(new Date(2007, 2, 3, 17, 42, 42));
// returns: 02/03/2007 17:42:42
let valueFormatterUSA = valueFormatter.create({ cultureSelector: "en-US" });
valueFormatterUSA.format(new Date(2007, 2, 3, 17, 42, 42));
// returns: 2/3/2007 5:42:42 PM
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ format: "0.00 %;-0.00 %;0.00 %" });
iValueFormatter.format(0.54);
// returns: 54.00 %
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let date = new Date(2016, 10, 28, 15, 36, 0),
iValueFormatter = valueFormatter.create({});
iValueFormatter.format(date);
// returns: 10/28/2016 3:36:00 PM
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({});
iValueFormatter.format(true);
// returns: True
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
let iValueFormatter = valueFormatter.create({ value: 0, precision: 3 });
iValueFormatter.format(3.141592653589793);
// returns: 3.142
Για παράδειγμα, ανατρέξτε στον κώδικα προσαρμοσμένης απεικόνισης.
Αυτή η διασύνδεση περιγράφει options
το IValueFormatter και επιλογές συνάρτησης create
.
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
import ValueFormatterOptions = valueFormatter.ValueFormatterOptions;
interface ValueFormatterOptions {
/** The format string to use. */
format?: string;
/** The data value. */
value?: any;
/** The data value. */
value2?: any;
/** The number of ticks. */
tickCount?: any;
/** The display unit system to use */
displayUnitSystemType?: DisplayUnitSystemType;
/** True if we are formatting single values in isolation (e.g. card), as opposed to multiple values with a common base (e.g. chart axes) */
formatSingleValues?: boolean;
/** True if we want to trim off unnecessary zeroes after the decimal and remove a space before the % symbol */
allowFormatBeautification?: boolean;
/** Specifies the maximum number of decimal places to show*/
precision?: number;
/** Detect axis precision based on value */
detectAxisPrecision?: boolean;
/** Specifies the column type of the data value */
columnType?: ValueTypeDescriptor;
/** Specifies the culture */
cultureSelector?: string;
}
Αυτή η μέθοδος δημιουργεί μια παρουσία του IValueFormatter.
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
import create = valueFormatter.create;
function create(options: ValueFormatterOptions): IValueFormatter;
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
valueFormatter.create({});
// returns: an instance of IValueFormatter.
Εναλλακτικός τρόπος μορφοποίησης της τιμής IValueFormatter
χωρίς δημιουργία . Χρήσιμο για υποθέσεις με δυναμική συμβολοσειρά μορφών
import { format } from "powerbi-visuals-utils-formattingutils";
import format = valueFormatter.format;
function format(value: any, format?: string, allowFormatBeautification?: boolean, cultureSelector?: string): string;
import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
const value = 12
const format = '¥ #,0'
valueFormatter.format(value, format);
// returns: formatted value as string (¥ 12)
συμβάν
Παγκόσμιο Πρωτάθλημα Power BI DataViz
14 Φεβ, 4 μ.μ. - 31 Μαρ, 4 μ.μ.
Με 4 ευκαιρίες εισόδου, θα μπορούσατε να κερδίσετε ένα πακέτο συνεδρίου και να μεταβείτε στο LIVE Grand Finale στο Λας Βέγκας
Μάθετε περισσότεραΕκπαίδευση
Διαδρομή εκμάθησης
Use advance techniques in canvas apps to perform custom updates and optimization - Training
Use advance techniques in canvas apps to perform custom updates and optimization