我能够使用下面的代码添加csv文件中的标签,但是csv每行的文本是相互重叠的,你知道如何移动它看起来更好吗?
WITH errors AS
(SELECT importable_id ,
importable_type,
created_at ,
substring(lower(replace_operation)
FROM 'code:(.+?)title') code_1 ,
split_part(replace_operation, 'code', 2) AS code_2 ,
split_part(replace_operation, 'title', 2) AS sec_part ,
split_part(split_part(replace_operation, 'title', 2), ':', 2) error_1 ,
split_part(replace_operation, 'title', 3) AS third_part ,
split_part(split_part(replace_operation, 'title', 3), ':', 2) error_2 ,
split_part(replace_operation, 'title', 4) AS f_part ,
split_part(split_part(replace_operation, 'title', 4), ':', 2) error_3 ,
split_part(replace_operation, 'title', 5) AS f_part ,
split_part(split_part(replace_operation, 'title', 5), ':', 2) error_4
FROM
( SELECT import_id ,
importable_id ,
i.importable_type ,
operation_errors AS replace_operation,
i.created_at
FROM import_results ir
JOIN imports i ON ir.import_id = i.id
WHERE operation_errors IS NOT NULL
AND i.created_at >= date_trunc('month', CURRENT_DATE :: date)) a
WHERE importable_type = 'Company')
SELECT importable_id,
created_at::date ,
code_1 ,
error_1 ,
error_2 ,
error_3 ,
error_4
FROM errors

答案 0 :(得分:0)
当您加入数据时,您可以访问已在datum
函数中演示的attr
。但是它还提供了index
,您可以将其用作第二个参数。
更改您的
.attr("dy", ".70em")
更像这样的事情。这样做是将0.7乘以每个项目的索引,生成它们的列表。您可能需要调整数字,具体取决于它的外观。
.attr("dy", (d, i) => `${i * 0.7}em`);