- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
C3 似乎在处理长字符串作为水平条形图表中的标签时遇到了麻烦。这是一个示例片段:
let bookData = [{
"title": "1984",
"author": "George Orwell",
"year": "1949",
"count": 6
}, {
"title": "The Handmaid's Tale",
"author": "Margaret Atwood",
"year": "1985",
"count": 3
}, {
"title": "The Picture of Dorian Gray",
"author": "Oscar Wilde",
"year": "1890",
"count": 2
}, {
"title": "Animal Farm",
"author": "George Orwell",
"year": "1945",
"count": 5
}, {
"title": "The Hobbit",
"author": "J.R.R. Tolkien",
"year": "1937",
"count": 3
}, {
"title": "Alice's Adventures in Wonderland",
"author": "Lewis Carroll",
"year": "1865",
"count": 3
}, {
"title": "Harry Potter Boxset (Harry Potter, #1-7)",
"author": "J.K. Rowling",
"year": "1998",
"count": 2
}, {
"title": "Romeo and Juliet",
"author": "William Shakespeare",
"year": "1597",
"count": 4
}, {
"title": "Macbeth",
"author": "William Shakespeare",
"year": "1606",
"count": 3
}, {
"title": "King Lear",
"author": "William Shakespeare",
"year": "1603",
"count": 2
}, {
"title": "The Merchant of Venice",
"author": "William Shakespeare",
"year": "1596",
"count": 1
}, {
"title": "Wuthering Heights",
"author": "Emily Bront\u00eb",
"year": "1847",
"count": 1
}, {
"title": "The Outsiders",
"author": "S.E. Hinton",
"year": "1967",
"count": 1
}, {
"title": "The Metamorphosis",
"author": "Franz Kafka",
"year": "1915",
"count": 1
}, {
"title": "The Glass Menagerie",
"author": "Tennessee Williams",
"year": "1945",
"count": 1
}, {
"title": "Waiting for Godot",
"author": "Samuel Beckett",
"year": "1953",
"count": 1
}, {
"title": "The Merry Adventures of Robin Hood",
"author": "Howard Pyle",
"year": "1883",
"count": 1
}, {
"title": "The Complete Grimm's Fairy Tales",
"author": "Jacob Grimm",
"year": "1812",
"count": 1
}, {
"title": "The Count of Monte Cristo",
"author": "Alexandre Dumas",
"year": "1844",
"count": 3
}, {
"title": "Pride and Prejudice",
"author": "Jane Austen",
"year": "1813",
"count": 5
}, {
"title": "The Hitchhiker's Guide to the Galaxy: A Trilogy in Four Parts",
"author": "Douglas Adams",
"year": "1986",
"count": 3
}, {
"title": "The Three Musketeers (The D'Artagnan Romances, #1)",
"author": "Alexandre Dumas",
"year": "1844",
"count": 1
}, {
"title": "The Call of the Wild",
"author": "Jack London",
"year": "1903",
"count": 1
}, {
"title": "David Copperfield",
"author": "Charles Dickens",
"year": "1849",
"count": 1
}, {
"title": "The Adventures of Tom Sawyer",
"author": "Mark Twain",
"year": "1876",
"count": 1
}, {
"title": "Julius Caesar",
"author": "William Shakespeare",
"year": "1599",
"count": 1
}, {
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": "1960",
"count": 5
}, {
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": "1925",
"count": 5
}, {
"title": "A Farewell to Arms",
"author": "Ernest Hemingway",
"year": "1929",
"count": 2
}, {
"title": "Twelfth Night",
"author": "William Shakespeare",
"year": "1601",
"count": 1
}, {
"title": "Lord of the Flies",
"author": "William Golding",
"year": "1954",
"count": 3
}, {
"title": "Charlotte's Web",
"author": "E.B. White",
"year": "1952",
"count": 1
}, {
"title": "Frankenstein",
"author": "Mary Wollstonecraft Shelley",
"year": "1818",
"count": 1
}, {
"title": "Moby-Dick or, The Whale",
"author": "Herman Melville",
"year": "1851",
"count": 2
}, {
"title": "The Scarlet Letter",
"author": "Nathaniel Hawthorne",
"year": "1850",
"count": 1
}, {
"title": "Fahrenheit 451",
"author": "Ray Bradbury",
"year": "1953",
"count": 2
}, {
"title": "Slaughterhouse-Five",
"author": "Kurt Vonnegut",
"year": "1969",
"count": 1
}, {
"title": "The Shining (The Shining, #1)",
"author": "Stephen King",
"year": "1977",
"count": 1
}, {
"title": "A Clockwork Orange",
"author": "Anthony Burgess",
"year": "1962",
"count": 1
}, {
"title": "Little Women (Little Women, #1)",
"author": "Louisa May Alcott",
"year": "1868",
"count": 1
}, {
"title": "Things Fall Apart",
"author": "Chinua Achebe",
"year": "1958",
"count": 1
}, {
"title": "One Flew Over the Cuckoo's Nest",
"author": "Ken Kesey",
"year": "1962",
"count": 1
}, {
"title": "Anna Karenina",
"author": "Leo Tolstoy",
"year": "1878",
"count": 1
}, {
"title": "A Man for All Seasons",
"author": "Robert Bolt",
"year": "1960",
"count": 1
}, {
"title": "Hamlet",
"author": "William Shakespeare",
"year": "1603",
"count": 1
}, {
"title": "Hedda Gabler",
"author": "Henrik Ibsen",
"year": "1890",
"count": 1
}, {
"title": "The Idiot",
"author": "Fyodor Dostoyevsky",
"year": "1868",
"count": 1
}, {
"title": "Persepolis: The Story of a Childhood (Persepolis, #1)",
"author": "Marjane Satrapi",
"year": "2000",
"count": 1
}, {
"title": "Watchmen",
"author": "Alan Moore",
"year": "1987",
"count": 1
}, {
"title": "The Arabian Nights: Tales of 1001 Nights, Volume 1",
"author": "Anonymous",
"year": "800",
"count": 1
}, {
"title": "No Exit",
"author": "Jean-Paul Sartre",
"year": "1944",
"count": 1
}, {
"title": "The Hound of the Baskervilles",
"author": "Arthur Conan Doyle",
"year": "1902",
"count": 1
}, {
"title": "Antigone (The Theban Plays, #3)",
"author": "Sophocles",
"year": "-441",
"count": 1
}, {
"title": "The Rime of the Ancient Mariner",
"author": "Samuel Taylor Coleridge",
"year": "1798",
"count": 1
}, {
"title": "Great Expectations",
"author": "Charles Dickens",
"year": "1860",
"count": 2
}, {
"title": "The Illiad of Homer",
"author": "Homer",
"year": "-750",
"count": 1
}, {
"title": "The Odyssey",
"author": "Homer",
"year": "-720",
"count": 1
}, {
"title": "Sense and Sensibility",
"author": "Jane Austen",
"year": "1811",
"count": 1
}, {
"title": "Emma",
"author": "Jane Austen",
"year": "1815",
"count": 1
}, {
"title": "Jane Eyre",
"author": "Charlotte Bront\u00eb",
"year": "1847",
"count": 1
}, {
"title": "Of Mice and Men",
"author": "John Steinbeck",
"year": "1937",
"count": 1
}, {
"title": "Brave New World",
"author": "Aldous Huxley",
"year": "1932",
"count": 3
}, {
"title": "Life of Pi",
"author": "Yann Martel",
"year": "2001",
"count": 1
}, {
"title": "The Sisters Brothers",
"author": "Patrick deWitt",
"year": "2011",
"count": 1
}, {
"title": "The Kite Runner",
"author": "Khaled Hosseini",
"year": "2003",
"count": 1
}, {
"title": "The War of the Worlds",
"author": "H.G. Wells",
"year": "1898",
"count": 1
}, {
"title": "The Restaurant at the End of the Universe (Hitchhiker's Guide to the Galaxy, #2)",
"author": "Douglas Adams",
"year": "1980",
"count": 1
}, {
"title": "The Chrysalids",
"author": "John Wyndham",
"year": "1955",
"count": 1
}, {
"title": "Gulliver's Travels",
"author": "Jonathan Swift",
"year": "1726",
"count": 1
}, {
"title": "The Invisible Man",
"author": "H.G. Wells",
"year": "1897",
"count": 1
}, {
"title": "The Gulag Archipelago 1918-1956",
"author": "Aleksandr Solzhenitsyn",
"year": "1973",
"count": 1
}, {
"title": "Cloud Atlas",
"author": "David Mitchell",
"year": "2004",
"count": 1
}, {
"title": "Holy Bible: King James Version",
"author": "Anonymous",
"year": "1611",
"count": 1
}, {
"title": "The Catcher in the Rye",
"author": "J.D. Salinger",
"year": "1951",
"count": 1
}, {
"title": "The Time Machine",
"author": "H.G. Wells",
"year": "1895",
"count": 1
}];
const labels = bookData.map((book) => book.title);
const y = bookData.map((book) => book.count);
labels.splice(0, 0, "x");
y.splice(0, 0, "count");
const char = c3.generate({
data: {
x: "x",
columns: [
labels, y
],
type: "bar"
},
axis: {
x: {
type: "category",
},
y: {
tick: {
values: _.range(0, 7),
}
},
rotated: true,
},
bindto: "#book-title-histogram",
size: {
height: 1400,
width: 800,
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.6.2/c3.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.6.2/c3.js"></script>
<div id="book-title-histogram">
<!-- content goes here -->
</div>
最佳答案
从这里thread您可以使用 axis.x.tick.multiline = false
。
然后像这样更新你的代码:
const char = c3.generate({
data: {
x: "x",
columns: [
labels, y
],
type: "bar"
},
axis: {
x: {
type: "category",
tick: {
multiline:false
}
},
y: {
tick: {
values: _.range(0, 7),
}
},
rotated: true,
},
bindto: "#book-title-histogram",
size: {
height: 1400,
width: 800,
}
});
此外,您可以使用 axis.x 对象的不同选项来获得您想要的结果(即:tick.multilineMax、x.height...)。
在文档中,您可以找到很多不同的参数来使用 here .
您还可以增加图表的总高度(使用固定高度或 bookData.length)并执行以下操作:
const char = c3.generate({
data: {
x: "x",
columns: [
labels, y
],
type: "bar"
},
axis: {
x: {
type: "category",
tick: {
multiline:true,
}
},
y: {
tick: {
values: _.range(0, 7),
}
},
rotated: true,
},
bindto: "#book-title-histogram",
size: {
height: bookData.length * 50
width: 800,
}
});
关于javascript - C3 中水平条形图标签中的长字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50826873/
所以我使用一个带有整个 block 的标签作为链接,它是一个产品展示,所以你点击它会转到产品页面。现在我创建了一个标签作为链接到购物车页面的按钮。所以我让它工作,但是当我点击购物车按钮时,两个页面都会
根据 Web 标准,创建带有标题 1 的链接的正确代码是什么? 是吗 stackoverflow 或 stackoverflow 谢谢 最佳答案 根据网络标准,您不能将 block 元素放入内
在Java中它是这样写的..当我移植这段代码时...意识到没有这样的东西 break 和continue . 我知道这些命令没有包含在内,因为在使用带有命令的 goto 时必须有一种更简洁的方法来执
我们有一个相当标准的发布过程,使用 Visual Source Safe 在发布之前标记构建。这允许我们在出现任何问题时从该标签中获取,并在需要更改时使用它进行分支。 我们有几个不同的项目,并且总是使
我必须创建一个搜索内容,其中包含搜索框、标题和段落描述。默认情况下,描述被禁用,当我输入一些与描述文本匹配的文本时,描述段落标签应该打开。一些匹配的演示是这样的: [ fiddle ][1] 但默认情
我一直在阅读有关 的文档标签,我似乎无法理解它与简单地使用 有何不同那是 display: none; 文档:template tag 例子 对比 例子
我需要一个脚本来复制当开关按钮打开时标记,当开关按钮关闭时删除标记。我需要一个简单的方法。这是开关按钮: 我试过这个: var change
JSF 是一个 MVC 框架,但我很困惑为什么我们已经有了这么多 HTML 标签还需要 JSF 标签。毫无疑问,JSF 简化了很多事情。我想进一步了解 JSF 中的模型 View 和 Controll
我在这个 website 上看到了那些 html 代码: Homepa
我添加了 photoswipe 插件,可以使用 搜索我的所有照片。标签,如果点击,照片就会变成全屏。我让它工作了,但现在我的导航栏(有 标签)在点击时会触发 photoswipe 插件。 在 ph
标签
我正在尝试截断显示自 的文本标签,但它不工作。我将样式应用于其他标签样式并且它确实有效(我看到的示例中没有一个使用 标签)。我想知道是否有人可以向我解释为什么会这样(我不是最擅长 HTML/CSS
HTML 是这样的: Menu 1 Menu 2 Sub menu 2
我可以更改 TextInputLayout 的位置 float 标签(底部 float 标签)吗?我需要为波纹管 float 标签设置正确的位置。 最佳答案 我解决了我的问题,这是我的 xml:
我的代码是 printMsg : function(data) { $("#message").html(data.bodyText); ... } 这里 data.body
我是 Scrapy 和 Xpath 的初学者,我正在寻找解析具有以下结构的网站 cat1 value1 value2
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求提供代码的问题必须表现出对所解决问题的最低限度理解。包括尝试过的解决方案、为什么它们不起作用,以及
我必须从 xml 中解析数据。这是我的 xml- 或者它的 url 是:http://mobileecommerce.site247365.com/admin/catdata.xml News f
如何创建应该允许多行数据的标记。不要说使用textarea标签。我知道,但我只想 标记因为标签具有 value 属性。所以当我从 xml 文件获取值时,我应该使用 jquery 语法动态获取.. 最佳
我有一个页面使用我定义的某些样式。 在同一页面上,我刚刚导入了一个使用自己样式的外部 jQuery 插件,例如,包括 。被我自己覆盖的标签样式。 如何确保我的样式表中的样式不会覆盖 jQuery 插件
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我是一名优秀的程序员,十分优秀!