Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot use '\n' in custom format text #14

Closed
Janrin opened this issue May 7, 2019 · 8 comments
Closed

cannot use '\n' in custom format text #14

Janrin opened this issue May 7, 2019 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Janrin
Copy link

Janrin commented May 7, 2019

such as code below, '\n' is replaced by toString

label: { // 在文本中,可以对部分文本采用 rich 中定义样式。 // 这里需要在文本中使用标记符号: //{styleName|text content text content}` 标记样式名。
// 注意,换行仍是使用 '\n'。
formatter: [
'{a|这段文本采用样式a}',
'{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
].join('\n'),

// 这里是文本块的样式设置:
color: '#333',
fontSize: 5,
fontFamily: 'Arial',
borderWidth: 3,
backgroundColor: '#984455',
padding: [3, 10, 10, 5],
lineHeight: 20,

// rich 里是文本片段的样式设置:
rich: {
    a: {
        color: 'red',
        lineHeight: 10
    },
    b: {
        backgroundColor: {
            image: 'xxx/xxx.jpg'
        },
        height: 40
    },
    x: {
        fontSize: 18,
        fontFamily: 'Microsoft YaHei',
        borderColor: '#449933',
        borderRadius: 4
    },
}

}
`

@tomLadder
Copy link
Owner

Can you give me a small static example in order to reproduce this issue?

regards,
Tom

@EngsShi
Copy link

EngsShi commented Aug 21, 2019

same issue

@ty-sang
Copy link

ty-sang commented Aug 21, 2019

Formatter doesn't work, any plan to add this @tomLadder ?

@tomLadder
Copy link
Owner

@SHIEER Yes someone should definitely have a look at it.

@EngsShi
Copy link

EngsShi commented Aug 31, 2019

const airOption2 = ({
xAxisData,
seriesData,
color = '#848dc8',
}) => {
return {
color: color,
grid: {
right: 20,
left: 40,
top: 20,
bottom: 80
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
xAxis: {
type: 'category',
data: xAxisData,
splitLine: {
show: false
},
axisLine: {
show: false
},
axisLabel: {
rotate: 45,
formatter: function (value, index) {
return value + "\n"; // here
},
// formatter: function (value, index) {
// return value
// .toString()
// .split('')
// .join('\n')
// }
}
},
yAxis: {
type: 'value',
splitLine: {
show: true
},
axisLine: {
show: false
}
},
series: [
{
data: seriesData,
type: 'bar',
barWidth: '30%',
itemStyle: {
barBorderRadius: [5, 5, 5, 5],
width: 50,
top: 10
},
label: {
show: true,
position: 'top',
}
}
]
}
}

it will catch, if you add '\n'。
SyntaxError: Unexpected identifier 'yAxis'. Expected a ';' following a return statement

@EngsShi
Copy link

EngsShi commented Aug 31, 2019

formatter: function (value, index) {
return value + "(\n)"; // here
},

if use "(\n)" or "\n;" will nothing happened

@tomLadder
Copy link
Owner

Currently working on v2.0.0. Will be fixed!

Cheers,
Tom

@tomLadder tomLadder self-assigned this Sep 4, 2019
@tomLadder tomLadder added the bug Something isn't working label Sep 4, 2019
@tomLadder
Copy link
Owner

Just released v2.0.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants