Browse Source

Remove useless code for categories and update sample for categorized axis - #266

pull/274/head
Masayuki Tanaka 11 years ago
parent
commit
98502fe674
  1. 10
      c3.js
  2. 4
      c3.min.js
  3. 31
      htdocs/samples/categorized.html

10
c3.js

@ -759,7 +759,6 @@
if (isEmpty(__axis_x_tick_culling)) { if (isEmpty(__axis_x_tick_culling)) {
__axis_x_tick_culling = false; __axis_x_tick_culling = false;
} }
axis.categories(__axis_x_categories);
} else { } else {
// TODO: move this to c3_axis // TODO: move this to c3_axis
axis.tickOffset = function () { axis.tickOffset = function () {
@ -4637,7 +4636,6 @@
// update categories if exists // update categories if exists
if ('categories' in args && isCategorized) { if ('categories' in args && isCategorized) {
__axis_x_categories = args.categories; __axis_x_categories = args.categories;
xAxis.categories(__axis_x_categories);
} }
// use cache if exists // use cache if exists
if ('cacheIds' in args && hasCaches(args.cacheIds)) { if ('cacheIds' in args && hasCaches(args.cacheIds)) {
@ -5063,8 +5061,7 @@
function c3_axis(d3, isCategory) { function c3_axis(d3, isCategory) {
var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickValues = null, tickFormat, tickArguments; var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickValues = null, tickFormat, tickArguments;
var tickOffset = 0, tickCulling = true; var tickOffset = 0, tickCulling = true, tickCentered;
var categories = [], tickCentered;
function axisX(selection, x) { function axisX(selection, x) {
selection.attr("transform", function (d) { selection.attr("transform", function (d) {
@ -5239,11 +5236,6 @@
tickValues = x; tickValues = x;
return axis; return axis;
}; };
axis.categories = function (x) {
if (!arguments.length) { return categories; }
categories = x;
return axis;
};
return axis; return axis;
} }

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

31
htdocs/samples/categorized.html

@ -3,14 +3,18 @@
<link href="/css/c3.css" rel="stylesheet" type="text/css"> <link href="/css/c3.css" rel="stylesheet" type="text/css">
</head> </head>
<body> <body>
<div id="chart"></div> <div id="chart1"></div>
<div id="chart2"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="/js/c3.js"></script>
<script> <script>
var chart = c3.generate({ var chart1 = c3.generate({
bindto: '#chart1',
data: { data: {
x: 'x',
columns: [ columns: [
['x', '1e-3', '1e-2', '1'],
['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250] ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250]
] ]
}, },
@ -21,9 +25,28 @@
} }
}); });
var chart2 = c3.generate({
bindto: '#chart2',
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250]
]
},
axis: {
x: {
categories: ['1e-3', '1e-2', '1e-1', '0', 'hoge'],
type: 'categorized'
}
}
});
setTimeout(function () {
chart1.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]});
}, 1000);
setTimeout(function () { setTimeout(function () {
chart.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]}); chart2.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]});
}, 500); }, 2000);
</script> </script>
</body> </body>

Loading…
Cancel
Save