Skip to content

Commit

Permalink
fix: exception thrown for charts without a x-axis (#36)
Browse files Browse the repository at this point in the history
* fix: pie chart exception

* fix: incoporate krist's feedbacl
  • Loading branch information
khtruong authored and zhaoyongjie committed Nov 26, 2021
1 parent 2a57177 commit 77396af
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,17 @@ function nvd3Vis(element, props) {
if (chart.x2Axis && chart.x2Axis.tickFormat) {
chart.x2Axis.tickFormat(xAxisFormatter);
}
const isXAxisString = isVizTypes(['dist_bar', 'box_plot']);
if (!isXAxisString && chart.xAxis && chart.xAxis.tickFormat) {
chart.xAxis.tickFormat(xAxisFormatter);
} else {
chart.xAxis.tickFormat(d =>
d.length > MAX_NO_CHARACTERS_IN_LABEL
? `${d.substring(0, MAX_NO_CHARACTERS_IN_LABEL)}…`
: d,
);
if (chart.xAxis && chart.xAxis.tickFormat) {
const isXAxisString = isVizTypes(['dist_bar', 'box_plot']);
if (isXAxisString) {
chart.xAxis.tickFormat(d =>
d.length > MAX_NO_CHARACTERS_IN_LABEL
? `${d.substring(0, MAX_NO_CHARACTERS_IN_LABEL)}…`
: d,
);
} else {
chart.xAxis.tickFormat(xAxisFormatter);
}
}

let yAxisFormatter = getTimeOrNumberFormatter(yAxisFormat);
Expand Down

0 comments on commit 77396af

Please sign in to comment.