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

FFchart生成的图表背景是黑色的, 代码如下,请问怎么弄成透明背景 #403

Open
yangshen2000 opened this issue Oct 24, 2023 · 1 comment

Comments

@yangshen2000
Copy link

const { FFScene, FFText, FFVideo, FFAlbum, FFImage, FFCreator, FFVideoAlbum, FFChart } = require("ffcreator");
const path = require("path");

const outputDir = path.join(__dirname, "./output");
const cacheDir = path.join(__dirname, "./cache");

// 创建FFCreator 实例
const creator = new FFCreator({
  cacheDir,
  outputDir,
  width: 600,
  height: 600,
  transparent: true,
  voImageExtra: 'png',
  cacheFormat: 'png',
  ext: 'mov',
  defaultOutputOptions: {
    merge: false,
    options: ['-vcodec', 'png', '-c:v', 'libx264']
  },
});

// 创建场景
const scene = new FFScene();
scene.setDuration(3);
scene.setBgColor('transparent')
creator.addChild(scene);


option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line'
    }
  ]
};
const fchart = new FFChart({
  // theme: 'light',
  option: option,
  x: 100,
  y: 100,
  width: 400,
  height: 400,
});
scene.addChild(fchart);

creator.start(); // 开始加工
creator.output(path.join(__dirname, "./output/chart.mov")); // 开始加工

creator.on('complete', e => {
  console.log(`FFCreator completed`)
});
@drawcall
Copy link
Member

#334

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

2 participants