【问题标题】:kendo ui chart - add html and multiple values to series.Labels.Templatekendo ui 图表 - 将 html 和多个值添加到 series.Labels.Template
【发布时间】:2014-12-24 10:37:02
【问题描述】:

对于这个例子:

http://dojo.telerik.com/arIhI/2

$("#chart").kendoChart({
  dataSource: {
    data: [
      { score: 1.1, legend: 'a' },
      { score: 2.5, legend: 'b' },
      { score: 3.25, legend: 'c' }
    ]
  },
  series: [{
    field: "score",   
    labels: {
      visible: true,
      template: "Score is: #: value #% legend is: ????"
    },
  }]
});

2 个问题:

1) 是否可以将 html 添加到模板中(比如 Value is: ....)?

2) 是否可以向标签添加多个值。我想添加分数和图例。

-谢谢。

【问题讨论】:

    标签: kendo-ui kendo-chart


    【解决方案1】:

    1) 当然

    template: "<b>Score is:</b> #: value #% legend is: ????"
    

    是有效的模板。

    2) 这样做:

    template: "Score is: #= dataItem.score #% legend is: #= dataItem.legend #"
    

    或者使用我认为更方便的功能:

    template: function(e) { return "Score is: " + e.dataItem.score + "% legend is: " + e.dataItem.legend }
    

    更新: 目前无法将 html 添加到 series.labels.templates。

    【讨论】:

    • 1) 向模板添加 html 不起作用。它会导致标签低于图表。 2)效果很好。谢谢!
    • 我相信我误解了您在 1) 中的问题。检查此示例:dojo.telerik.com/icOC 当您将鼠标悬停在图表上时,您会看到粗体的国家名称和正常值。
    • 我用 Telerik 开了一张票,目前 series.labels.templates 不支持 html。蹩脚!..我更新了你的答案。谢谢!
    • dataItem 未定义
    • @Jedaias Rodrigues 这里是最新剑道的例子:dojo.telerik.com/arIhI/58 同样的解决方案对我有用。你不能像 RayLoveless 所说的那样使用粗体字。
    猜你喜欢
    • 1970-01-01
    • 2013-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多