我正在尝试在ChartJS v2.0中创建自定义图例模板.在ChartJS的v1*中,我只是向新的Chart构造函数添加了一个属性,例如......
legendTemplate : '<ul>'
+'<% for (var i=0; i<datasets.length; i++) { %>'
+'<li>'
+'<span style=\"background-color:<%=datasets[i].lineColor%>\"></span>'
+'<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
+'</li>'
+'<% } %>'
+'</ul>'
Run Code Online (Sandbox Code Playgroud)
我似乎无法在v2.0中找到此选项的任何文档.它甚至可用吗?任何人都可以展示如何实现这一目标的例子吗?
谢谢!
更新 - 下面的工作代码
legendCallback: function(chart) {
console.log(chart.data);
var text = [];
text.push('<ul>');
for (var i=0; i<chart.data.datasets[0].data.length; i++) {
text.push('<li>');
text.push('<span style="background-color:' + chart.data.datasets[0].backgroundColor[i] + '">' + chart.data.datasets[0].data[i] + '</span>');
if (chart.data.labels[i]) {
text.push(chart.data.labels[i]);
}
text.push('</li>');
}
text.push('</ul>');
return text.join("");
}
Run Code Online (Sandbox Code Playgroud) 当我点击一个按钮时,我写了一个简单的代码来在我的svg页面中添加一行
这是html
<body>
<svg width="500" height="400">
</svg>
<button id="btn1">Append text</button>
</body>
Run Code Online (Sandbox Code Playgroud)
和脚本
$(document).ready(function(){
$("#btn1").click(function(){
$("svg").append(' <line x1="10" y1="10" x2="40" y2="40" style="stroke: black">' );
console.log("done!");
});
});
Run Code Online (Sandbox Code Playgroud)
和jsfiddle https://jsfiddle.net/dch7xyez/1/
该行被追加但不可见.任何人都可以向我解释原因吗?
我正在尝试加载带有一些特定参数的谷歌地图.我理解问题很可能是initMap函数需要全局声明.但是,即使在搜索了一些类似问题的StackOverflow帖子后,我也不知道如何.
其余的部分
<script>
var databaseArray = [{id: 'BTS1', arfcn: '70', bsic: '29'}
,{id: 'BTS2', arfcn: '60', bsic: '28'}
,{id: 'BTS3', arfcn: '65', bsic: '27'}
,{id: 'BTS4', arfcn: '55', bsic: '26'}
,{id: 'BTS5', arfcn: '75', bsic: '29'}];
var locationArray = [{lat: '60.78064', lng: '10.67037'}
,{lat: '60.76978', lng: '10.66677'}
,{lat: '60.76991', lng: '10.69672'}
,{lat: '60.78889', lng: '10.68462'}
,{lat: '60.76086', lng: '10.65141'}];
function displayDatabase(){
var table1 = document.getElementById('database');
for (var i = 0; i < databaseArray.length; i++){
var bts = databaseArray[i];
var row …Run Code Online (Sandbox Code Playgroud) 我目前正在通过wordpress开发一个在线商店.一切都很好,现在我想给我的页面一个自定义边框(倒圆角),并找到它的CSS代码,如下所示:
CSS:
body {
background-color: #fff;
}
.wrapper {
overflow:hidden;
width:200px;
height:200px;
}
div.inverted-corner {
box-sizing:border-box;
position: relative;
background-color: #3e2a4f;
height: 200px;
width: 200px;
border: solid grey 7px;
}
.top, .bottom {
position: absolute;
width: 100%;
height: 100%;
top:0;
left:0;
}
.top:before, .top:after, .bottom:before, .bottom:after{
content:" ";
position:absolute;
width: 40px;
height: 40px;
background-color: #fff;
border: solid grey 7px;
border-radius: 20px;
}
.top:before {
top:-35px;
left:-35px;
}
.top:after {
top: -35px;
right: -35px;
box-shadow: inset 1px 1px 1px grey;
}
.bottom:before …Run Code Online (Sandbox Code Playgroud) <script>
var data={
Data: {
name: 'aaaa',
number: '0003'
},
values: {
val: '-20.00',
rate: '22047'
},
user: [ '6|1|5', '10|1|15' ]
};
console.log(data);
console.log(data.user.length);
for(var i=0;i<data.user.length;i++) {
console.log(data.user[i]);
}
</script>
Run Code Online (Sandbox Code Playgroud)
上面是我的代码我想放置循环并得到这样的值
这是我的数据 user: [ '6|1|5', '10|1|15' ]
但我想这样:
排名 - 5
userid - 10
我怎么能这样帮助我?