- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我正在使用 Material Design Lite Pie Chart .
代码如下:
<svg fill="currentColor" width="200px" height="200px" viewBox="0 0 1 1" class="demo-chart mdl-cell mdl-cell--4-col mdl-cell--3-col-desktop">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#piechart" mask="url(#piemask)"></use>
<text x="0.5" y="0.5" font-family="Roboto" font-size="0.3" fill="#888" text-anchor="middle" dy="0.1">
82
<tspan font-size="0.2" dy="-0.07">%</tspan>
</text>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" style="position: fixed; left: -1000px; height: -1000px;">
<defs>
<mask id="piemask" maskContentUnits="objectBoundingBox">
<circle cx="0.5" cy="0.5" r="0.49" fill="white"></circle>
<circle cx="0.5" cy="0.5" r="0.40" fill="black"></circle>
</mask>
<g id="piechart">
<circle cx="0.5" cy="0.5" r="0.5"></circle>
<path d="M 0.5 0.5 0.5 0 A 0.5 0.5 0 0 1 0.95 0.28 z" stroke="none" fill="rgba(255, 255, 255, 0.75)"></path>
</g>
</defs>
</svg>
我怎样才能使这个动态我的意思是如果我添加 100 个标签它应该填充 100% 的圆..
最佳答案
您必须自己编写代码。我使用 SVG 路径 ( https://www.w3schools.com/graphics/svg_path.asp ) 并用正弦和余弦计算点。这并不容易,但没有比这更容易的库或工具。
我生成参数“d”的代码:
if (percent > 50 && percent <= 99) {
if (bool_main_circle) {
return "M100,50 A50,50 0 1,0 " + x + "," + y;
} else {
return "M100,50 A50,50 0 0,1 " + x + "," + y;
}
} else if (percent <= 50 && percent >= 1) {
if (bool_main_circle) {
return "M100,50 A50,50 0 0,0 " + x + "," + y;
} else {
return "M100,50 A50,50 0 1,1 " + x + "," + y;
}
} else if (percent == 100) {
if (bool_main_circle) {
return "M50,100a50,50 0 1,0 100,0a50,50 0 1,0 -100,0";
} else {
return "";
}
} else if (percent === 0) {
if (bool_main_circle) {
return "";
} else {
return "M50,100a50,50 0 1,0 100,0a50,50 0 1,0 -100,0";
}
} else {
console.log("Only values up to 100 percent are possible!");
}
正如我所说,您需要使用正弦和余弦计算 x 和 y 值。 ( https://de.serlo.org/mathe/geometrie/sinus-kosinus-tangens/sinus-kosinus-tangens-einheitskreis/trigonometrie-einheitskreis ) 对不起,这个德语页面,但是当你点击“Veranschaulichung an einem Applet”时,它有一个非常好的小程序,它很好地展示了如何用正弦计算点。然后你只需要计算你的百分比值的度值(度数=百分比*3.6)。
关于javascript - Material 设计精简饼图动态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43519594/
我正在尝试在elisp中实现我自己的深层复制例程(因为类似(setq newlist oldlist)的东西似乎只能提供浅拷贝,而(copy-sequence newlist oldlist)仍然使n
您好,我正在开发客户端站点的交互性,我觉得我的按钮功能的 JS 和 carousel.fader 窗口的构建有点多余。有人可以看一下这段代码,看看是否可以进一步简化,以减少页面加载时间,实际上只是为了
我一直在优化我的网站,但阻碍我的一个问题是我不使用的所有 jQuery 函数。我唯一使用的是平滑的页面滚动器。这似乎是在浪费下载时间。 我的问题是:是否有任何脚本或程序可以删除我不需要的 jQuery
我在很大程度上不太擅长 javascript/jquery,但我知道如何让一些软件工作。但我的问题是我有一大堆 $("body").on("click", "button#thisid", funct
我的 Eclipse 3.5.2 (Ubuntu 10.10) 安装中安装了多个插件(Apatana、SVN、Pydev、Zend Debugger、PHP)。自从几年前我第一次使用 Eclipse
这个问题在这里已经有了答案: std::forward_list and std::forward_list::push_back (5 个答案) 关闭 5 年前。 我偶然发现了这段代码并试图理解它
我有一个非常简单的 jQuery 脚本,当输入元素获得焦点时,它会将宽度扩展到 250px(使用 focusin() 事件),当失去焦点时,它会缩小使用 focusout() 事件回到 200px。但
我一直在研究为什么 WYSIWYG 编辑器不利于内容创建。给出的最常见原因是它们输出不正确的 html。但是如果我使用功能减少的编辑器怎么办? 我的要求只是斜体、使文本加粗、创建有序/无序列表和(可能
我一直在与 MVVM 模式作斗争,并且在尝试为小型/中型项目创建实用设计时遇到了许多挑战。其中一项挑战是弄清楚如何在不创建大量重复且难以维护的代码的情况下获得与此模式分离的好处。 我目前的策略是创建“
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
从MVC模式和Symfony2的角度来看,我可以瘦身吗? Controller 代码 一点点,移开一些持久化逻辑 ?例如,给定一个标准的新 Action ,如下所示: public function
我打算使用适用于 Android 的 ARM DS5 Streamline。 要将 Streamline 与您的 Android 目标一起使用,您必须构建 Gator 驱动程序 gator.ko 并将
我正在使用 LESS ( http://lesscss.org ),它说 ... JavaScript evaluation JavaScript expressions can be evaluat
我一直在研究使用 EventMachine 为一些工作做后台处理的可能性。在 Sinatra 中,这似乎工作得很好,但 Rails 3 似乎在呈现 View 之前执行所有滴答。 当我在瘦网络服务器下运
if SOMETHING charge = Object (this object has a method ID) end DiffObject.update_attributes(specif
我是一名优秀的程序员,十分优秀!