| Page 1 of 1 | [ 5 posts ] |
|
Anybody could give me some clue, how to control the bar width in a column chart? I hope to set bar width thinner while the browser window size change smaller.
I've found this thread about this topic from : viewtopic.php?p=7787 But Tripp's solution is in YUI2 but not YUI3. Could Tripp or anyone else give more clue? Thanks. |
|
You can set the width of the columns in a chart by defining a seriesCollection and setting the styles.marker.width value. Below is a link to an example showing how to define seriesCollection in a chart.
http://yuilibrary.com/yui/docs/charts/charts-objectstyles.html The example does not set the marker width but you can do so by creating a seriesCollection like the example below: Code: var seriesCollection = [ { xKey: "date", yKey: "miscellaneous", type: "column", styles: { marker: { width: 4 } } }, { xKey: "date", yKey: "expenses", type: "column", styles: { marker: { width: 4 } } }, { xKey: "date", yKey: "revenue", type: "column", styles: { marker: { width: 4 } } } ], mychart = new Y.Chart({type:"column", render:"#mychart", categoryKey: "date", seriesCollection: seriesCollection, dataProvider:myDataValues}); Thanks, Tripp |
|
Yes Tripp, that is what I expected.
But I still have some confusion about the "marker". After changed code to: Code: { xKey: "date", yKey: "expenses", type: "column", styles: { marker: { width: 4 }, fill: { color: "#ff0000" }, } }, The color setting doesn't work and it must be like below, the color setting DOES work. Code: { xKey: "date", yKey: "expenses", type: "column", styles: { marker: { width: 4, fill: { color: "#ff0000" } } } }, And in the example , I picked codes, it seems these two series has the same effection, but the codes are different. Could you Tripp pls tell me something about the usage of "marker" ? Thanks. Code: { type:"column", xAxis:"dateRange", yAxis:"financials", xKey:"date", yKey:"miscellaneous", xDisplayName:"Date", yDisplayName:"Miscellaneous", styles: { border: { weight: 1, color: "#58006e" }, over: { fill: { alpha: 0.7 } } } }, { type:"column", xAxis:"dateRange", yAxis:"financials", xKey:"date", yKey:"expenses", yDisplayName:"Expenses", styles: { marker:{ fill: { color: "#e0ddd0" }, border: { weight: 1, color: "#cbc8ba" }, over: { fill: { alpha: 0.7 } } } } }, |
|
This is how the marker is styled: (across series types)
Code: styles: { marker: { fill: { color: "#9aa" }, border: { color: "#999", width: 1 }, height: 5, (ignored for column charts) width: 5 (ignored for bar charts) } } In the case of a histogram (column/bar), this will actually work. Code: styles: { fill: {}, border:{}, width:val, height:val } The second case will work because it the marker is the only stylable element of a column/bar series. The first method allows for more consistency in defining styles for different series types. The second is less verbose. This is a bug in the example. The example should not contain both approaches without explanation. Thanks, Tripp |
|
Thank you Tripp for your detailed explanation.
Is my comprehension right? If the codes like Code 1: Code: styles: { fill: {xxx}, border:{xxx}, width:val, height:val } Then the styles will try applied to all series types. If the codes like Code 2: Code: styles: { marker: { fill: {xxx}, border: {xxx}, height: val, width: val } } Then the marker styles will applied to the specific series types. Meanwhile, 1. Code 2 has the priority to Code 1. 2. Code 2 has support some parameters that Code 1 does not support. I've learned many thing from Tripp, thank you Tripp again. dusjj. |
| Page 1 of 1 | [ 5 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group