简体   繁体   English

百度的echarts - 填充2行之间的空间

[英]Baidu's echarts - filling up space between 2 lines

I would like to find an approach on how to draw 2 lines in ECharts and fill up the space between them like this:我想找到一种如何在 ECharts 中绘制 2 条线并像这样填充它们之间的空间的方法:

在此处输入图片说明

So that each line has it's own color.这样每条线都有自己的颜色。 Depending on order of lines - area is filled into one color or another (see image).根据行的顺序 - 区域填充为一种颜色或另一种颜色(见图)。

Is there a native way of doing it?有本地的方法吗? I found that some people are mentioning extensions , but nobody is providing any kind of instructions on how to write them from scratch.. Nor I found any examples on official documentation page.我发现有些人提到了extensions ,但没有人提供任何关于如何从头开始编写它们的说明。我也没有在官方文档页面上找到任何示例。 I would appreciate if somebody could point me to correct direction on how to achieve this goal.如果有人能指出我如何实现这一目标的正确方向,我将不胜感激。

In the worst case - I would accept other libraries if they have such very needed option.在最坏的情况下 - 如果其他图书馆有这样非常需要的选择,我会接受他们。

The best I could do is this:我能做的最好的是:

var chartOptions = {
    xAxis: [{
        type: 'value'
    }],
    yAxis: [{
        type: 'value'
    }],
    series: [{
        type: "line",
        data: [[0, 4], [1, 3], [2, 2], [3, 2], [4, 1], [5, 2]],
    }, {
        type: "line",
        data: [[0, 2], [1, 3], [2, 4], [3, 8], [4, 5], [5, 0]],
    }],
};
var aChart = echarts.init(document.getElementById('aGraph'));
aChart.setOption(chartOptions);

在此处输入图片说明

I've usedareaStyle to fill the area between the axisLine and the data.我使用areaStyle填充轴和数据之间的区域。 I would try to solve this issue by adding the green/yellow areaStyle to the green series, adding a pink areaStyle to the red series, and then adding a white areaStyle to a new series made up from the min values from the other two series.我会尝试通过将绿色/黄色 areaStyle 添加到绿色系列,将粉红色 areaStyle 添加到红色系列,然后将白色 areaStyle 添加到由其他两个系列的最小值组成的新系列来解决这个问题。 Combined with a lineStyle with a width of 0, you could mostly achieve the look in the sketch, however, the minimum series fill would probably also obscure the interior grid lines.结合宽度为 0 的 lineStyle,您可以在大多数情况下实现草图中的外观,但是,最小系列填充可能也会掩盖内部网格线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM