Commit fc658310 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Merge branch 'jasonxunxu-master'

parents facf083d 98502fe6
...@@ -759,7 +759,6 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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) {
...@@ -5102,8 +5099,7 @@ ...@@ -5102,8 +5099,7 @@
} }
return newScale; return newScale;
} }
function textFormatted(i) { function textFormatted(v) {
var v = isCategory && i < categories.length ? categories[i] : i;
return tickFormat ? tickFormat(v) : v; return tickFormat ? tickFormat(v) : v;
} }
function axis(g) { function axis(g) {
...@@ -5240,11 +5236,6 @@ ...@@ -5240,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;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,14 +3,18 @@ ...@@ -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 @@ ...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment