Skip to content

Commit

Permalink
docs(all): Improve readability & undocumented APIs (#206)
Browse files Browse the repository at this point in the history
Make to generate undocumented APIs changing some code structures.
Changed the arbitrary colon char to dot char.

Fix #190
Close #206
  • Loading branch information
netil authored Nov 28, 2017
1 parent bec92dd commit b2ad2a5
Show file tree
Hide file tree
Showing 22 changed files with 891 additions and 851 deletions.
218 changes: 112 additions & 106 deletions src/api/api.axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {isValue, isDefined, isObjectType, extend} from "../internals/util";

/**
* Set the min/max value
* @param $$
* @param type
* @param value
* @param {Chart} $$
* @param {String} type
* @param {Object} value
* @return {undefined}
* @private
*/
const setMinMax = ($$, type, value) => {
const config = $$.config;
Expand Down Expand Up @@ -39,9 +40,10 @@ const setMinMax = ($$, type, value) => {

/**
* Get the min/max value
* @param $$
* @param type
* @param {Chart} $$
* @param {String} type
* @return {{x, y, y2}}
* @private
*/
const getMinMax = ($$, type) => {
const config = $$.config;
Expand All @@ -59,108 +61,112 @@ const getMinMax = ($$, type) => {
/**
* Define axis
*/
const axis = function() {};

/**
* Get and set axis labels.
* @method axis․labels
* @instance
* @memberof Chart
* @param {Object} labels specified axis' label to be updated.
* @example
* // Update axis' label
* chart.axis.labels({
* x: "New X Axis Label",
* y: "New Y Axis Label"
* });
*/
axis.labels = function(labels) {
const $$ = this.internal;

if (arguments.length) {
Object.keys(labels).forEach(axisId => {
$$.axis.setLabelText(axisId, labels[axisId]);
});

$$.axis.updateLabels();
}
};

/**
* Get and set axis min value.
* @method axis:min
* @instance
* @memberof Chart
* @param {Object} min If min is given, specified axis' min value will be updated. If no argument is given, the current min values for each axis will be returned.
* @example
* // Update axis' min
* chart.axis.min({
* x: -10,
* y: 1000,
* y2: 100
* });
*/
axis.min = function(min) {
return arguments.length ?
setMinMax(this.internal, "min", min) :
getMinMax(this.internal, "min");
};

/**
* Get and set axis max value.
* @method axis:max
* @instance
* @memberof Chart
* @param {Object} max If max is given, specified axis' max value will be updated. If no argument is given, the current max values for each axis will be returned.
* @example
* // Update axis' label
* chart.axis.max({
* x: 100,
* y: 1000,
* y2: 10000
* });
*/
axis.max = function(max) {
return arguments.length ?
setMinMax(this.internal, "max", max) :
getMinMax(this.internal, "max");
};
const axis = extend(() => {}, {
/**
* Get and set axis labels.
* @method axis․labels
* @instance
* @memberOf Chart
* @param {Object} labels specified axis' label to be updated.
* @example
* // Update axis' label
* chart.axis.labels({
* x: "New X Axis Label",
* y: "New Y Axis Label"
* });
*/
labels: function(labels) {
const $$ = this.internal;

if (arguments.length) {
Object.keys(labels).forEach(axisId => {
$$.axis.setLabelText(axisId, labels[axisId]);
});

$$.axis.updateLabels();
}
},

/**
* Get and set axis min value.
* @method axis․min
* @instance
* @memberOf Chart
* @param {Object} min If min is given, specified axis' min value will be updated. If no argument is given, the current min values for each axis will be returned.
* @example
* // Update axis' min
* chart.axis.min({
* x: -10,
* y: 1000,
* y2: 100
* });
*/
min: function(min) {
const $$ = this.internal;

return arguments.length ?
setMinMax($$, "min", min) :
getMinMax($$, "min");
},

/**
* Get and set axis max value.
* @method axis․max
* @instance
* @memberOf Chart
* @param {Object} max If max is given, specified axis' max value will be updated. If no argument is given, the current max values for each axis will be returned.
* @example
* // Update axis' label
* chart.axis.max({
* x: 100,
* y: 1000,
* y2: 10000
* });
*/
max: function(max) {
const $$ = this.internal;

return arguments.length ?
setMinMax($$, "max", max) :
getMinMax($$, "max");
},

/**
* Get and set axis min and max value.
* @method axis․range
* @instance
* @memberOf Chart
* @param {Object} range If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.
* @example
* // Update axis' label
* chart.axis.range({
* min: {
* x: -10,
* y: -1000,
* y2: -10000
* },
* max: {
* x: 100,
* y: 1000,
* y2: 10000
* },
* });
*/
range: function(range) {
const axis = this.axis;

if (arguments.length) {
isDefined(range.max) && axis.max(range.max);
isDefined(range.min) && axis.min(range.min);
} else {
return {
max: axis.max(),
min: axis.min()
};
}

/**
* Get and set axis min and max value.
* @method axis:range
* @instance
* @memberof Chart
* @param {Object} range If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.
* @example
* // Update axis' label
* chart.axis.range({
* min: {
* x: -10,
* y: -1000,
* y2: -10000
* },
* max: {
* x: 100,
* y: 1000,
* y2: 10000
* },
* });
*/
axis.range = function(range) {
const axis = this.axis;

if (arguments.length) {
isDefined(range.max) && axis.max(range.max);
isDefined(range.min) && axis.min(range.min);
} else {
return {
max: axis.max(),
min: axis.min()
};
return undefined;
}

return undefined;
};
});

extend(Chart.prototype, {axis});
4 changes: 2 additions & 2 deletions src/api/api.category.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extend(Chart.prototype, {
* Set specified category name on category axis.
* @method category
* @instance
* @memberof Chart
* @memberOf Chart
* @param {Number} i index of category to be changed
* @param {String} category category value to be changed
* @example
Expand All @@ -32,7 +32,7 @@ extend(Chart.prototype, {
* Set category names on category axis.
* @method categories
* @instance
* @memberof Chart
* @memberOf Chart
* @param {Array} categories This must be an array that includes category names in string. If category names are included in the date by data.x option, this is not required.
* @example
* chart.categories([
Expand Down
6 changes: 3 additions & 3 deletions src/api/api.chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extend(Chart.prototype, {
* Resize the chart.
* @method resize
* @instance
* @memberof Chart
* @memberOf Chart
* @param {Object} size This argument should include width and height in pixels.
* @example
* // Resize to 640x480
Expand All @@ -33,7 +33,7 @@ extend(Chart.prototype, {
* Force to redraw.
* @method flush
* @instance
* @memberof Chart
* @memberOf Chart
* @example
* chart.flush();
*/
Expand All @@ -49,7 +49,7 @@ extend(Chart.prototype, {
* Reset the chart object and remove element and events completely.
* @method destroy
* @instance
* @memberof Chart
* @memberOf Chart
* @example
* chart.destroy();
*/
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.color.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extend(Chart.prototype, {
* Get the color
* @method color
* @instance
* @memberof Chart
* @memberOf Chart
* @param {String} id id to get the color
* @example
* chart.color("data1");
Expand Down
Loading

0 comments on commit b2ad2a5

Please sign in to comment.