小编Ris*_*aje的帖子

在SVG中添加省略号以溢出文本?

我正在使用D3.js. 我想找到一个等同于这个CSS类的SVG,如果文本流出其包含的div,它会添加省略号:

.ai-ellipsis {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  -moz-binding: url(<q>assets/xml/ellipsis.xml#ellipsis</q>);
}
Run Code Online (Sandbox Code Playgroud)

这是我的SVG:

<g class="bar" transform="translate(0,39)">
    <text class="label" x="-3" y="6.5" dy=".35em" text-anchor="start">Construction</text>    
    <rect height="13" width="123"></rect>
</g>
Run Code Online (Sandbox Code Playgroud)

它的生成如下:

barEnter.append("text").attr("class", "label")
        .attr("x", -3).attr("y", function() { return y.rangeBand() / 2})
        .attr("dy", ".35em").attr("text-anchor", "start")
        .text(function(d) {
            return d.Name;
        });
Run Code Online (Sandbox Code Playgroud)

目前,文本溢出并与rect元素重叠.

有什么方法可以说"如果文字超过一定宽度,裁剪它并添加省略号"?

css svg d3.js

26
推荐指数
3
解决办法
3万
查看次数

View.get中的context.getTheme.obtainStyledAttributes和context.obtainStyledAttributes之间的区别

context.getTheme.obtainStyledAttributes() 和之间有什么区别context.obtainStyledAttributes()

主题是我的应用程序风格?

android difference

3
推荐指数
1
解决办法
533
查看次数

有关Misra规则11.6的查询(MISRA C:2012)

我无法在此行中解决米斯拉规则11.6警告:

uint32_t * delay = (uint32_t *)0x40086D0C ;
Run Code Online (Sandbox Code Playgroud)

[ 仅供参考: typedef long unsigned int uint32_t;]

PC-Lint:注释923:从int转换为指针[MISRA 2012 Rule 11.6,必填]

我做了什么:

  • 明确类型转换,但不起作用
  • 使用memset(),它正在工作,但这不是解决Misra警告的正确方法。因为那是不必要的增加系统上的函数调用,它可能会降低系统性能。

您能否分享有关我的问题的有用想法?我们将不胜感激。

c misra

3
推荐指数
1
解决办法
1184
查看次数

删除"静态"关键字对函数的影响

最近,我学会了" 回溯 "功能的存在.此函数允许在某些情况下检索在没有调试信息的情况下编译的ELF运行程序的callstack.

它对我来说是完美的(我不能在生产程序中插入调试符号),但是对于"回溯"工作,有(大致)两个条件:

  • 告诉链接器添加额外信息(通过传递-rdynamic选项).
  • 将所有"静态"函数转换为"非静态"函数.

我担心的是,如果我满足这两个条件,我的程序将会变慢(因为编译器无法优化非静态函数,因为他优化了静态函数?).据我所知,使用-rdynamic添加额外信息不会影响程序的性能:它只是给ELF二进制文件增加了一点重量.

所以这是我的问题:

当所有静态函数变为非静态函数时,运行性能的影响是什么?

c

2
推荐指数
1
解决办法
132
查看次数

如何在if条件中声明将C三元语句转换为if/else?

因此,在查看大规模的互联网后,我无法找到答案.

说我有这段代码:

if(P4IN & GPIO_PIN1?0:1){
        if (state==1){
            state = 0;
            //Wait for this state to pass -- ends up saving the current state on button press.
            while (counter < 10000){
                counter++;
            }
        }
        else{
            state = 1;
            while (counter < 10000){
                counter++;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我怎么会重写这个,所以if(P4IN & GPIO_PIN1?0:1)不是这样写的.我不介意创建额外的if/else条件或扩展此代码块(用于MSP432)

谢谢你的时间.

c microcontroller if-statement ternary-operator

0
推荐指数
1
解决办法
88
查看次数