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

渲染多个图表,独享x轴 #9673

Closed
5 of 23 tasks
helloyoucan opened this issue Jan 3, 2019 · 1 comment
Closed
5 of 23 tasks

渲染多个图表,独享x轴 #9673

helloyoucan opened this issue Jan 3, 2019 · 1 comment

Comments

@helloyoucan
Copy link

helloyoucan commented Jan 3, 2019

  • I am using English in this issue. 在这个 Issue 中我使用了英文(强烈建议)。

General Questions

  • Required: I have read the document and examples and tried to solve it by myself. (必填)我读过了文档和教程,并且曾试图自己解决问题。
  • Required: I have searched for similar issues and that didn't help. (必填)我搜索过 issue 但是没有帮助。
  • Required: I have tried with the latest version of ECharts and still have this problem. (必填)我试过最新版本的 ECharts,还是存在这个问题。

In this issue, I have provided information with: 在这个 issue 中我提供了以下信息:

  • Required: issue type;(必填)issue 类型
  • Required: one sentence description in issue details;(必填)一句话的问题描述
  • Required: demo;(必填)能反映问题的例子(如果你想提问或报 bug)
  • Required: ECharts version;ECharts 版本

Issue Type

  • I have a question to ask about how to use ECharts to ...;我想提问如何使用 ECharts 实现某功能
  • I have a bug to report;我想要报 bug
  • I have a feature to request, e.g.: I'd like a new feature that ...;我需要一个新功能
  • I have a feature to enhance, e.g.: The current feature should be improved in the way that ...;我希望改进某个功能
  • There's something wrong with the documents;文档有些问题
  • Others, or I'm not sure which issue types to choose here;其他,或我不知道应该选什么类型

Issue Details

Expected Behavior

Current Behavior

Online Example

Topics

  • Legend
  • Tooltip
  • Event
  • Performance
  • SVG
  • Map
  • ECharts GL
  • Third-party libraries, e.g.: Vue.js, React

Anything Else We Need to Know

Environment

  • ECharts version;ECharts 版本: {DESCRIBE_HERE}

  • It happens only on certain browsers or operating systems. 对于特定浏览器或操作系统才会出现的问题,请提供相应环境信息:{BROWSER_VERSION_OR_OS_INFORMATION_HERE}

@helloyoucan
Copy link
Author

helloyoucan commented Jan 3, 2019

版本:3.x
//option

const xAxisData = [2,4,6,8,10]
const xAxisData2 = [1,2,3,4,5,6,7,8,9,10]
const datas = [4,8,6,2,4]
const datas2 = [1,0,1,0,1,0,1,0,1,0]
function setFontSize(size, width = 1920) {
  return size * (document.body.clientWidth / width)
}
option =((theme)=> {
  const color = {
    white: {
      text: '#333',
      line: '#666'
    },
    dark: {
      text: '#fff',
      line: '#999'
    }
  }[theme]
  return {
    title: {
      text: 'XXX',
      top: setFontSize(30),
      left: setFontSize(45),
      textStyle: {
        fontSize: setFontSize(40),
        fontWeight: 'bolder',
        color: color.text
      }
    },
    grid: {
      left: setFontSize(50),
      right: setFontSize(50),
      bottom: setFontSize(30),
      top: setFontSize(90),
      containLabel: true
    },
    legend: {
      top: setFontSize(100),
      textStyle: {
        color: color.text
      },
      data: ['价格走势( 元/斤 )', '销量( 斤 )']
    },
    xAxis: [
      {// 价格走势的X轴
        data: xAxisData2,
        position: 'top',
        // show: false,
        // type: 'value',
        // boundaryGap: false,
        axisTick: { show: true, alignWithLabel: true, lineStyle: { width: setFontSize(2), color: '#ffffff' }},
        axisLine: { lineStyle: { color: color.text, width: setFontSize(2) }},
        axisLabel: { fontSize: '.2rem', color: color.text }
      },
        {// 销量(斤)的X轴
        data: xAxisData,
        position: 'bottom',
        // type: 'value',
        // boundaryGap: false,
        // show: false,
        axisTick: { show: false, alignWithLabel: true, lineStyle: { width: setFontSize(2), color: '#ffffff' }},
        axisLine: { lineStyle: { color: color.text, width: setFontSize(2) }},
        axisLabel: { interval: 0, fontSize: '.2rem', color: color.text }
      }
    ],
    yAxis: [
      {
        name: '销量( 斤 )',
        type: 'value',
        position: 'right',
        show: true,
        nameTextStyle: { fontSize: setFontSize(18) },
        axisTick: { show: false },
        axisLine: { lineStyle: { color: color.line, width: setFontSize(2) }},
        splitLine: { show: true, lineStyle: { color: [color.line], opacity: 0.2, width: setFontSize(2), type: 'solid' }},
        axisLabel: { fontSize: setFontSize(16), color: color.text }
      },
      {
        name: '价格走势( 元/斤 )',
        type: 'value',
        position: 'left',
        nameTextStyle: { padding: [0, 0, 0, setFontSize(100)], fontSize: setFontSize(18) },
        axisTick: { show: false },
        axisLine: { lineStyle: { color: color.line, width: setFontSize(2) }},
        splitLine: { show: false, lineStyle: { color: [color.line], opacity: 0.2, width: setFontSize(1), type: 'dotted' }},
        axisLabel: { fontSize: setFontSize(16), color: color.text }
      }
    ],
    series: [
      {
        name: '销量( 斤 )',
        yAxisIndex: 1,
        type: 'bar',
        barWidth: '50%',
        barGap: '0%',
        itemStyle: { color: '#0096ff', borderWidth: 0, borderColor: '#0096ff' },
        data: datas
      },
      {
        name: '价格走势( 元/斤 )',
        xAxisIndex: 0,
        data: datas2,
        type: 'line',
        lineStyle: { color: '#ff9c00', width: setFontSize(2) },
        itemStyle: { opacity: 0 }
        // itemStyle: { color: '#ff9c00', borderWidth: setFontSize(10) }
      }
    ]
  }
}
)('white')

image

你好,我希望两个图表有不同的x轴,但是实际上是根据第一个x轴去渲染数据的,在配置中也没找到对应的配置,请问这个是我的配置问题还是没有这个配置项?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant