Skip to content

Commit

Permalink
fix(core): loop also through non-display data to assign colors to dat…
Browse files Browse the repository at this point in the history
  • Loading branch information
theiliad authored and cal-smith committed Dec 2, 2019
1 parent 17d8c1c commit d526522
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 33 deletions.
14 changes: 0 additions & 14 deletions packages/core/demo/demo-data/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const groupedBarData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
65000,
-29123,
Expand All @@ -19,7 +18,6 @@ export const groupedBarData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
32432,
-21312,
Expand All @@ -30,7 +28,6 @@ export const groupedBarData = {
},
{
label: "Dataset 3",
fillColors: [colors[2]],
data: [
-12312,
23232,
Expand All @@ -41,7 +38,6 @@ export const groupedBarData = {
},
{
label: "Dataset 4",
fillColors: [colors[3]],
data: [
-32423,
21313,
Expand Down Expand Up @@ -75,7 +71,6 @@ export const simpleBarData = {
datasets: [
{
label: "Dataset 1",
fillColors: colors,
data: [
65000,
29123,
Expand Down Expand Up @@ -106,7 +101,6 @@ export const simpleBarTimeSeriesData = {
datasets: [
{
label: "Dataset 1",
fillColors: colors,
data: [
{
date: new Date(2019, 0, 1),
Expand Down Expand Up @@ -155,7 +149,6 @@ export const stackedBarData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
65000,
29123,
Expand All @@ -166,7 +159,6 @@ export const stackedBarData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
32432,
21312,
Expand All @@ -177,7 +169,6 @@ export const stackedBarData = {
},
{
label: "Dataset 3",
fillColors: [colors[2]],
data: [
12312,
23232,
Expand All @@ -188,7 +179,6 @@ export const stackedBarData = {
},
{
label: "Dataset 4",
fillColors: [colors[3]],
data: [
32423,
21313,
Expand Down Expand Up @@ -220,7 +210,6 @@ export const stackedBarTimeSeriesData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
{
date: new Date(2019, 0, 1),
Expand All @@ -246,7 +235,6 @@ export const stackedBarTimeSeriesData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
{
date: new Date(2019, 0, 3),
Expand All @@ -272,7 +260,6 @@ export const stackedBarTimeSeriesData = {
},
{
label: "Dataset 3",
fillColors: [colors[2]],
data: [
{
date: new Date(2019, 0, 1),
Expand All @@ -298,7 +285,6 @@ export const stackedBarTimeSeriesData = {
},
{
label: "Dataset 4",
fillColors: [colors[3]],
data: [
{
date: new Date(2019, 0, 2),
Expand Down
16 changes: 0 additions & 16 deletions packages/core/demo/demo-data/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const lineTimeSeriesData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
{
date: new Date(2019, 0, 1),
Expand All @@ -32,7 +31,6 @@ export const lineTimeSeriesData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
{
date: new Date(2019, 0, 2),
Expand All @@ -58,7 +56,6 @@ export const lineTimeSeriesData = {
},
{
label: "Dataset 3",
fillColors: [colors[2]],
data: [
{
date: new Date(2019, 0, 1),
Expand All @@ -84,7 +81,6 @@ export const lineTimeSeriesData = {
},
{
label: "Dataset 4",
fillColors: [colors[3]],
data: [
{
date: new Date(2019, 0, 2),
Expand Down Expand Up @@ -130,7 +126,6 @@ export const lineData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
32100,
23500,
Expand All @@ -141,7 +136,6 @@ export const lineData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
34200,
53200,
Expand All @@ -152,7 +146,6 @@ export const lineData = {
},
{
label: "Dataset 3 long name",
fillColors: [colors[2]],
data: [
41200,
23400,
Expand All @@ -163,7 +156,6 @@ export const lineData = {
},
{
label: "Dataset 4 long name",
fillColors: [colors[3]],
data: [
22000,
1200,
Expand All @@ -174,7 +166,6 @@ export const lineData = {
},
{
label: "Dataset 5 long name",
fillColors: [colors[4]],
data: [
2412,
30000,
Expand All @@ -185,7 +176,6 @@ export const lineData = {
},
{
label: "Dataset 6 long name",
fillColors: [colors[5]],
data: [
0,
20000,
Expand Down Expand Up @@ -232,7 +222,6 @@ export const scatterData = {
datasets: [
{
label: "Dataset 1",
fillColors: [colors[0]],
data: [
32100,
23500,
Expand All @@ -243,7 +232,6 @@ export const scatterData = {
},
{
label: "Dataset 2",
fillColors: [colors[1]],
data: [
34200,
53200,
Expand All @@ -254,7 +242,6 @@ export const scatterData = {
},
{
label: "Dataset 3 long name",
fillColors: [colors[2]],
data: [
41200,
23400,
Expand All @@ -265,7 +252,6 @@ export const scatterData = {
},
{
label: "Dataset 4 long name",
fillColors: [colors[3]],
data: [
22000,
1200,
Expand All @@ -276,7 +262,6 @@ export const scatterData = {
},
{
label: "Dataset 5 long name",
fillColors: [colors[4]],
data: [
2412,
30000,
Expand All @@ -287,7 +272,6 @@ export const scatterData = {
},
{
label: "Dataset 6 long name",
fillColors: [colors[5]],
data: [
0,
20000,
Expand Down
1 change: 0 additions & 1 deletion packages/core/demo/demo-data/pie-donut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const pieData = {
datasets: [
{
label: "Dataset 1",
fillColors: colors,
data: [75000, 65000, 10000, 25000, 1200, 20000]
}
]
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class ChartModel {
});
} else {
const colors = colorPalettes.DEFAULT;
this.getDisplayData().datasets.forEach((dataset, i) => {
this.getData().datasets.forEach((dataset, i) => {
this.colorScale[dataset.label] = scaleOrdinal().range([colors[i]]).domain(this.allDataLabels);
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/tsconfig-demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
],
"exclude": [
"./src/**/*.spec.ts",
"./src/tests/"
"./src/tests/",
"./demo/dist"
]
}

0 comments on commit d526522

Please sign in to comment.