简体   繁体   English

如何更改 AnyChart React 标签云中的主题?

[英]How do I change the theme in an AnyChart React tag cloud?

I am creating a tag cloud word cloud using the React library from AnyChart.我正在使用 AnyChart 中的 React 库创建标签云词云。 How do I change the color theme of it?如何更改它的颜色主题? The answer found here doesn't seem to work: 在这里找到的答案似乎不起作用:

import React from "react";
import ReactDOM from "react-dom";
import AnyChart from "anychart-react";
import anychart from "anychart";
anychart.theme("coffee");

var data = [
  { x: "learning", value: 80 },
  { x: "includes", value: 56 },
  { x: "lists", value: 44 },
  { x: "meaning", value: 40 },
  { x: "useful", value: 36 },
  { x: "different", value: 32 },
  { x: "grammar", value: 28 },
  { x: "teaching", value: 24 },
  { x: "example", value: 20 },
  { x: "thing", value: 12 }
];

// create a chart and set the data
var chart = anychart.tagCloud(data);
//chart.theme = anychart.palettes.coffee;

ReactDOM.render(
  <AnyChart width={800} height={600} instance={chart} title="Column chart" />,
  document.getElementById("root")
);

Full demo is here完整的演示在这里

It is available if you are using the instance attribute.如果您使用instance属性,则它可用。 THe idea is to create the chart with the usual library API, and then apply this instance to the component.想法是使用常用库 API 创建图表,然后将此实例应用于组件。 In this case, all library features are available via API.在这种情况下,所有库功能都可以通过 API 获得。 So, you can use this call所以,你可以使用这个调用

chart.theme = anychart.palettes.coffee;

in the instance.在这种情况下。 For details, check the live sample .有关详细信息,请查看实时示例

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

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