echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Suggestion: How can I set alignment of text contain inside graphics element of type "rect"

Open ambikeshshukla opened this issue 9 years ago • 3 comments

One-line summary [问题简述]

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

Expected behavior [期望结果]

ECharts option [ECharts配置项]

app.title = '坐标轴刻度与标签对齐';

option = {
    color: ['#3398DB'],
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    graphic : {
      type:'rect',
      shape : {
          x:200,
          y:200,
          width:200,
          height:100,
          origin: [70000, 75],
      },
      style : {
        text: 'text inside rect',
        //how can I align or rotate text
        fill:'#fff',
        align:'left'
        
      }
      
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'直接访问',
            type:'bar',
            barWidth: '60%',
            data:[10, 52, 200, 334, 390, 330, 220]
        }
    ]
};

Other comments [其他信息]

ambikeshshukla avatar Aug 18 '17 07:08 ambikeshshukla

opts.style.textPosition 文字位置,可以为 'inside'、 'left'、 'right'、 'top'、 'bottom',或一个二维数组 [x, y] 表示相对形状的位置。 opts.style.textAlign 文字水平对齐方式,可取值:'left'、 'center'、 'right',默认根据 textPosition 计算。

参考zrenderdisplayable文档:

https://ecomfe.github.io/zrender-doc/public/api.html#zrenderdisplayable

hiwanz avatar Nov 30 '17 06:11 hiwanz

opts.style.textPosition 'left'、 'right'、 'top'、 'bottom' goes outside of rect.

amittonge avatar Apr 11 '18 09:04 amittonge

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 10 '20 09:04 stale[bot]