Skip to content

Commit

Permalink
Merge 3572cdb into 6435de2
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ebay committed Dec 15, 2022
2 parents 6435de2 + 3572cdb commit 53cf099
Show file tree
Hide file tree
Showing 33 changed files with 9,434 additions and 0 deletions.
8 changes: 8 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

USE OF SOME COMPONENTS REQUIRES A SEPARATE, NON-OPEN-SOURCE LICENSE FROM THIRD PARTIES

The data visualization components and the charting components of the eBayUI library are designed to use one or more HighCharts® software products. HighCharts® is a registered trademark of HighSoft AS. HighSoft AS is not affiliated with Ebay. Ebay provides no warranties of any kind (e.g., of merchantability, fitness for a particular purpose, and noninfringement), whether express or implied, with respect to the HighCharts® software products that the data visualization components and the charting components are designed to use.

COMMERCIAL USE OF HIGHCHARTS® SOFTWARE PRODUCTS REQUIRES A PAID LICENSE PROVIDED BY HIGHSOFT AS. While many components of the eBayUI library are licensed under the MIT License, the HighCharts® software products which the data visualization components and charting components of the EbayUI library are designed to use are NOT licensed under the MIT License or any other open source license. Rights pertaining to HighCharts® software products (e.g., including, but not limited to, rights to use, install, distribute, publish, merge, duplicate, and modify) are governed by the terms of one or more proprietary license agreements that are available online at http://www.highcharts.com or by the terms of custom license agreements that HighSoft AS may negotiate with its customers at its own discretion. While HighSoft AS may choose to license HighCharts® software products for non-commercial use at no cost, IT IS THE RESPONSIBILITY OF ANY PARTY THAT WISHES TO USE HIGHCHARTS® SOFTWARE PRODUCTS TO VERIFY THE TERMS OF SUCH A LICENSE WITH HIGHSOFT AS. NOTWITHSTANDING ANY PROVISION OF THIS LICENSE, PARTIES WHO ARE NOT LICENSED BY HIGHSOFT AS (OR ITS SUCCESSORS OR ASSIGNS) TO USE HIGHCHARTS® SOFTWARE PRODUCTS ARE NOT LICENSED TO USE THE DATA VISUALIZATION COMPONENTS AND THE CHARTING COMPONENTS OF THE EBAYUI LIBRARY.

This notice shall be included in all copies or substantial portions of the Software.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,11 @@ Looking to contribute to eBay UI? Please visit our [contributing page](CONTRIBUT
Copyright (c) 2018 eBay Inc.

Use of this source code is governed by a MIT-style license that can be found in the LICENSE file or at [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT).

USE OF SOME COMPONENTS REQUIRES A SEPARATE, NON-OPEN-SOURCE LICENSE FROM THIRD PARTIES

The data visualization components and the charting components of the eBayUI library are designed to use one or more HighCharts® software products. HighCharts® is a registered trademark of HighSoft AS. HighSoft AS is not affiliated with Ebay. Ebay provides no warranties of any kind (e.g., of merchantability, fitness for a particular purpose, and noninfringement), whether express or implied, with respect to the HighCharts® software products that the data visualization components and the charting components are designed to use.

COMMERCIAL USE OF HIGHCHARTS® SOFTWARE PRODUCTS REQUIRES A PAID LICENSE PROVIDED BY HIGHSOFT AS. While many components of the eBayUI library are licensed under the MIT License, the HighCharts® software products which the data visualization components and charting components of the EbayUI library are designed to use are NOT licensed under the MIT License or any other open source license. Rights pertaining to HighCharts® software products (e.g., including, but not limited to, rights to use, install, distribute, publish, merge, duplicate, and modify) are governed by the terms of one or more proprietary license agreements that are available online at http://www.highcharts.com or by the terms of custom license agreements that HighSoft AS may negotiate with its customers at its own discretion. While HighSoft AS may choose to license HighCharts® software products for non-commercial use at no cost, IT IS THE RESPONSIBILITY OF ANY PARTY THAT WISHES TO USE HIGHCHARTS® SOFTWARE PRODUCTS TO VERIFY THE TERMS OF SUCH A LICENSE WITH HIGHSOFT AS. NOTWITHSTANDING ANY PROVISION OF THIS LICENSE, PARTIES WHO ARE NOT LICENSED BY HIGHSOFT AS (OR ITS SUCCESSORS OR ASSIGNS) TO USE HIGHCHARTS® SOFTWARE PRODUCTS ARE NOT LICENSED TO USE THE DATA VISUALIZATION COMPONENTS AND THE CHARTING COMPONENTS OF THE EBAYUI LIBRARY.

This notice shall be included in all copies or substantial portions of the Software.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
},
"dependencies": {
"@marko-tags/subscribe": "^0.4.2",
"highcharts": "^10.2.1",
"makeup-active-descendant": "0.6.1",
"makeup-expander": "~0.10.1",
"makeup-floating-label": "~0.3.2",
Expand Down
134 changes: 134 additions & 0 deletions src/common/charts/bar-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
export function eBayColumns(H) {
H.wrap(H.seriesTypes.column.prototype, 'translate', function (proceed) {
const top = this.options.top, // pull out the top value from the highcharts options object
bottom = this.options.bottom; // pull out the bottom value from the highcarts options object

// this runs the original code for this translate function at this point
// if it is not run H.each will not exist yet
proceed.call(this);
H.each(this.points, (point) => {
// loop over each data point element
const shapeArgs = point.shapeArgs, // reference to the points shapeArgs object
x = shapeArgs.x, // references to the shapeArgs X value
w = shapeArgs.width; // references to the shapeArgs width value

let y = shapeArgs.y, // references to the shapeArgs X value
// references to the shapeArgs height value.
// If it is not marked as a bottom point subract 4 pixels to create the visual gap in the chart
h = shapeArgs.height - (bottom ? 0 : 4);

// check to make sure h is not negative and if it is set the hight back to the original height and move it's y position instead
if (h < 0) {
h = shapeArgs.height;
y = y - 4;
}

const cornerRadius = 3;

// H.relativeLength returns a length based on either the integer value, or a percentage of a base with w being the base.
let rTopLeft = H.relativeLength(top ? cornerRadius : 0, w),
rTopRight = H.relativeLength(top ? cornerRadius : 0, w),
rBottomRight = H.relativeLength(bottom ? cornerRadius : 0, w),
rBottomLeft = H.relativeLength(bottom ? cornerRadius : 0, w);

// max corner radius is half the width and height of the shape
const maxCornerRadius = Math.min(w, h) / 2;

// adjust top left corner if it is larger that maxCornerRadius
if (rTopLeft > maxCornerRadius) {
rTopLeft = maxCornerRadius;
}

// adjust top right corner if it is larger that maxCornerRadius
if (rTopRight > maxCornerRadius) {
rTopRight = maxCornerRadius;
}

// adjust bottom right corner if it is larger that maxCornerRadius
if (rBottomRight > maxCornerRadius) {
rBottomRight = maxCornerRadius;
}

// adjust bottom left corner if it is larger that maxCornerRadius
if (rBottomLeft > maxCornerRadius) {
rBottomLeft = maxCornerRadius;
}

point.dlBox = point.shapeArgs; // set the data label Box for aligning tooltips to match the point shape
point.shapeY = y; // set the points y position
point.shapeType = 'path'; // set the shape type to path
point.shapeArgs = {
// define the shape arg used to render the svg path element
// d is a standard SVG path definition string
// refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
d: [
// move to the top left corner plus rTopLeft for the beveled corner width to start the path
'M',
x + rTopLeft,
y,
// top side line
'L',
x + w - rTopRight,
y,
// top right corner curve
'C',
// top right corner start bezier control point
x + w - rTopRight / 2,
y,
// top right corner end bezier control point
x + w,
y + rTopRight / 2,
// top right
x + w,
y + rTopRight,
// right side
'L',
x + w,
y + h - rBottomRight,
// bottom right corner
'C',
// bottom right corner start bezier control point
x + w,
y + h - rBottomRight / 2,
// bottom right corner end bezier control point
x + w - rBottomRight / 2,
y + h,
// bottom right
x + w - rBottomRight,
y + h,
// bottom side
'L',
x + rBottomLeft,
y + h,
// bottom left corner
'C',
// bottom left corner start bezier control point
x + rBottomLeft / 2,
y + h,
// bottom left corner start bezier control point
x,
y + h - rBottomLeft / 2,
// bottom left
x,
y + h - rBottomLeft,
// left side
'L',
x,
y + rTopLeft,
// top left corner
'C',
// top left corner start bezier control point
x,
y + rTopLeft / 2,
// top left corner end bezier control point
x + rTopLeft / 2,
y,
// top left corner
x + rTopLeft,
y,
'Z', // close path
],
};
});
});
}
19 changes: 19 additions & 0 deletions src/common/charts/legend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function ebayLegend(H) {
H.wrap(H.Legend.prototype, 'colorizeItem', function (p, item, visible) {
// this helps make the legend svg elements render crisper
const width = H.pick(item.borderWidth, 1),
crisp = -(width % 2) / 2;
p.apply(this, [].slice.call(arguments, 1));

if (item.legendSymbol) {
if (visible) {
item.legendSymbol.attr({
'stroke-width': width, // set the border width if visible
translateX: crisp, // set translateX to land on a perfect pixel
translateY: crisp, // set translateX to land on a perfect pixel
stroke: item.options.borderColor, // set the border color of legend item
});
}
}
});
}
99 changes: 99 additions & 0 deletions src/common/charts/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
export const chartFontFamily = '"Market Sans", Arial, sans-serif';
export const backgroundColor = 'var(--color-background-primary)';
export const gridColor = 'var(--color-data-viz-grid)';
export const labelsColor = 'var(--color-data-viz-labels)';
export const legendColor = 'var(--color-data-viz-legend)';
export const legendInactiveColor = 'var(--color-data-viz-legend-inactive)';
export const legendHoverColor = 'var(--color-data-viz-legend-hover)';
export const tooltipBackgroundColor = 'var(--color-neutral-0)';
export const tooltipShadows =
'drop-shadow(0 2px 7px var(--color-data-viz-tooltip-shadow-primary)) drop-shadow(0 5px 7px var(--color-data-viz-tooltip-shadow-secondary))';
export const lineChartPrimaryColor = 'var(--color-data-viz-line-chart-primary)';
export const lineChartSecondaryColor = 'var(--color-data-viz-line-chart-secondary)';
export const lineChartTertiaryColor = 'var(--color-data-viz-line-chart-tertiary)';
export const lineChartQueternaryColor = 'var(--color-data-viz-line-chart-queternary)';
export const lineChartQuinaryColor = 'var(--color-data-viz-line-chart-quinary)';
export const trendPositiveColor = 'var(--color-data-viz-trend-positive)';
export const trendNegativeColor = 'var(--color-data-viz-trend-negative)';
export const chartPrimaryColor = 'var(--color-data-viz-chart-primary)';
export const chartSecondaryColor = 'var(--color-data-viz-chart-secondary)';
export const chartTertiaryBackgroundColor = 'var(--color-data-viz-chart-tertiary-background)';
export const chartTertiaryStrokeColor = 'var(--color-data-viz-chart-tertiary-stroke)';
export const chartQuaternaryBackgroundColor = 'var(--color-data-viz-chart-quaternary-background)';
export const chartQuaternaryStrokeColor = 'var(--color-data-viz-chart-quaternary-stroke)';
export const chartQuinaryBackgroundColor = 'var(--color-data-viz-chart-quinary-background)';
export const chartQuinaryStrokeColor = 'var(--color-data-viz-chart-quinary-stroke)';
// patterns are in highcharts PatternOptionsObject format
// refer to https://api.highcharts.com/class-reference/Highcharts.PatternOptionsObject
export const pattern1 = {
pattern: {
path: {
// d is a standard SVG path definition string
// refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
d: 'M0 0 L0 3', // draw a 3 until vertical line
},
width: 4.5, // defines the x bounds of the repeating pattern
height: 3, // defines the y bounds of the repeating pattern
backgroundColor: chartTertiaryBackgroundColor, // sets the patterns background color
color: chartTertiaryStrokeColor, // sets the patterns stroke color
patternTransform: 'rotate(-60)', // rotates the path -60 degrees
},
};
export const pattern2 = {
pattern: {
path: {
// d is a standard SVG path definition string
// refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
d: 'M0 0 L3 0',
},
width: 3, // defines the x bounds of the repeating pattern
height: 5, // defines the y bounds of the repeating pattern
backgroundColor: chartQuaternaryBackgroundColor, // sets the patterns background color
color: chartQuaternaryStrokeColor, // sets the patterns stroke color
},
};
// configure the color sequences based on how many series are used
export const colorsSingle = [chartPrimaryColor];
export const colorsTwo = [chartSecondaryColor, chartPrimaryColor];
export const colorsThree = [chartSecondaryColor, chartPrimaryColor, pattern1];
export const colorsMore = [
chartSecondaryColor,
pattern1,
chartPrimaryColor,
pattern2,
chartQuinaryBackgroundColor,
];
// function is used to set up the colors including lineColor(svg stroke) on each of the series objects
// based on the length of the series array
export function setSeriesColors(series) {
let colors;
switch (series.length) {
case 1:
colors = colorsSingle;
series[0].lineColor = series[0].borderColor = chartPrimaryColor;
break;
case 2:
colors = colorsTwo;
series[0].lineColor = series[0].borderColor = chartSecondaryColor;
series[1].lineColor = series[1].borderColor = chartPrimaryColor;
break;
case 3:
colors = colorsThree;
series[0].lineColor = series[0].borderColor = chartSecondaryColor;
series[1].lineColor = series[1].borderColor = chartPrimaryColor;
series[2].lineColor = series[2].borderColor = chartTertiaryStrokeColor;
break;
default:
colors = colorsMore;
series[0].lineColor = series[0].borderColor = chartSecondaryColor;
series[1].lineColor = series[1].borderColor = chartTertiaryStrokeColor;
series[2].lineColor = series[2].borderColor = chartPrimaryColor;
if (series.length > 3) {
series[3].lineColor = series[3].borderColor = chartQuaternaryStrokeColor;
}
if (series.length > 4) {
series[4].lineColor = series[4].borderColor = chartQuaternaryStrokeColor;
}
}
return colors;
}
Loading

0 comments on commit 53cf099

Please sign in to comment.