Browse Source

Merge branch 'jasonxunxu-master'

pull/274/head
Masayuki Tanaka 11 years ago
parent
commit
fc6583108d
  1. 13
      c3.js
  2. 6
      c3.min.js
  3. 31
      htdocs/samples/categorized.html

13
c3.js

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

6
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">
</head>
<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="/js/c3.js"></script>
<script>
var chart = c3.generate({
var chart1 = c3.generate({
bindto: '#chart1',
data: {
x: 'x',
columns: [
['x', '1e-3', '1e-2', '1'],
['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 () {
chart.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]});
}, 500);
chart2.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]});
}, 2000);
</script>
</body>

Loading…
Cancel
Save