我正在尝试使用 chartist 为条形图创建图例,我使用 chartist 插件作为图例,但我无法将它与图表底部对齐,任何人都可以提供有关如何自定义的输入。(我曾尝试在 css 中使用它,但无法反映我的更改。)
HTML:
<chartist class="ct-chart ct-major-twelfth"
chartist-chart-type="Bar"
chartist-data="chartData"
chartist-chart-options="chartOptions">
</chartist>
JS:
chartData = {
labels: [],
series: [[]]
};
chartOptions= {
plugins: [
Chartist.plugins.legend()
]
};
传奇.JS:
$ct-series-colors: (#d70206, #F05B4F, #F4C63D, #453D3F) !default;
.ct-legend {
position: relative;
z-index: 10;
li {
position: relative;
padding-left: 23px;
margin-bottom: 3px;
}
li:before {
width: 12px;
height: 12px;
position: absolute;
left: 0;
content: '';
border: 3px solid transparent;
border-radius: 2px;
}
li.inactive:before {
background: transparent;
}
&.ct-legend-inside {
position: absolute;
top: 0;
right: 0;
}
@for $i from 0 to length($ct-series-colors) {
.ct-series-#{$i}:before {
background-color: nth($ct-series-colors, $i + 1);
border-color: nth($ct-series-colors, $i + 1);
}
}
}
也有人可以让我知道如何在条形顶部添加 y 轴值。我尝试使用下面的 css 文件但仍然无法获取标签(类似于 Chartist.plugins.ctPointLabels)但似乎它仅适用于折线图。
CSS:
.ct-chart .ct-bar {
stroke-width: 60px;
}
.ct-chart .ct-label, .ct-chart .ct-label.ct-horizontal {
text-align: center;
}
.ct-bar-label {
text-anchor: middle;
alignment-baseline: hanging;
fill: white;
}
提前致谢。