简体   繁体   English

使用KendoUI折线图,如何在类别上附加多个线标签?

[英]Using KendoUI Line Chart, How do you attach multiple Line Labels on Categories?

I'm replacing DotNet Charting charts with KendoUI. 我正在用KendoUI取代DotNet Charting图表。 I need to be able to put a multiple line label on a line chart. 我需要能够在折线图上放置多行标签。 See the image below with the red circle on the label. 请参阅下图,标签上有红色圆圈。 Any suggestions would be greatly appreciated. 任何建议将不胜感激。

See my current chart and the DotNet Cart I need to replace: 查看我当前的图表和我需要更换的DotNet购物车:

Short answer: you can't. 简短的回答:你做不到。

Long answer: You can't, but you there is a bug in Kendo that will let you... sort of. 答案很长:你不能,但是剑道中有一个bug会让你......有点儿。

Kendo is creating an SVG on the fly for your chart. 剑道正在为你的图表动态创建一个SVG。 SVGs are just XML, and you can inject XML into the element via the javascript config. SVG只是XML,你可以通过javascript配置将XML注入到元素中。

For your label, you have to use elements to position text. 对于标签,您必须使用元素来定位文本。 See the SVG spec for this element: http://www.w3.org/TR/SVG/text.html#TSpanElement 有关此元素,请参阅SVG规范: http//www.w3.org/TR/SVG/text.html#TSpanElement

The problem here is that Kendo uses left-justified text, and you can't change the parent element with this bug. 这里的问题是剑道使用左对齐文本,你不能用这个bug改变父元素。 That means you have to offset everything by hand, one pixel at a time. 这意味着您必须手动抵消所有内容,一次一个像素。 If your text is static, this might work; 如果您的文本是静态的,这可能会起作用; if it is dynamic, I wouldn't even attempt it. 如果它是动态的,我甚至都不会尝试它。

You might be able to hack something together via JS, and manipulate the SVG on the fly each time Kendo modifies it... but you may as well write a charting library if you're going to that much work. 可能可以通过JS一起破解某些东西,并且每当Kendo修改它时动态操作SVG ......但如果你要做那么多工作,你也可以编写一个图表库。

EDIT : For your use, it might be better to rotate the labels, if you don't have to mirror the old display exactly. 编辑 :为了您的使用,如果您不必完全镜像旧显示器,最好旋转标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM