亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

麻煩獲取CanvasJS僅對工具提示中的坐標進行著色

麻煩獲取CanvasJS僅對工具提示中的坐標進行著色

PHP
神不在的星期二 2021-05-12 18:37:17
工具提示文字:10Dataseries 1: 71Dataseries 2: 77我試圖讓工具提示,因此Dataseries 1:并Dataseries 2:保持其當前的顏色,和10,71和77為紅色。我已經嘗試過了,toolTipContent: " x: <span style='\"'color: red;'\"'>{x}</span> y: {y} <br/> name: {name}, label:{label} ",但是沒有任何改變。我確定這是一個愚蠢的錯誤,但是我是使用CanvasJS的新手,還無法正常工作。(https://jsfiddle.net/lightmaster/8p3ygwf1/)var chart = new CanvasJS.Chart("chartContainer", {  backgroundColor: "RGBA(37, 41, 45, 0.9)",  animationEnabled: true,  title: {    text: " ",    fontSize: 11,    fontColor: ' #ccc',    fontFamily: "arial",  },  toolTip: {    fontStyle: "normal",    cornerRadius: 4,    backgroundColor: "RGBA(37, 41, 45, 0.9)",    toolTipContent: " x: {x} y: {y} <br/> name: {name}, label:{label} ",    shared: true,  },  axisX: {    gridColor: "RGBA(64, 65, 66, 0.8)",    labelFontSize: 10,    labelFontColor: ' #ccc',    lineThickness: 1,    gridThickness: 1,    gridDashType: "dot",    titleFontFamily: "arial",    labelFontFamily: "arial",    interval: "auto",    intervalType: "hour",    minimum: 0,    crosshair: {      enabled: true,      snapToDataPoint: true,      color: "#9aba2f",      labelFontColor: "#ccc",      labelFontSize: 14,      labelBackgroundColor: "#FF8841",    }  },  axisY: {    title: "Temperature (°F) Recorded",    titleFontColor: "#ccc",    titleFontSize: 10,    titleWrap: false,    margin: 10,    lineThickness: 1,    gridThickness: 1,    gridDashType: "dot",    includeZero: false,    gridColor: "RGBA(64, 65, 66, 0.8)",    labelFontSize: 11,    labelFontColor: ' #ccc',    titleFontFamily: "arial",    labelFontFamily: "arial",    labelFormatter: function(e) {      return e.value.toFixed(0) + " °F ";    },    crosshair: {      enabled: true,      snapToDataPoint: true,      color: "#9aba2f",      labelFontColor: "#fff",      labelFontSize: 12,      labelBackgroundColor: "#FF8841",      valueFormatString: "#0.# °F",    }  },
查看完整描述

1 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

在圖表級別,toolTipContent您不需要content。您的toolTipContent代碼當前正在被忽略,因為這是僅在數據級別使用的屬性。您可以按照以下基本要求直接設置樣式:


toolTip: {

  fontStyle: "normal",

  cornerRadius: 14,

  backgroundColor: "RGBA(37, 41, 45, 0.9)",

  content: "<span style='\"'color: red;'\"'>{x}</span><br/> <span style='\"'color: {color};'\"'>{name}</span> <span style='\"'color: red;'\"'>{y}</span>",

  shared: true,

}

由于您正在使用shared: true,因此您的x值將顯示兩次。如果您不想這樣做,請查看文檔中“共享的工具提示”部分的contentFormatter函數。


查看完整回答
反對 回復 2021-05-21
  • 1 回答
  • 0 關注
  • 131 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號