当前位置: 首页 > news >正文

wordpress换行代码/百度搜索结果优化

wordpress换行代码,百度搜索结果优化,网站估值,大鹏新网站建设图表数据 创建图表的时候,需要把创建图表所需的所有数据放入一个数据对象中,然后向图表传递这个对象,这个数据对象可以包含下面这些参数 参数名类型描述datasetsArray[object]包含有一组数据的数据组。 查阅文档来确定有哪些可用参数是可添…

图表数据

创建图表的时候,需要把创建图表所需的所有数据放入一个数据对象中,然后向图表传递这个对象,这个数据对象可以包含下面这些参数

参数名类型描述
datasetsArray[object]包含有一组数据的数据组。 查阅文档来确定有哪些可用参数是可添加到数据组中的。
labelsArray[string]跟 category axis 一起使用的可选参数。
xLabelsArray[string]横向坐标轴 类别
yLabelsArray[string]纵向坐标轴 类别

绘制带参数创建图表

绘制一个带参数的图表,只需要向图表创建方法传递一个包含所需参数的对象即可。在下面这个例子中,设置了图表是不响应的。

var chartInstance = new Chart(ctx, {type: 'line',data: data,options: {responsive: false}
});

全局配置

全局配置这个概念在 Chart.js 1.0 中已经介绍了,全局配置文件可以方便的改变所有的图表样式,或者个性化其中的某一个图表。

Chart.js merges the options object passed to the chart with the global configuration using chart type defaults and scales defaults appropriately. This way you can be as specific as you would like in your individual chart configuration, while still changing the defaults for all chart types where applicable. The global general options are defined in Chart.defaults.global. The defaults for each chart type are discussed in the documentation for that chart type.

The following example would set the hover mode to ‘single’ for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation.

Chart.defaults.global.hover.mode = 'single';// Hover mode is set to single because it was not overridden here
var chartInstanceHoverModeSingle = new Chart(ctx, {type: 'line',data: data,
});// This chart would have the hover mode that was passed in
var chartInstanceDifferentHoverMode = new Chart(ctx, {type: 'line',data: data,options: {hover: {// Overrides the global settingmode: 'label'}}
})

全局字体设置

有4个可以改变全局图表字体样式的参数,这些参数在全局配置文件 Chart.defaults.global 中

名称类型默认描述
defaultFontColorColor‘#666’默认字体颜色
defaultFontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”默认字体
defaultFontSizeNumber12默认字体大小(单位:px),Does not apply to radialLinear scale point labels
defaultFontStyleString‘normal’默认字体样式。不会应用于提示弹窗的字体。不会应用于图表标题

通用图表配置

下面的设置选项适用于所有的图表, 你可以在全局配置文件中设置 global configuration,也可以在构建图表的时候传递给构建方法。

名称类型默认描述
responsiveBooleantrue在图表容器canvas变化的时候自适应
responsiveAnimationDurationNumber0图表自适应新尺寸所用时间
maintainAspectRatioBooleantrue调整大小时保持横纵比
eventsArray[String][“mousemove”,
”mouseout”, 
”click”,
”touchstart”,
”touchmove”,
”touchend”]
弹出提示小窗口要监听的事件
onClickFunctionnullCalled if the event is of type ‘mouseup’ or ‘click’. Called in the context of the chart and passed an array of active elements
legendCallbackFunctionfunction (chart) { }Function to generate a legend. Receives the chart object to generate a legend from. Default implementation returns an HTML string.
onResizeFunctionnullCalled when a resize occurs. Gets passed two arguemnts: the chart instance and the new size.

标题配置选项

标题相关配置设置在 options -> title 域中,相关的全局配置在 Chart.defaults.global.title中。

名称类型默认描述
displayBooleanfalse是否显示标题
positionString‘top’指定标题的位置。 可用参数有’top’, ‘left’, ‘bottom’ 和’right’
fullWidthBooleantrueMarks that this box should take the full width of the canvas (pushing down other boxes)
fontSizeNumber12文字大小,默认继承全局配置中的设定值
fontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”文字字体,默认继承全局配置中的设定值
fontColorColor“#666”文字颜色,默认继承全局配置中的设定值
fontStyleString‘bold’文字样式,默认继承全局配置中的设定值
paddingNumber10在标题上下添加的间隔(单位为px)
textString标题内容

示例

下面的例子会在创建图表的时候会包含标题“自定义图表标题”

var chartInstance = new Chart(ctx, {type: 'line',data: data, //data这里代表的是数值数组options: {title: {display: true,text: '自定义图表标题'}}
})

图例

图例相关的配置在options -> legend 域中,相关全局配置在Chart.defaults.global.legend中。

名称类型默认描述
displayBooleantrue是否显示图例
positionString‘top’图例位置。可用的位置有上下左右,’top’, ‘left’, ‘bottom’ and ‘right’.
fullWidthBooleantrueMarks that this box should take the full width of the canvas (pushing down other boxes)
onClickFunctionfunction(event, legendItem) {}A callback that is called when a click is registered on top of a label item
labelsObject-参阅下面的 图例文字选项.

图例文字选项

图例文字选项写在图例选项下面的options -> legend -> lables 中。

名称类型默认描述
boxWidthNumber40Width of coloured box
fontSizeNumber12文字大小,默认继承全局配置中的设定值
fontStyleString“normal”文字样式,默认继承全局配置中的设定值
fontColorColor“#666”文字颜色,默认继承全局配置中的设定值
fontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”文字字体,默认继承全局配置中的设定值
paddingNumber10同行图例之间的 Padding
generateLabels:Functionfunction(chart) { }Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See Legend Itemfor details.
usePointStyleBooleanfalseLabel style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case).

图例接口

Items passed to the legend onClick function are the ones returned from labels.generateLabels. These items must implement the following interface.

{// 文字text: String,// 图例方块颜色fillStyle: Color,// If true, this item represents a hidden dataset. Label will be rendered with a strike-through effecthidden: Boolean,// For box border. See https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCaplineCap: String,// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDashlineDash: Array[Number],// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffsetlineDashOffset: Number,// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoinlineJoin: String,// Width of box borderlineWidth: Number,// Stroke style of the legend boxstrokeStyle: Color// Point style of the legend box (only used if usePointStyle is true)pointStyle: String
}

示例

下面的例子将创建一个带图例的图表,图例文字颜色设置为红色。

var chartInstance = new Chart(ctx, {type: 'bar',data: data, //data 数据数组options: {legend: { //图例相关配置display: true,labels: { //图例文字fontColor: 'rgb(255, 99, 132)'}}}
});

提示弹窗 - 配置选项

tooltip相关配置在 options -> tooltips中,相关的全局配置在 Chart.defaults.global.tooltips中。

名称类型默认值描述
enabledBooleantrue是否开启
customFunctionnull参阅下面的 section 部分
modeString‘single’设置哪个元素要显示在提示弹窗中,可用的参数有 'single''label' or'x-axis'
 
single 高亮最近的元素。 
 
label 高亮显示所有相同X 数值的元素。 
 
'x-axis' also highlights elements in all datasets at the same X value, but activates when hovering anywhere within the vertical slice of the x-axis representing that X value.
itemSortFunctionundefinedAllows sorting of tooltip items. Must implement a function that can be passed to Array.prototype.sort
backgroundColorColor‘rgba(0,0,0,0.8)’背景颜色
titleFontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”标题文字字体,默认继承全局配置中的设置
titleFontSizeNumber12标题字体大小,默认继承全局配置中的设置
titleFontStyleString“bold”标题字体样式,默认继承全局配置中的设置
titleFontColorColor“#fff”标题字体颜色,默认继承全局配置中的设置
titleSpacingNumber2标题上下的padding
titleMarginBottomNumber6标题下方的margin
bodyFontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”内容字体,默认继承全局配置中的设置
bodyFontSizeNumber12内容字体大小,默认继承全局配置中的设置
bodyFontStyleString“normal”内容字体样式,默认继承全局配置中的设置
bodyFontColorColor“#fff”内容字体颜色,默认继承全局配置中的设置
bodySpacingNumber2内容上下的padding
footerFontFamilyString“‘Helvetica Neue’, ‘Helvetica’, ‘Arial’, sans-serif”footer字体,默认继承全局配置中的设置
footerFontSizeNumber12footer字体大小,默认继承全局配置中的设置
footerFontStyleString“bold”footer字体样式
footerFontColorColor“#fff”footer字体颜色
footerSpacingNumber2footer上下的padding
footerMarginTopNumber6footer上面的margin
xPaddingNumber6左右的padding
yPaddingNumber6上下的padding
caretSizeNumber5对话框引出箭头大小,单位px
cornerRadiusNumber6圆角大小
multiKeyBackgroundColor“#fff”Color to draw behind the colored boxes when multiple items are in the tooltip
callbacksObject See the callbacks section below

Tooltip 回调

The tooltip label configuration is nested below the tooltip configuration using the callbacks key. The tooltip has the following callbacks for providing text. For all functions, ‘this’ will be the tooltip object created from the Chart.Tooltip constructor.

All functions are called with the same arguments: a tooltip item and the data object passed to the chart. All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text.

CallbackArgumentsDescription
beforeTitleArray[tooltipItem], dataText to render before the title
titleArray[tooltipItem], dataText to render as the title
afterTitleArray[tooltipItem], dataText to render after the title
beforeBodyArray[tooltipItem], dataText to render before the body section
beforeLabeltooltipItem, dataText to render before an individual label
labeltooltipItem, dataText to render for an individual item in the tooltip
labelColortooltipItem, chartInstaceReturns the colors to render for the tooltip item. Return as an object containing two parameters: borderColor and backgroundColor.
afterLabeltooltipItem, dataText to render after an individual label
afterBodyArray[tooltipItem], dataText to render after the body section
beforeFooterArray[tooltipItem], dataText to render before the footer section
footerArray[tooltipItem], dataText to render as the footer
afterFooterArray[tooltipItem], dataText to render after the footer section

Tooltip Item Interface

The tooltip items passed to the tooltip callbacks implement the following interface.

{// X Value of the tooltip as a stringxLabel: String,// Y value of the tooltip as a stringyLabel: String,// Index of the dataset the item comes fromdatasetIndex: Number,// Index of this data item in the datasetindex: Number
}

悬停 - 配置选项

The hover configuration is passed into the options.hover namespace. The global hover configuration is at Chart.defaults.global.hover.

NameTypeDefaultDescription
modeString‘single’Sets which elements hover. Acceptable options are 'single''label''x-axis', or'dataset'
 
single highlights the closest element. 
 
label highlights elements in all datasets at the same X value. 
 
'x-axis' also highlights elements in all datasets at the same X value, but activates when hovering anywhere within the vertical slice of the x-axis representing that X value. 
 
dataset highlights the closest dataset.
animationDurationNumber400Duration in milliseconds it takes to animate hover style changes
onHoverFunctionnullCalled when any of the events fire. Called in the context of the chart and passed an array of active elements (bars, points, etc)

动画 - 配置选项

The following animation options are available. The global options for are defined in Chart.defaults.global.animation.

NameTypeDefaultDescription
durationNumber1000The number of milliseconds an animation takes.
easingString“easeOutQuart”Easing function to use.
onProgressFunctionnoneCallback called on each step of an animation. Passed a single argument, an object, containing the chart instance and an object with details of the animation.
onCompleteFunctionnoneCallback called at the end of an animation. Passed the same arguments as onProgress

动画回调

The onProgress and onComplete callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed an object that implements the following interface. An example usage of these callbacks can be found onGithub. This sample displays a progress bar showing how far along the animation is.

{// Chart objectchartInstance,// Contains details of the on-going animationanimationObject,
}

Animation Object

The animation object passed to the callbacks is of type Chart.Animation. The object has the following parameters.

{// Current Animation frame numbercurrentStep: Number,// Number of animation framesnumSteps: Number,// Animation easing to useeasing: String,// Function that renders the chartrender: Function,// User callbackonAnimationProgress: Function,// User callbackonAnimationComplete: Function
}

Element Configuration

The global options for elements are defined in Chart.defaults.global.elements.

Options can be configured for four different types of elements; arc, lines, points, and rectangles. When set, these options apply to all objects of that type unless specifically overridden by the configuration attached to a dataset.

Arc Configuration

Arcs are used in the polar area, doughnut and pie charts. They can be configured with the following options. The global arc options are stored in Chart.defaults.global.elements.arc.

NameTypeDefaultDescription
backgroundColorColor‘rgba(0,0,0,0.1)’Default fill color for arcs. Inherited from the global default
borderColorColor‘#fff’Default stroke color for arcs
borderWidthNumber2Default stroke width for arcs

曲线图表选项

Line elements are used to represent the line in a line chart. The global line options are stored in Chart.defaults.global.elements.line.

NameTypeDefaultDescription
tensionNumber0.4Default bezier curve tension. Set to 0 for no bezier curves.
backgroundColorColor‘rgba(0,0,0,0.1)’Default line fill color
borderWidthNumber3Default line stroke width
borderColorColor‘rgba(0,0,0,0.1)’Default line stroke color
borderCapStyleString‘butt’Default line cap style. See MDN
borderDashArray[]Default line dash. See MDN
borderDashOffsetNumber0.0Default line dash offset. See MDN
borderJoinStyleString‘miter’Default line join style. See MDN
capBezierPointsBooleantrueIf true, bezier control points are kept inside the chart. If false, no restriction is enforced.
fillBooleantrueIf true, the line is filled.
steppedBooleanfalseIf true, the line is shown as a stepped line and ‘tension’ will be ignored

Point Configuration

Point elements are used to represent the points in a line chart or a bubble chart. The global point options are stored in Chart.defaults.global.elements.point.

NameTypeDefaultDescription
radiusNumber3Default point radius
pointStyleString‘circle’Default point style
backgroundColorColor‘rgba(0,0,0,0.1)’Default point fill color
borderWidthNumber1Default point stroke width
borderColorColor‘rgba(0,0,0,0.1)’Default point stroke color
hitRadiusNumber1Extra radius added to point radius for hit detection
hoverRadiusNumber4Default point radius when hovered
hoverBorderWidthNumber1Default stroke width when hovered

Rectangle Configuration

Rectangle elements are used to represent the bars in a bar chart. The global rectangle options are stored in Chart.defaults.global.elements.rectangle.

NameTypeDefaultDescription
backgroundColorColor‘rgba(0,0,0,0.1)’Default bar fill color
borderWidthNumber0Default bar stroke width
borderColorColor‘rgba(0,0,0,0.1)’Default bar stroke color
borderSkippedString‘bottom’Default skipped (excluded) border for rectangle. Can be one of bottomlefttopright

颜色

When supplying colors to Chart options, you can use a number of formats. You can specify the color as a string in hexadecimal, RGB, or HSL notations. If a color is needed, but not specified, Chart.js will use the global default color. This color is stored at Chart.defaults.global.defaultColor. It is initially set to ‘rgba(0, 0, 0, 0.1)’;

You can also pass a CanvasGradient object. You will need to create this before passing to the chart, but using it you can achieve some interesting effects.

The final option is to pass a CanvasPattern object. For example, if you wanted to fill a dataset with a pattern from an image you could do the following.

var img = new Image();
img.src = 'https://example.com/my_image.png';
img.onload = function() {var ctx = document.getElementById('canvas').getContext('2d');var fillPattern = ctx.createPattern(img, 'repeat');var chart = new Chart(ctx, {data: {labels: ['Item 1', 'Item 2', 'Item 3'],datasets: [{data: [10, 20, 30],backgroundColor: fillPattern}]}})
}
http://www.lbrq.cn/news/1262827.html

相关文章:

  • 临沂专业网站建设公司/广州中小企业seo推广运营
  • 现在疫情可以去广州吗/宁波seo排名外包
  • 中华人民建设部网站/seo网站推广招聘
  • 商业网站需要的/中国疾控卫生应急服装
  • 长春电商网站建设/制作网页的步骤
  • 内容展示类网站/交友平台
  • 天津做网站贵吗/快速网站推广公司
  • 中企动力做网站好吗/自己建网站流程
  • 建设一个网站需要多少钱/店铺推广软文范例
  • 网上做网站兼职/昆明网络营销
  • 黑群辉做web下载网站/进一步优化落实
  • 榆林国贸网站建设/百度搜索风云榜下载
  • 企业登记代理公司/网站seo推广方案
  • 建网站的大公司/汕头企业网络推广
  • 广州建外贸网站公司简介/谷歌官网登录入口
  • 高效的网站建设/网络软文营销案例3篇
  • 成都网站建设益友网络/网站优化排名服务
  • c 教程如何做网站/看到招聘游戏推广员千万别去
  • 专教做美食的网站/app运营
  • 贵州做网站的/东莞seo排名优化
  • 手机端网站怎么做/个人接外包的网站
  • 云南建设网站/网站模板之家免费下载
  • 河南建设网站公司哪家好/上海优化网站seo公司
  • 网站后台发文章图片链接怎么做/营销外包
  • 业务员自己掏钱做网站可以吗/昆明网络推广方式有哪些
  • 隆尧网站/百度一下首页百度一下知道
  • 公司做网站建设/宁德市属于哪个省
  • 备案网站转入阿里云/百度网址导航
  • 以前做的网站怎么才能登陆后台/seo技巧seo排名优化
  • 做网站如何获利/百度搜索推广操作简要流程
  • JVM学习日记(十五)Day15——性能监控与调优(二)
  • 动态置信度调优实战:YOLOv11多目标追踪精度跃迁方案(附完整代码)
  • 【一天一个知识点】RAG遇见推理
  • 对于考研数学的理解
  • 【redis】基于工业界技术分享的内容总结
  • 【机器学习】“回归“算法模型的三个评估指标:MAE(衡量预测准确性)、MSE(放大大误差)、R²(说明模型解释能力)